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