]> Creatis software - crea.git/blob - cmake/FindWxWidgetsWin32.cmake
3941224bb3807e0dd5fba081ba7221ee05e070af
[crea.git] / cmake / FindWxWidgetsWin32.cmake
1 #
2 # FindwxW.cmake
3 # v1.06 2006-03-27
4 # Jerry Fath 2005
5 # Based on work by Jorgen Bodde
6 #
7 # This module finds if wxWindows is installed and determines where the
8 # include files and libraries are. It also determines what the name of
9 # the library is. This code sets the following variables:
10 #
11 #  WXWIDGETS_FOUND =     wxWidgets was found
12 #  WXWIDGETS_ROOT_DIR =  base wxWidgets directory
13 #  WXWIDGETS_LINK_DIRECTORIES = link directories, useful for rpath on Unix
14 #  WXWIDGETS_LIBRARIES       = all the wxWindows libraries ( and  linker flags on unix )
15 #  WXWIDGETS_CXX_FLAGS        = compiler flags for building wxWindows
16 #  WXWIDGETS_EXE_LINKER_FLAGS  = compiler flags for building wxWindows
17 #  WXWIDGETS_INCLUDE_DIR    = all include path of wxWindows
18 #  WXWIDGETS_DEFINITIONS  = all flags of wxWindows
19 #
20 #  WXWIDGETS_RELEASE_LIBRARIES       = release wxWindows libraries (Win32 only)
21 #  WXWIDGETS_DEBUG_LIBRARIES       = debug wxWindows libraries (Win32 only)
22 #  WXWIDGETS_COMMON_LIBRARIES  = libraries common to Release and Debug (Win32 only)
23
24 # NOTE: This module REQUIRES that an environment variable named WXWIN
25 # be set to the base wxWidgets installation directory.
26 # Under Unix, you must also set and environment variable named WXWINCFG
27 # to the name of the active build subdirectory (eg buildgtk).  As an alternative
28 # to the WXWINCFG environment variable, you can set a sym link in the wxWidgets
29 # root directory called wx-config which points to the active build subdirectory.
30 #
31
32 # These variable should be set before including this module
33 #
34 # WXWIDGETS_FILE_VERSION (26)
35 # WXWIDGETS_VERSION (2.6)
36 #
37 #
38
39 ####################### EXAMPLE CMakeLists.txt ###################
40 #
41 ##Required project specific settings
42 #PROJECT( myprojectname )
43 #SET(PROJECT_SOURCE_FILES  myfile.cpp myfile2.cpp)
44 #IF( WIN32)
45 #    SET(PROJECT_RC_FILE myresfile.rc)
46 #ELSE( WIN32)
47 #    SET(PROJECT_RC_FILE "")
48 #ENDIF( WIN32)
49 #
50 ##Optional project specific settings
51 #SET(PROJECT_DEFINITIONS -D_MYPROJECT_ -D_MYPROJECT2_)
52 #SET(PROJECT_INCLUDE_PATH e:/myproject/include e:/myproject2/include)
53 #SET(PROJECT_LINK_DIRECTORIES e:/myproject/lib e:/myproject2/lib)
54 #SET(PROJECT_LIBRARIES myprojectlib myproject2lib)
55 #
56 ##wxWidgets build related stuff
57 #SET(WXW_USE_DEBUG OFF)
58 #SET(WXW_USE_UNICODE OFF)
59 #SET(WXW_USE_SHARED OFF)
60 #SET(WXW_USE_UNIV OFF)
61 #SET(WXW_USE_MONO OFF)
62 #SET(WXW_FILE_VERSION "26")
63 #SET(WXW_VERSION "2.6")
64 #
65 #INCLUDE (FindwxW)
66 #INCLUDE (UsewxW)
67 #
68 ####################### END EXAMPLE CMakeLists.txt ###################
69
70 #
71 # Set WX_USE vars in CMakeLists if you don't want to default to all off
72 #
73 SET(WXWIDGETS_USE_DEBUG ${WXW_USE_DEBUG} CACHE BOOL "Use Debug versions of wxWindows libraries")
74 SET(WXWIDGETS_USE_UNICODE ${WXW_USE_UNICODE} CACHE BOOL "Use Unicode versions of wxWindows libraries")
75 SET(WXWIDGETS_USE_SHARED ${WXW_USE_SHARED} CACHE BOOL "Use shared versions of wxWindows libraries")
76 SET(WXWIDGETS_USE_UNIV ${WXW_USE_UNIV} CACHE BOOL "Use Universal versions of wxWindows libraries")
77 SET(WXWIDGETS_USE_MONO ${WXW_USE_MONO} CACHE BOOL "Use monolithic versions of wxWindows libraries")
78
79 #
80 # Style can be non-Win32 even under Windows when using MinGW
81 #
82 IF(WIN32)
83   SET(WIN32_STYLE_FIND 1)
84 ENDIF(WIN32)
85 IF(MINGW)
86   SET(WIN32_STYLE_FIND 1)
87   if(UNIX)
88     SET(WIN32_STYLE_FIND 0)
89   SET(UNIX_STYLE_FIND 1)
90   endif(UNIX)
91 ENDIF(MINGW)
92 IF(UNIX)
93   SET(UNIX_STYLE_FIND 1)
94 ENDIF(UNIX)
95
96 #
97 # Versions should be set before this file is included.  If not,
98 # default to 2.6
99 #
100 IF(WXW_FILE_VERSION)
101   SET( WXVERSIONSUFFIX ${WXW_FILE_VERSION})
102 ELSE(WXW_FILE_VERSION)
103   SET( WXVERSIONSUFFIX "26")
104 ENDIF(WXW_FILE_VERSION)
105
106 IF(WXW_VERSION)
107   SET( WXVERSION ${WXW_VERSION})
108 ELSE(WXW_VERSION)
109   SET( WXVERSION "2.6")
110 ENDIF(WXW_VERSION)
111
112 #
113 # Find the base wxWidgets install path
114 # NOTE: WXWIN must be set
115 #
116 FIND_PATH( WXWIDGETS_ROOT_DIR
117    wx-config.in
118    $ENV{WXWIN}
119 )
120 IF(WXWIDGETS_ROOT_DIR STREQUAL "WXWIDGETS_ROOT_DIR-NOTFOUND")
121     MESSAGE( FATAL_ERROR "FATAL_ERROR: wx-config.in NOT found.  Set WXWIN")
122 ENDIF(WXWIDGETS_ROOT_DIR STREQUAL "WXWIDGETS_ROOT_DIR-NOTFOUND")
123 SET(WXWIDGETS_CONFIG_PATH ${WXWIDGETS_ROOT_DIR})
124
125 #
126 # Find library path (platform specific)
127 #
128 IF( WIN32_STYLE_FIND )
129
130     #DFCH: If x64 architecture
131         IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
132                 IF( WXWIDGETS_USE_SHARED )
133         SET(WXWIDGETS_LIB_PATH "${WXWIDGETS_ROOT_DIR}/lib/vc_amd64_dll" )
134                 ELSE( WXWIDGETS_USE_SHARED )
135         SET(WXWIDGETS_LIB_PATH "${WXWIDGETS_ROOT_DIR}/lib/vc_amd64_lib" )
136                 ENDIF( WXWIDGETS_USE_SHARED )
137         ELSE (CMAKE_SIZEOF_VOID_P EQUAL 8)
138                 IF( WXWIDGETS_USE_SHARED )
139         SET(WXWIDGETS_LIB_PATH "${WXWIDGETS_ROOT_DIR}/lib/vc_dll" )
140                 ELSE( WXWIDGETS_USE_SHARED )
141         SET(WXWIDGETS_LIB_PATH "${WXWIDGETS_ROOT_DIR}/lib/vc_lib" )
142                 ENDIF( WXWIDGETS_USE_SHARED )
143         ENDIF (CMAKE_SIZEOF_VOID_P EQUAL 8)
144     SET( WXWIDGETS_LINK_DIRECTORIES ${WXWIDGETS_LIB_PATH} )
145
146 ELSE( WIN32_STYLE_FIND )
147   IF (UNIX_STYLE_FIND) 
148
149     #
150     # Unix uses a config specific directory under the install path
151     # specified in the WXWINCFG environment variable.
152     # If the WXWINCFG variable isn't set, we try a sym link within
153     # the WX root dir called wx-config, or the current PATH
154     #
155     FIND_PROGRAM( WX_WXCONFIG_EXECUTABLE
156                     wx-config
157                     "${WXWIDGETS_ROOT_DIR}/$ENV{WXWINCFG}"
158                     "${WXWIDGETS_ROOT_DIR}/wx-config" )
159     #
160     # Check wether wx-config can be found
161     #
162     IF(NOT EXISTS ${WX_WXCONFIG_EXECUTABLE})    
163       # we really need wx-config...
164       MESSAGE(FATAL_ERROR "FATAL_ERROR: Cannot find wx-config. Set WXWIN and WXWINCFG environment variables.")
165     ENDIF(NOT EXISTS ${WX_WXCONFIG_EXECUTABLE})    
166
167     GET_FILENAME_COMPONENT( WXWIDGETS_CONFIG_PATH
168                             WX_WXCONFIG_EXECUTABLE
169                             PATH )
170
171     SET(WXWIDGETS_LIB_PATH "${WXWIDGETS_CONFIG_PATH}/lib" )
172     SET( WXWIDGETS_LINK_DIRECTORIES ${WXWIDGETS_LIB_PATH} )
173
174   ELSE(UNIX_STYLE_FIND)
175     MESSAGE(FATAL_ERROR "FATAL_ERROR: FindwxWindows.cmake:  Platform unsupported by FindwxW.cmake. It's neither WIN32 nor UNIX")
176   ENDIF(UNIX_STYLE_FIND)
177 ENDIF( WIN32_STYLE_FIND )
178
179 #
180 # Check options against installed libraries
181 #
182 SET(WX_CONFIG_ARGS "")
183 SET( LIBRARYWANT  "${WXWIDGETS_LIB_PATH}/msw" )
184
185 IF( WXWIDGETS_USE_UNIV )
186     SET( LIBRARYWANT "${LIBRARYWANT}univ")
187     SET( PFUNIV  "univ" )
188     SET(WX_CONFIG_ARGS "${WX_CONFIG_ARGS} --universal=yes")
189 ELSE( WXWIDGETS_USE_UNIV )
190     SET(WX_CONFIG_ARGS "${WX_CONFIG_ARGS} --universal=no")
191 ENDIF( WXWIDGETS_USE_UNIV )
192
193 IF( WXWIDGETS_USE_UNICODE )
194     SET( LIBRARYWANT "${LIBRARYWANT}u" )
195     SET( PFUNICODE "u" )
196     SET(WX_CONFIG_ARGS "${WX_CONFIG_ARGS} --unicode=yes")
197 ELSE( WXWIDGETS_USE_UNICODE )
198     SET(WX_CONFIG_ARGS "${WX_CONFIG_ARGS} --unicode=no")
199 ENDIF( WXWIDGETS_USE_UNICODE )
200
201 IF( WXWIDGETS_USE_DEBUG )
202     SET( PFDEBUG "d" )
203     SET(WX_CONFIG_ARGS "${WX_CONFIG_ARGS} --debug=yes")
204 ELSE( WXWIDGETS_USE_DEBUG )
205     SET( PFDEBUG "" )
206     SET(WX_CONFIG_ARGS "${WX_CONFIG_ARGS} --debug=no")
207 ENDIF( WXWIDGETS_USE_DEBUG )
208
209 IF( WXWIDGETS_USE_SHARED )
210     SET(WX_CONFIG_ARGS "${WX_CONFIG_ARGS} --static=no")
211 ELSE( WXWIDGETS_USE_SHARED )
212     SET(WX_CONFIG_ARGS "${WX_CONFIG_ARGS} --static=yes")
213 ENDIF( WXWIDGETS_USE_SHARED )
214
215 # Not sure how to check this yet!!!!!
216 IF( WXWIDGETS_USE_MONO )
217     SET(WX_CONFIG_ARGS "${WX_CONFIG_ARGS}")
218 ELSE( WXWIDGETS_USE_MONO )
219     SET(WX_CONFIG_ARGS "${WX_CONFIG_ARGS}")
220 ENDIF( WXWIDGETS_USE_MONO )
221
222 SET(WX_CONFIG_ARGS_LIBS "${WX_CONFIG_ARGS} --libs")
223
224 #
225 # Platform specific method for testing installed wx Builds
226 #
227 IF( WIN32_STYLE_FIND )
228
229     #
230     # See if we have both release and debug wx versions
231     #
232     SET ( WX_DEBUGANDRELEASE FALSE )
233     IF( EXISTS "${LIBRARYWANT}/wx/setup.h" )
234         IF( EXISTS "${LIBRARYWANT}d/wx/setup.h" )
235             SET ( WX_DEBUGANDRELEASE TRUE )
236         ENDIF( EXISTS "${LIBRARYWANT}d/wx/setup.h" )
237     ENDIF( EXISTS "${LIBRARYWANT}/wx/setup.h" )
238
239     SET( LIBRARYWANT "${LIBRARYWANT}${PFDEBUG}" )
240     IF( NOT EXISTS "${LIBRARYWANT}/wx/setup.h" )
241         MESSAGE( SEND_ERROR "ERROR: WXWidgets config NOT found ${WX_CONFIG_ARGS}")
242     ENDIF( NOT EXISTS "${LIBRARYWANT}/wx/setup.h" )
243
244 ELSE( WIN32_STYLE_FIND )
245
246     EXEC_PROGRAM(${WX_WXCONFIG_EXECUTABLE}
247         ARGS ${WX_CONFIG_ARGS_LIBS}
248         OUTPUT_VARIABLE WXWIDGETS_LIBRARIES
249         RETURN_VALUE BAD_WXCONFIG )
250     IF(BAD_WXCONFIG)
251         MESSAGE( SEND_ERROR "ERROR: WXWidgets config NOT found ${WX_CONFIG_ARGS}")
252     ENDIF(BAD_WXCONFIG)
253
254 ENDIF( WIN32_STYLE_FIND )
255
256 #
257 #  Get compiler flags
258 #
259 IF( WIN32_STYLE_FIND )
260     # Not used for Windows
261     SET( WXWIDGETS_CXX_FLAGS "" )
262 ELSE( WIN32_STYLE_FIND )
263     #
264     # Get CXXFLAGS from wx-config
265     #
266     EXEC_PROGRAM(${WX_WXCONFIG_EXECUTABLE}
267       ARGS "--cxxflags"
268       OUTPUT_VARIABLE WXWIDGETS_CXX_FLAGS
269       RETURN_VALUE BAD_WXCONFIG )
270     IF (BAD_WXCONFIG)
271       MESSAGE( SEND_ERROR "ERROR: wx-config --cxxflags returned an error")
272     ENDIF (BAD_WXCONFIG)
273 ENDIF( WIN32_STYLE_FIND )
274
275 #
276 # Find include directories (platform specific)
277 #
278 IF( WIN32_STYLE_FIND )
279     #
280     # Set non-build specific include directories
281     #
282     SET ( WX_INCLUDE_PATH ${WXWIDGETS_ROOT_DIR}/include )
283     SET ( WXWIDGETS_INCLUDE_DIR ${WX_INCLUDE_PATH} )
284     SET( WXWIDGETS_INCLUDE_DIR ${WXWIDGETS_INCLUDE_DIR} ${WXWIDGETS_INCLUDE_DIR}/../contrib/include )
285     #
286     # Append the build specific include dir for wx/setup.h:
287     #
288     IF ( EXISTS ${LIBRARYWANT}/wx/setup.h )
289         SET( WX_INCLUDE_LIB_PATH ${LIBRARYWANT})
290         SET( WXWIDGETS_INCLUDE_DIR  ${WXWIDGETS_INCLUDE_DIR}  ${LIBRARYWANT} )
291     ELSE ( EXISTS ${LIBRARYWANT}/wx/setup.h )
292         SET( WX_INCLUDE_LIB_PATH, "")
293         MESSAGE(SEND_ERROR "ERROR: Can't find ${LIBRARYWANT}/wx/setup.h")
294     ENDIF ( EXISTS ${LIBRARYWANT}/wx/setup.h )
295
296 ELSE( WIN32_STYLE_FIND )
297
298     # Pull out -I options
299     # evaluate wx-config output to separate include dirs
300     SET(WX_INCLUDE_DIR ${WXWIDGETS_CXX_FLAGS})
301     # extract include dirs (-I)
302     # use regular expression to match wildcard equivalent "-I*<endchar>"
303     # with <endchar> is a space or a semicolon
304     STRING(REGEX MATCHALL "[-][I]([^ ;])+" WX_INCLUDE_DIRS_WITH_PREFIX "${WX_INCLUDE_DIR}" )
305     # remove prefix -I because we need the pure directory
306     IF(WX_INCLUDE_DIRS_WITH_PREFIX)
307       STRING(REGEX REPLACE "[-][I]" ";" WXWIDGETS_INCLUDE_DIR ${WX_INCLUDE_DIRS_WITH_PREFIX} )
308     ENDIF(WX_INCLUDE_DIRS_WITH_PREFIX)
309     # replace space separated string by semicolon separated vector
310     SEPARATE_ARGUMENTS(WXWIDGETS_INCLUDE_DIR)
311     # Remove the -I options from the CXX_FLAGS no need to duplicate
312     STRING(REGEX REPLACE "[-][I]([^ ;])+" "" WXWIDGETS_CXX_FLAGS ${WXWIDGETS_CXX_FLAGS} )
313
314     #
315     # Find XWindows
316     #
317     IF( NOT CYGWIN OR MINGW )
318         INCLUDE( ${CMAKE_ROOT}/Modules/FindX11.cmake )
319         SET( WXWIDGETS_INCLUDE_DIR ${WXWIDGETS_INCLUDE_DIR}  ${X11_INCLUDE_DIR} )
320     ENDIF( NOT CYGWIN OR MINGW )
321 ENDIF( WIN32_STYLE_FIND )
322
323 #
324 # Find library list (platform specific)
325 #
326 IF( WIN32_STYLE_FIND )
327     #
328     #Misc vars used to build lib names
329     #
330     SET( PFLIBEXT ${CMAKE_STATIC_LIBRARY_SUFFIX} )
331     SET( WXPF "${WXPF}${WXVERSIONSUFFIX}" )
332     SET( PFVERSION ${WXVERSIONSUFFIX} )
333     SET( PFCOMPILER "" )
334
335     #
336     # Build the libraries list
337     #
338     SET( WX_TOKEN_LIBS "" )
339     SET( WX_MULTI_LIBRARIES "" )
340     SET( WX_MONO_LIBRARIES "" )
341     SET( WX_DEBUG_TOKEN "@1" )
342
343     #start filling library string with needed libraries for the choosen configuration.
344     #note we use tokens for debug/release and the debug suffix so we can replace later
345     SET( WXPF "${PFVERSION}${PFUNICODE}${WX_DEBUG_TOKEN}" )
346     SET(WX_MULTI_LIBRARIES ${WX_MULTI_LIBRARIES}
347         wxbase${WXPF}${PFCOMPILER}${PFLIBEXT}
348         wxbase${WXPF}_net${PFCOMPILER}${PFLIBEXT}
349         wxbase${WXPF}_xml${PFCOMPILER}${PFLIBEXT}
350     )
351
352     SET( WXPF "${PFVERSION}${PFUNICODE}${WX_DEBUG_TOKEN}" )
353     SET(WX_MULTI_LIBRARIES ${WX_MULTI_LIBRARIES}
354         wxmsw${WXPF}_adv${PFCOMPILER}${PFLIBEXT}
355         wxmsw${WXPF}_core${PFCOMPILER}${PFLIBEXT}
356         wxmsw${WXPF}_html${PFCOMPILER}${PFLIBEXT}
357         wxmsw${WXPF}_xrc${PFCOMPILER}${PFLIBEXT}
358     )
359     IF (WXWIDGETS_USE_MEDIA)
360         SET(WX_MULTI_LIBRARIES ${WX_MULTI_LIBRARIES}
361             wxmsw${WXPF}_media${PFCOMPILER}${PFLIBEXT}
362         )
363     ENDIF (WXWIDGETS_USE_MEDIA)
364
365     IF( NOT WXWIDGETS_USE_SHARED )
366         SET( WXPF "${PFVERSION}${PFUNICODE}${WX_DEBUG_TOKEN}" )
367         IF (WXWIDGETS_USE_ODBC)
368             SET(WX_MULTI_LIBRARIES ${WX_MULTI_LIBRARIES}
369                 wxbase${WXPF}_odbc${PFCOMPILER}${PFLIBEXT}
370              )
371         ENDIF (WXWIDGETS_USE_ODBC)
372
373         SET( WXPF "${PFVERSION}${PFUNICODE}${WX_DEBUG_TOKEN}" )
374         IF (WXWIDGETS_USE_DBGRID)
375             SET(WX_MULTI_LIBRARIES ${WX_MULTI_LIBRARIES}
376                 wxmsw${WXPF}_dbgrid${PFLIBEXT}
377             )
378         ENDIF (WXWIDGETS_USE_DBGRID)
379         IF (WXWIDGETS_USE_GL)
380             SET(WX_MULTI_LIBRARIES ${WX_MULTI_LIBRARIES}
381                 wxmsw${WXPF}_gl${PFCOMPILER}${PFLIBEXT}
382             )
383         ENDIF (WXWIDGETS_USE_GL)
384     ENDIF( NOT WXWIDGETS_USE_SHARED )
385
386     IF ( WXWIDGETS_USE_UNIV )
387         SET( WXPF "${PFUNIV}${PFVERSION}${PFUNICODE}${WX_DEBUG_TOKEN}" )
388         SET(WX_MULTI_LIBRARIES ${WX_MULTI_LIBRARIES}
389             wxmsw${WXPF}_core${PFCOMPILER}${PFLIBEXT}
390         )
391     ENDIF ( WXWIDGETS_USE_UNIV )
392
393     SET(WX_MONO_LIBRARIES ${WX_MONO_LIBRARIES}
394         wxmsw${WXPF}${PFCOMPILER}${PFLIBEXT}
395     )
396
397     IF ( WXWIDGETS_USE_MONO )
398         SET(WX_TOKEN_LIBS ${WX_TOKEN_LIBS} ${WX_MONO_LIBRARIES})
399     ELSE ( WXWIDGETS_USE_MONO )
400         SET(WX_TOKEN_LIBS ${WX_TOKEN_LIBS} ${WX_MULTI_LIBRARIES})
401     ENDIF ( WXWIDGETS_USE_MONO )
402
403     SET( WXPF "${PFUNICODE}${WX_DEBUG_TOKEN}" )
404     SET(WX_TOKEN_LIBS ${WX_TOKEN_LIBS}
405         wxregex${WXPF}.lib
406     )
407
408     SET( WXPF "${WX_DEBUG_TOKEN}" )
409     SET(WX_TOKEN_LIBS ${WX_TOKEN_LIBS}
410             wxexpat${WXPF}.lib
411             wxpng${WXPF}.lib
412             wxtiff${WXPF}.lib
413             wxjpeg${WXPF}.lib
414             wxzlib${WXPF}.lib
415     )
416
417
418     SET( WXWIDGETS_COMMON_LIBRARIES 
419         comctl32${PFLIBEXT} wsock32${PFLIBEXT} rpcrt4${PFLIBEXT}
420     )
421     #
422     #Build release/debug lists by replacing tokens
423     #
424     SET( WXWIDGETS_RELEASE_LIBRARIES "" )
425     FOREACH(LOOPLIB ${WX_TOKEN_LIBS})
426         SET(WX_TMPLIB ${LOOPLIB})
427         STRING(REGEX REPLACE "[@][1]" "" WX_TMPLIB ${WX_TMPLIB} )
428         SET( WXWIDGETS_RELEASE_LIBRARIES ${WXWIDGETS_RELEASE_LIBRARIES}
429             ${WX_TMPLIB}
430         ) 
431     ENDFOREACH(LOOPLIB ${WX_TOKEN_LIBS})
432     SET( WXWIDGETS_DEBUG_LIBRARIES "" )
433     FOREACH(LOOPLIB ${WX_TOKEN_LIBS})
434         SET(WX_TMPLIB ${LOOPLIB})
435         STRING(REGEX REPLACE "[@][1]" "d" WX_TMPLIB ${WX_TMPLIB} )
436         SET( WXWIDGETS_DEBUG_LIBRARIES ${WXWIDGETS_DEBUG_LIBRARIES}
437             ${WX_TMPLIB}
438         ) 
439     ENDFOREACH(LOOPLIB ${WX_TOKEN_LIBS})
440
441     #
442     # Set full lib list to requested type
443     #
444     IF( WXWIDGETS_USE_DEBUG )
445         SET( WXWIDGETS_LIBRARIES ${WXWIDGETS_COMMON_LIBRARIES}
446             ${WXWIDGETS_DEBUG_LIBRARIES}
447         ) 
448     ELSE( WXWIDGETS_USE_DEBUG )
449         SET( WXWIDGETS_LIBRARIES ${WXWIDGETS_COMMON_LIBRARIES}
450             ${WXWIDGETS_RELEASE_LIBRARIES}
451         ) 
452     ENDIF( WXWIDGETS_USE_DEBUG )
453
454     #Not used under Windows
455     SET( WXWIDGETS_EXE_LINKER_FLAGS "" )
456
457 ELSE( WIN32_STYLE_FIND )
458     #
459     # Get Library list from wx-config
460     #
461     # do we need additionial wx GL stuff like GLCanvas ?
462     IF(WXWIDGETS_USE_GL)
463       SET(WX_CONFIG_ARGS_LIBS "${WX_CONFIG_ARGS_LIBS} --gl-libs" )
464     ENDIF(WXWIDGETS_USE_GL)
465       
466     EXEC_PROGRAM(${WX_WXCONFIG_EXECUTABLE}
467       ARGS ${WX_CONFIG_ARGS_LIBS}
468       OUTPUT_VARIABLE WX_CONFIGARGS
469       RETURN_VALUE BAD_WXCONFIG )
470     IF (BAD_WXCONFIG)
471       MESSAGE( SEND_ERROR "ERROR: Specified WXWidgets config NOT found")
472     ENDIF (BAD_WXCONFIG)
473       
474     #Pull lib dirs, linker opts, and libs from wx-config --libs return
475     SET(WXWIDGETS_LINK_DIRECTORIES "")
476     SET(WXWIDGETS_EXE_LINKER_FLAGS "")
477     SET(WXWIDGETS_LIBRARIES "")
478     SEPARATE_ARGUMENTS(WX_CONFIGARGS)
479     FILE( WRITE "${PROJECT_BINARY_DIR}/findwxw-args.log" "WXWIDGETS ARGS\n" )
480     FOREACH(WXARG ${WX_CONFIGARGS})
481       FILE( APPEND "${PROJECT_BINARY_DIR}/findwxw-args.log" "WXARG: ${WXARG}\n" )
482       IF(WXARG MATCHES "^-L")
483         SET(WXWIDGETS_LINK_DIRECTORIES ${WXWIDGETS_LINK_DIRECTORIES} ${WXARG})
484       ELSE(WXARG MATCHES "^-L")
485         IF(WXARG MATCHES "^-l")
486           SET(WXWIDGETS_LIBRARIES "${WXWIDGETS_LIBRARIES} ${WXARG}")
487         ELSE(WXARG MATCHES "^-l")
488           IF(WXARG MATCHES "^-")
489             SET(WXWIDGETS_EXE_LINKER_FLAGS "${WXWIDGETS_EXE_LINKER_FLAGS} ${WXARG}")
490           ELSE(WXARG MATCHES "^-")
491             SET(WXWIDGETS_LIBRARIES "${WXWIDGETS_LIBRARIES} ${WXARG}")
492           ENDIF(WXARG MATCHES "^-")
493         ENDIF(WXARG MATCHES "^-l")
494       ENDIF(WXARG MATCHES "^-L")
495     ENDFOREACH(WXARG ${WX_CONFIGARGS})
496
497     #Separate library names with ;
498     SEPARATE_ARGUMENTS(WXWIDGETS_LIBRARIES)
499
500     # remove prefix -L because we need the pure directory for LINK_DIRECTORIES
501     # replace -L by ; because the separator seems to be lost otherwise (bug or
502     # feature?)
503     SET(WX_LINK_DIRECTORIES_WITH_PREFIX ${WXWIDGETS_LINK_DIRECTORIES})
504     IF(WX_LINK_DIRECTORIES_WITH_PREFIX)
505       STRING(REGEX REPLACE "[-][L]" ";" WXWIDGETS_LINK_DIRECTORIES ${WX_LINK_DIRECTORIES_WITH_PREFIX} )
506       #MESSAGE("DBG  WXWIDGETS_LINK_DIRECTORIES=${WXWIDGETS_LINK_DIRECTORIES}")
507     ENDIF(WX_LINK_DIRECTORIES_WITH_PREFIX)
508     # replace space separated string by semicolon separated vector to make it
509     # work with LINK_DIRECTORIES
510     SEPARATE_ARGUMENTS(WXWIDGETS_LINK_DIRECTORIES)
511
512
513     #
514     # Unix puts all the libs in the WXWIDGETS_LIBRARIES var
515     # We don't know debug/release libs under unix, so we set the
516     # common var to full set as well and leave debug/release sets blank
517     #
518     SET( WXWIDGETS_RELEASE_LIBRARIES "" )
519     SET( WXWIDGETS_DEBUG_LIBRARIES "" )
520     SET(WXWIDGETS_COMMON_LIBRARIES ${WXWIDGETS_LIBRARIES})
521
522 ENDIF( WIN32_STYLE_FIND )
523
524
525 #
526 # Find wx.rc
527 #
528 SET( WXWIDGETS_RC ${WXWIDGETS_ROOT_DIR}/include/wx/msw/wx.rc )
529 IF( NOT WIN32_STYLE_FIND )
530     IF( NOT CYGWIN OR MINGW )
531         SET( WXWIDGETS_RC "" )
532     ENDIF( NOT CYGWIN OR MINGW )
533 ENDIF( NOT WIN32_STYLE_FIND )
534
535 #
536 # Set preprocessor defs
537 #
538 STRING(TOUPPER ${CMAKE_SYSTEM_NAME} WX_SYSNAME)
539 SET( WXWIDGETS_DEFINITIONS ${WXWIDGETS_DEFINITIONS} "-D${WX_SYSNAME}" )
540
541 IF(WIN32_STYLE_FIND)
542     SET( WXWIDGETS_DEFINITIONS ${WXWIDGETS_DEFINITIONS} -DWIN32 -D__WXMSW__  )
543 ELSE(WIN32_STYLE_FIND)
544     IF( CYGWIN )
545         SET( WXWIDGETS_DEFINITIONS ${WXWIDGETS_DEFINITIONS} -D__GNUWIN32__  -O2 -D_WIN32_IE=0x400 -MMD -Wall  )
546     ENDIF( CYGWIN )
547 ENDIF(WIN32_STYLE_FIND)
548
549 IF( WXWIDGETS_USE_SHARED )
550     SET( WXWIDGETS_DEFINITIONS ${WXWIDGETS_DEFINITIONS} -DWXUSINGDLL  )
551 ENDIF( WXWIDGETS_USE_SHARED )
552
553 IF( WXWIDGETS_USE_DEBUG )
554     SET( WXWIDGETS_DEFINITIONS ${WXWIDGETS_DEFINITIONS} -D_DEBUG_  -D__WXDEBUG__  -DWXDEBUG=1 )
555 ENDIF( WXWIDGETS_USE_DEBUG )
556
557 IF ( WXWIDGETS_USE_UNICODE )
558     SET( WXWIDGETS_DEFINITIONS ${WXWIDGETS_DEFINITIONS} -DwxUSE_UNICODE  )
559 ENDIF ( WXWIDGETS_USE_UNICODE )
560
561 #
562 # Set the WXWIDGETS_FOUND var
563 #
564 IF(WXWIDGETS_LIBRARIES AND WXWIDGETS_INCLUDE_DIR)
565     SET(WXWIDGETS_FOUND 1)
566 ENDIF(WXWIDGETS_LIBRARIES AND WXWIDGETS_INCLUDE_DIR)
567
568 #
569 # Mark advanced vars
570 #
571 MARK_AS_ADVANCED(WXWIDGETS_ROOT_DIR)
572
573 #
574 # Log results
575 #
576 FILE( WRITE "${PROJECT_BINARY_DIR}/findwxw.log" "FindwxW.cmake version 1.06\n" )
577 FILE( APPEND "${PROJECT_BINARY_DIR}/findwxw.log" "WXWIDGETS_FOUND: ${WXWIDGETS_FOUND}\n" )
578 FILE( APPEND "${PROJECT_BINARY_DIR}/findwxw.log" "WXWIDGETS_LINK_DIRECTORIES: ${WXWIDGETS_LINK_DIRECTORIES}\n" )
579 FILE( APPEND "${PROJECT_BINARY_DIR}/findwxw.log" "WXWIDGETS_LIBRARIES: ${WXWIDGETS_LIBRARIES}\n" )
580 FILE( APPEND "${PROJECT_BINARY_DIR}/findwxw.log" "WXWIDGETS_RELEASE_LIBRARIES: ${WXWIDGETS_RELEASE_LIBRARIES}\n" )
581 FILE( APPEND "${PROJECT_BINARY_DIR}/findwxw.log" "WXWIDGETS_DEBUG_LIBRARIES: ${WXWIDGETS_DEBUG_LIBRARIES}\n" )
582 FILE( APPEND "${PROJECT_BINARY_DIR}/findwxw.log" "WXWIDGETS_CXX_FLAGS: ${WXWIDGETS_CXX_FLAGS}\n" )
583 FILE( APPEND "${PROJECT_BINARY_DIR}/findwxw.log" "WXWIDGETS_EXE_LINKER_FLAGS: ${WXWIDGETS_EXE_LINKER_FLAGS}\n" )
584 FILE( APPEND "${PROJECT_BINARY_DIR}/findwxw.log" "WXWIDGETS_INCLUDE_DIR: ${WXWIDGETS_INCLUDE_DIR}\n" )
585 FILE( APPEND "${PROJECT_BINARY_DIR}/findwxw.log" "WXWIDGETS_DEFINITIONS: ${WXWIDGETS_DEFINITIONS}\n" )