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