2 ## This module finds if wxWindows is installed and determines where the
3 ## include files and libraries are. It also determines what the name of
4 ## the library is. This code sets the following variables:
6 ## ------------------------------------------------------------------
8 ## WXWINDOWS_FOUND = system has WxWindows (in desired config. build)
10 ## WXWINDOWS_LIBRARIES = full path to the wxWindows libraries
11 ## on Unix/Linux with additional linker flags from
14 ## CMAKE_WXWINDOWS_CXX_FLAGS = Unix compiler flags for wxWindows, essentially
15 ## "`wx-config --cxxflags`"
17 ## WXWINDOWS_INCLUDE_DIR = where to find headers "wx/wx.h" "wx/setup.h"
19 ## WXWINDOWS_LINK_DIRECTORIES = link directories, useful for rpath on Unix
21 ## WXWINDOWS_DEFINITIONS = extra defines
24 ## * CMAKE_WX_CAN_COMPILE
25 ## * WXWINDOWS_LIBRARY
26 ## * CMAKE_WX_CXX_FLAGS
27 ## * WXWINDOWS_INCLUDE_PATH
29 ## ------------------------------------------------------------------
32 ## # for convenience include Use_wxWindows.cmake in your projects
35 ## # if you need OpenGL support please
36 ## SET(WXWINDOWS_USE_GL 1)
37 ## # in your CMakeLists.txt *before* you include this file.
39 ## # just include Use_wxWindows.cmake
40 ## # in your projects CMakeLists.txt
41 ## INCLUDE(Use_wxWindows)
43 ## ------------------------------------------------------------------
44 ## Author Jan Woetzel <http://www.mip.informatik.uni-kiel.de/~jw> (07/2003)
45 ## ------------------------------------------------------------------
47 ## -changed variable names to conventions from cmakes readme.txt (Jan Woetzel
49 ## -added definition WINVER for WIN32 (Jan Woetzel 07/07//2003)
50 ## -added IF(CMAKE_WXWINDOWS_CONFIG_EXECUTABLE) found and changed
51 ## CMAKE_WX_CONFIG to CMAKE_WXWINDOWS_CONFIG_EXECUTABLE (Jan Woetzel
53 ## -removed OPTION for CMAKE_WXWINDOWS_USE_GL. Force the developer to SET it.
57 ## -cmake 1.6.7, Linux (Suse 7.3), wxWindows 2.4.0, gcc 2.95
58 ## -cmake 1.6.7, Linux (Suse 8.2), wxWindows 2.4.0, gcc 3.3
59 ## -cmake 1.6.7, Linux (Suse 8.2), wxWindows 2.4.1-patch1, gcc 3.3
60 ## -cmake 1.6.7, MS Windows XP home, wxWindows 2.4.1, MS Visual Studio .net 7
61 ## 2002 (static build)
64 ## -OPTION for unicode builds
65 ## -change WXWINDOWS_USE_GL to use FindOpenGL.cmake or let the user do it
66 ## -testing of DLL linking under MS WIN32
70 SET(WIN32_STYLE_FIND 1)
73 SET(WIN32_STYLE_FIND 0)
74 SET(UNIX_STYLE_FIND 1)
77 SET(UNIX_STYLE_FIND 1)
83 ## ######################################################################
87 ## candidates for root/base directory of wxwindows
88 ## should have subdirs include and lib containing include/wx/wx.h
89 ## fix the root dir to avoid mixing of headers/libs from different
92 SET (WXWINDOWS_POSSIBLE_ROOT_PATHS
94 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\wxWindows_is1;Inno Setup: App Path]" )
96 FIND_PATH(WXWINDOWS_ROOT_DIR include/wx/wx.h
97 ${WXWINDOWS_POSSIBLE_ROOT_PATHS} )
99 ## MESSAGE("DBG found WXWINDOWS_ROOT_DIR: ${WXWINDOWS_ROOT_DIR}")
101 ## find libs for combination of static/shared with release/debug
102 SET (WXWINDOWS_POSSIBLE_LIB_PATHS
103 "${WXWINDOWS_ROOT_DIR}/lib" )
105 FIND_LIBRARY(WXWINDOWS_STATIC_LIBRARY
107 PATHS ${WXWINDOWS_POSSIBLE_LIB_PATHS}
108 DOC "wxWindows static release build library" )
110 FIND_LIBRARY(WXWINDOWS_STATIC_DEBUG_LIBRARY
112 PATHS ${WXWINDOWS_POSSIBLE_LIB_PATHS}
113 DOC "wxWindows static debug build library" )
115 FIND_LIBRARY(WXWINDOWS_SHARED_LIBRARY
116 NAMES wxmsw24 wxmsw241 wxmsw240 wx23_2 wx22_9
117 PATHS ${WXWINDOWS_POSSIBLE_LIB_PATHS}
118 DOC "wxWindows shared release build library" )
120 FIND_LIBRARY(WXWINDOWS_SHARED_DEBUG_LIBRARY
121 NAMES wxmsw24d wxmsw241d wxmsw240d wx23_2d wx22_9d
122 PATHS ${WXWINDOWS_POSSIBLE_LIB_PATHS}
123 DOC "wxWindows shared debug build library " )
126 ## if there is at least one shared lib available
127 ## let user choose wether to use shared or static wxwindows libs
128 IF(WXWINDOWS_SHARED_LIBRARY OR WXWINDOWS_SHARED_DEBUG_LIBRARY)
129 ## default value OFF because wxWindows MSVS default build is static
130 OPTION(WXWINDOWS_USE_SHARED_LIBS
131 "Use shared versions (dll) of wxWindows libraries?" OFF)
132 MARK_AS_ADVANCED(WXWINDOWS_USE_SHARED_LIBS)
133 ENDIF(WXWINDOWS_SHARED_LIBRARY OR WXWINDOWS_SHARED_DEBUG_LIBRARY)
136 ## add system libraries wxwindows depends on
137 SET(CMAKE_WXWINDOWS_LIBRARIES ${CMAKE_WXWINDOWS_LIBRARIES}
141 ## presumably ctl3d32 is not neccesary (Jan Woetzel 07/2003)
143 # debug ${WXWINDOWS_ROOT_DIR}/lib/zlibd.lib optimized ${WXWINDOWS_ROOT_DIR}/lib/zlibd.lib
144 # debug ${WXWINDOWS_ROOT_DIR}/lib/regexd.lib optimized ${WXWINDOWS_ROOT_DIR}/lib/regexd.lib
145 # debug ${WXWINDOWS_ROOT_DIR}/lib/pngd.lib optimized ${WXWINDOWS_ROOT_DIR}/lib/pngd.lib
146 # debug ${WXWINDOWS_ROOT_DIR}/lib/jpegd.lib optimized ${WXWINDOWS_ROOT_DIR}/lib/jpegd.lib
147 # debug ${WXWINDOWS_ROOT_DIR}/lib/tiffd.lib optimized ${WXWINDOWS_ROOT_DIR}/lib/tiff.lib
150 # JW removed option and force the develper th SET it.
151 # OPTION(WXWINDOWS_USE_GL "use wxWindows with GL support (use additional
152 # opengl, glu libs)?" OFF)
154 ## opengl/glu: (TODO/FIXME: better use FindOpenGL.cmake here
155 IF (WXWINDOWS_USE_GL)
156 SET(CMAKE_WXWINDOWS_LIBRARIES ${CMAKE_WXWINDOWS_LIBRARIES}
160 ENDIF (WXWINDOWS_USE_GL)
164 ## select between use of shared or static wxWindows lib then set libs to use
165 ## for debug and optimized build. so the user can switch between debug and
166 ## release build e.g. within MS Visual Studio without running cmake with a
167 ## different build directory again.
169 ## then add the build specific include dir for wx/setup.h
172 IF(WXWINDOWS_USE_SHARED_LIBS)
173 ##MESSAGE("DBG wxWindows use shared lib selected.")
175 ## shared: both wx (debug and release) found?
176 IF(WXWINDOWS_SHARED_DEBUG_LIBRARY AND WXWINDOWS_SHARED_LIBRARY)
177 ##MESSAGE("DBG wx shared: debug and optimized found.")
178 SET(WXWINDOWS_LIBRARIES ${CMAKE_WXWINDOWS_LIBRARIES}
179 debug ${WXWINDOWS_SHARED_DEBUG_LIBRARY}
180 optimized ${WXWINDOWS_SHARED_LIBRARY} )
181 FIND_PATH(WXWINDOWS_INCLUDE_DIR_SETUPH wx/setup.h
182 ${WXWINDOWS_ROOT_DIR}/lib/mswdlld
183 ${WXWINDOWS_ROOT_DIR}/lib/mswdll )
184 ENDIF(WXWINDOWS_SHARED_DEBUG_LIBRARY AND WXWINDOWS_SHARED_LIBRARY)
186 ## shared: only debug wx lib found?
187 IF(WXWINDOWS_SHARED_DEBUG_LIBRARY)
188 IF(NOT WXWINDOWS_SHARED_LIBRARY)
189 ##MESSAGE("DBG wx shared: debug (but no optimized) found.")
190 SET(WXWINDOWS_LIBRARIES ${CMAKE_WXWINDOWS_LIBRARIES}
191 ${WXWINDOWS_SHARED_DEBUG_LIBRARY} )
192 FIND_PATH(WXWINDOWS_INCLUDE_DIR_SETUPH wx/setup.h
193 ${WXWINDOWS_ROOT_DIR}/lib/mswdlld )
194 ENDIF(NOT WXWINDOWS_SHARED_LIBRARY)
195 ENDIF(WXWINDOWS_SHARED_DEBUG_LIBRARY)
197 ## shared: only release wx lib found?
198 IF(NOT WXWINDOWS_SHARED_DEBUG_LIBRARY)
199 IF(WXWINDOWS_SHARED_LIBRARY)
200 ##MESSAGE("DBG wx shared: optimized (but no debug) found.")
201 SET(WXWINDOWS_LIBRARIES ${CMAKE_WXWINDOWS_LIBRARIES}
202 ${WXWINDOWS_SHARED_DEBUG_LIBRARY} )
203 FIND_PATH(WXWINDOWS_INCLUDE_DIR_SETUPH wx/setup.h
204 ${WXWINDOWS_ROOT_DIR}/lib/mswdll )
205 ENDIF(WXWINDOWS_SHARED_LIBRARY)
206 ENDIF(NOT WXWINDOWS_SHARED_DEBUG_LIBRARY)
208 ## shared: none found?
209 IF(NOT WXWINDOWS_SHARED_DEBUG_LIBRARY)
210 IF(NOT WXWINDOWS_SHARED_LIBRARY)
212 "No shared wxWindows lib found, but WXWINDOWS_USE_SHARED_LIBS=${WXWINDOWS_USE_SHARED_LIBS}.")
213 ENDIF(NOT WXWINDOWS_SHARED_LIBRARY)
214 ENDIF(NOT WXWINDOWS_SHARED_DEBUG_LIBRARY)
217 ELSE(WXWINDOWS_USE_SHARED_LIBS)
218 ##MESSAGE("DBG wxWindows static lib selected.")
220 ## static: both wx (debug and release) found?
221 IF(WXWINDOWS_STATIC_DEBUG_LIBRARY AND WXWINDOWS_STATIC_LIBRARY)
222 ##MESSAGE("DBG wx static: debug and optimized found.")
223 SET(WXWINDOWS_LIBRARIES ${CMAKE_WXWINDOWS_LIBRARIES}
224 debug ${WXWINDOWS_STATIC_DEBUG_LIBRARY}
225 optimized ${WXWINDOWS_STATIC_LIBRARY} )
226 FIND_PATH(WXWINDOWS_INCLUDE_DIR_SETUPH wx/setup.h
227 ${WXWINDOWS_ROOT_DIR}/lib/mswd
228 ${WXWINDOWS_ROOT_DIR}/lib/msw )
229 ENDIF(WXWINDOWS_STATIC_DEBUG_LIBRARY AND WXWINDOWS_STATIC_LIBRARY)
231 ## static: only debug wx lib found?
232 IF(WXWINDOWS_STATIC_DEBUG_LIBRARY)
233 IF(NOT WXWINDOWS_STATIC_LIBRARY)
234 ##MESSAGE("DBG wx static: debug (but no optimized) found.")
235 SET(WXWINDOWS_LIBRARIES ${CMAKE_WXWINDOWS_LIBRARIES}
236 ${WXWINDOWS_STATIC_DEBUG_LIBRARY} )
237 FIND_PATH(WXWINDOWS_INCLUDE_DIR_SETUPH wx/setup.h
238 ${WXWINDOWS_ROOT_DIR}/lib/mswd )
239 ENDIF(NOT WXWINDOWS_STATIC_LIBRARY)
240 ENDIF(WXWINDOWS_STATIC_DEBUG_LIBRARY)
242 ## static: only release wx lib found?
243 IF(NOT WXWINDOWS_STATIC_DEBUG_LIBRARY)
244 IF(WXWINDOWS_STATIC_LIBRARY)
245 ##MESSAGE("DBG wx static: optimized (but no debug) found.")
246 SET(WXWINDOWS_LIBRARIES ${CMAKE_WXWINDOWS_LIBRARIES}
247 ${WXWINDOWS_STATIC_DEBUG_LIBRARY} )
248 FIND_PATH(WXWINDOWS_INCLUDE_DIR_SETUPH wx/setup.h
249 ${WXWINDOWS_ROOT_DIR}/lib/msw )
250 ENDIF(WXWINDOWS_STATIC_LIBRARY)
251 ENDIF(NOT WXWINDOWS_STATIC_DEBUG_LIBRARY)
253 ## static: none found?
254 IF(NOT WXWINDOWS_STATIC_DEBUG_LIBRARY)
255 IF(NOT WXWINDOWS_STATIC_LIBRARY)
257 "No static wxWindows lib found, but WXWINDOWS_USE_SHARED_LIBS=${WXWINDOWS_USE_SHARED_LIBS}.")
258 ENDIF(NOT WXWINDOWS_STATIC_LIBRARY)
259 ENDIF(NOT WXWINDOWS_STATIC_DEBUG_LIBRARY)
261 ENDIF(WXWINDOWS_USE_SHARED_LIBS)
264 ## not neccessary in wxWindows 2.4.1
265 ## but it may fix a previous bug, see
266 ## http://lists.wxwindows.org/cgi-bin/ezmlm-cgi?8:mss:37574:200305:mpdioeneabobmgjenoap
267 OPTION(WXWINDOWS_SET_DEFINITIONS "Set additional defines for wxWindows" OFF)
268 MARK_AS_ADVANCED(WXWINDOWS_SET_DEFINITIONS)
269 IF (WXWINDOWS_SET_DEFINITIONS)
270 SET(WXWINDOWS_DEFINITIONS "-DWINVER=0x400")
271 ELSE (WXWINDOWS_SET_DEFINITIONS)
273 SET(WXWINDOWS_DEFINITIONS "")
274 ENDIF (WXWINDOWS_SET_DEFINITIONS)
277 ## Find the include directories for wxwindows
278 ## the first, build specific for wx/setup.h was determined before.
279 ## add inc dir for general for "wx/wx.h"
280 SET (WXWINDOWS_POSSIBLE_INCLUDE_PATHS
281 "${WXWINDOWS_ROOT_DIR}/include"
283 FIND_PATH(WXWINDOWS_INCLUDE_DIR wx/wx.h
284 ${WXWINDOWS_POSSIBLE_INCLUDE_PATHS}
286 # append the build specific include dir for wx/setup.h:
287 IF (WXWINDOWS_INCLUDE_DIR_SETUPH)
288 SET(WXWINDOWS_INCLUDE_DIR ${WXWINDOWS_INCLUDE_DIR} ${WXWINDOWS_INCLUDE_DIR_SETUPH} )
289 ENDIF (WXWINDOWS_INCLUDE_DIR_SETUPH)
293 WXWINDOWS_INCLUDE_DIR
294 WXWINDOWS_INCLUDE_DIR_SETUPH
295 WXWINDOWS_STATIC_LIBRARY
296 WXWINDOWS_STATIC_DEBUG_LIBRARY
297 WXWINDOWS_SHARED_LIBRARY
298 WXWINDOWS_SHARED_DEBUG_LIBRARY
302 ELSE(WIN32_STYLE_FIND)
304 ## ######################################################################
306 ## UNIX/Linux specific:
308 ## use backquoted wx-config to query and set flags and libs:
309 ## 06/2003 Jan Woetzel
312 OPTION(WXWINDOWS_USE_SHARED_LIBS "Use shared versions (.so) of wxWindows libraries" ON)
313 MARK_AS_ADVANCED(WXWINDOWS_USE_SHARED_LIBS)
315 # JW removed option and force the develper th SET it.
316 # OPTION(WXWINDOWS_USE_GL "use wxWindows with GL support (use additional
317 # --gl-libs for wx-config)?" OFF)
319 # wx-config should be in your path anyhow, usually no need to set WXWIN or
320 # search in ../wx or ../../wx
321 FIND_PROGRAM(CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE wx-config
326 # check wether wx-config was found:
327 IF(CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE)
329 # use shared/static wx lib?
330 # remember: always link shared to use systems GL etc. libs (no static
331 # linking, just link *against* static .a libs)
332 IF(WXWINDOWS_USE_SHARED_LIBS)
333 SET(WX_CONFIG_ARGS_LIBS "--libs")
334 ELSE(WXWINDOWS_USE_SHARED_LIBS)
335 SET(WX_CONFIG_ARGS_LIBS "--static --libs")
336 ENDIF(WXWINDOWS_USE_SHARED_LIBS)
338 # do we need additionial wx GL stuff like GLCanvas ?
340 SET(WX_CONFIG_ARGS_LIBS "${WX_CONFIG_ARGS_LIBS} --gl-libs" )
341 ENDIF(WXWINDOWS_USE_GL)
342 ##MESSAGE("DBG: WX_CONFIG_ARGS_LIBS=${WX_CONFIG_ARGS_LIBS}===")
344 # set CXXFLAGS to be fed into CMAKE_CXX_FLAGS by the user:
345 SET(CMAKE_WXWINDOWS_CXX_FLAGS "`${CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE} --cxxflags`")
346 ##MESSAGE("DBG: for compilation:
347 ##CMAKE_WXWINDOWS_CXX_FLAGS=${CMAKE_WXWINDOWS_CXX_FLAGS}===")
349 # keep the back-quoted string for clarity
350 SET(WXWINDOWS_LIBRARIES "`${CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE} ${WX_CONFIG_ARGS_LIBS}`")
351 ##MESSAGE("DBG2: for linking:
352 ##WXWINDOWS_LIBRARIES=${WXWINDOWS_LIBRARIES}===")
354 # evaluate wx-config output to separate linker flags and linkdirs for
356 EXEC_PROGRAM(${CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE}
357 ARGS ${WX_CONFIG_ARGS_LIBS}
358 OUTPUT_VARIABLE WX_CONFIG_LIBS )
360 ## extract linkdirs (-L) for rpath
361 ## use regular expression to match wildcard equivalent "-L*<endchar>"
362 ## with <endchar> is a space or a semicolon
363 STRING(REGEX MATCHALL "[-][L]([^ ;])+" WXWINDOWS_LINK_DIRECTORIES_WITH_PREFIX "${WX_CONFIG_LIBS}" )
364 #MESSAGE("DBG WXWINDOWS_LINK_DIRECTORIES_WITH_PREFIX=${WXWINDOWS_LINK_DIRECTORIES_WITH_PREFIX}")
366 ## remove prefix -L because we need the pure directory for LINK_DIRECTORIES
367 ## replace -L by ; because the separator seems to be lost otherwise (bug or
369 IF(WXWINDOWS_LINK_DIRECTORIES_WITH_PREFIX)
370 STRING(REGEX REPLACE "[-][L]" ";" WXWINDOWS_LINK_DIRECTORIES ${WXWINDOWS_LINK_DIRECTORIES_WITH_PREFIX} )
371 #MESSAGE("DBG WXWINDOWS_LINK_DIRECTORIES=${WXWINDOWS_LINK_DIRECTORIES}")
372 ENDIF(WXWINDOWS_LINK_DIRECTORIES_WITH_PREFIX)
375 ## replace space separated string by semicolon separated vector to make it
376 ## work with LINK_DIRECTORIES
377 SEPARATE_ARGUMENTS(WXWINDOWS_LINK_DIRECTORIES)
380 CMAKE_WXWINDOWS_CXX_FLAGS
381 WXWINDOWS_INCLUDE_DIR
383 CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE
387 # we really need wx-config...
388 ELSE(CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE)
389 MESSAGE(SEND_ERROR "Cannot find wx-config anywhere on the system. Please put the file into your path or specify it in CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE.")
390 MARK_AS_ADVANCED(CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE)
391 ENDIF(CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE)
395 ELSE(UNIX_STYLE_FIND)
396 MESSAGE(SEND_ERROR "FindwxWindows.cmake: Platform unknown/unsupported by FindwxWindows.cmake. It's neither WIN32 nor UNIX")
397 ENDIF(UNIX_STYLE_FIND)
398 ENDIF(WIN32_STYLE_FIND)
401 IF(WXWINDOWS_LIBRARIES)
402 IF(WXWINDOWS_INCLUDE_DIR OR CMAKE_WXWINDOWS_CXX_FLAGS)
404 ## found all we need.
405 SET(WXWINDOWS_FOUND 1)
407 ## set deprecated variables for backward compatibility:
408 SET(CMAKE_WX_CAN_COMPILE ${WXWINDOWS_FOUND})
409 SET(WXWINDOWS_LIBRARY ${WXWINDOWS_LIBRARIES})
410 SET(WXWINDOWS_INCLUDE_PATH ${WXWINDOWS_INCLUDE_DIR})
411 SET(CMAKE_WX_CXX_FLAGS ${CMAKE_WXWINDOWS_CXX_FLAGS})
413 ENDIF(WXWINDOWS_INCLUDE_DIR OR CMAKE_WXWINDOWS_CXX_FLAGS)
414 ENDIF(WXWINDOWS_LIBRARIES)