Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Modules / FindwxWidgets.cmake
blob5c3bfabf9e1b3af73ccf7fe78e0e6cf3958212f0
1 # - Find a wxWidgets (a.k.a., wxWindows) installation.
2 # This module finds if wxWidgets is installed and selects a default
3 # configuration to use. wxWidgets is a modular library. To specify the
4 # modules that you will use, you need to name them as components to
5 # the package:
6
7 # FIND_PACKAGE(wxWidgets COMPONENTS base core ...)
8
9 # There are two search branches: a windows style and a unix style. For
10 # windows, the following variables are searched for and set to
11 # defaults in case of multiple choices. Change them if the defaults
12 # are not desired (i.e., these are the only variables you should
13 # change to select a configuration):
15 #  wxWidgets_ROOT_DIR      - Base wxWidgets directory
16 #                            (e.g., C:/wxWidgets-2.6.3).
17 #  wxWidgets_LIB_DIR       - Path to wxWidgets libraries
18 #                            (e.g., C:/wxWidgets-2.6.3/lib/vc_lib).
19 #  wxWidgets_CONFIGURATION - Configuration to use
20 #                            (e.g., msw, mswd, mswu, mswunivud, etc.)
21
22 # For unix style it uses the wx-config utility. You can select between
23 # debug/release, unicode/ansi, universal/non-universal, and
24 # static/shared in the QtDialog or ccmake interfaces by turning ON/OFF
25 # the following variables:
27 #  wxWidgets_USE_DEBUG
28 #  wxWidgets_USE_UNICODE
29 #  wxWidgets_USE_UNIVERSAL
30 #  wxWidgets_USE_STATIC
31 #  
32 # The following are set after the configuration is done for both
33 # windows and unix style:
35 #  wxWidgets_FOUND            - Set to TRUE if wxWidgets was found.
36 #  wxWidgets_INCLUDE_DIRS     - Include directories for WIN32
37 #                               i.e., where to find "wx/wx.h" and
38 #                               "wx/setup.h"; possibly empty for unices.
39 #  wxWidgets_LIBRARIES        - Path to the wxWidgets libraries.
40 #  wxWidgets_LIBRARY_DIRS     - compile time link dirs, useful for
41 #                               rpath on UNIX. Typically an empty string
42 #                               in WIN32 environment.
43 #  wxWidgets_DEFINITIONS      - Contains defines required to compile/link
44 #                               against WX, e.g. WXUSINGDLL
45 #  wxWidgets_DEFINITIONS_DEBUG- Contains defines required to compile/link
46 #                               against WX debug builds, e.g. __WXDEBUG__
47 #  wxWidgets_CXX_FLAGS        - Include dirs and ompiler flags for
48 #                               unices, empty on WIN32. Esentially
49 #                               "`wx-config --cxxflags`".
50 #  wxWidgets_USE_FILE         - Convenience include file.
52 # Sample usage:
53 #   FIND_PACKAGE(wxWidgets COMPONENTS base core gl net)
54 #   IF(wxWidgets_FOUND)
55 #     INCLUDE(${wxWidgets_USE_FILE})
56 #     # and for each of your dependant executable/library targets:
57 #     TARGET_LINK_LIBRARIES(<YourTarget> ${wxWidgets_LIBRARIES})
58 #   ENDIF(wxWidgets_FOUND)
60 # If wxWidgets is required (i.e., not an optional part):
61 #   FIND_PACKAGE(wxWidgets REQUIRED base core gl net)
62 #   INCLUDE(${wxWidgets_USE_FILE})
63 #   # and for each of your dependant executable/library targets:
64 #   TARGET_LINK_LIBRARIES(<YourTarget> ${wxWidgets_LIBRARIES})
67 # FIXME: check this and provide a correct sample usage...
68 #        Remember to connect back to the upper text.
69 # Sample usage with monolithic wx build:
71 #   FIND_PACKAGE(wxWidgets COMPONENTS mono)
72 #   ...
75 # NOTES
77 # This module has been tested on the WIN32 platform with wxWidgets
78 # 2.6.2, 2.6.3, and 2.5.3. However, it has been designed to
79 # easily extend support to all possible builds, e.g., static/shared,
80 # debug/release, unicode, universal, multilib/monolithic, etc..
82 # If you want to use the module and your build type is not supported
83 # out-of-the-box, please contact me to exchange information on how
84 # your system is setup and I'll try to add support for it.
86 # AUTHOR
88 # Miguel A. Figueroa-Villanueva (miguelf at ieee dot org).
89 # Jan Woetzel (jw at mip.informatik.uni-kiel.de).
91 # Based on previous works of:
92 # Jan Woetzel (FindwxWindows.cmake),
93 # Jorgen Bodde and Jerry Fath (FindwxWin.cmake).
95 # TODO/ideas
97 # (1) Option/Setting to use all available wx libs
98 # In contrast to expert developer who lists the
99 # minimal set of required libs in wxWidgets_USE_LIBS
100 # there is the newbie user:
101 #   - who just wants to link against WX with more 'magic'
102 #   - doesn't know the internal structure of WX or how it was built,
103 #     in particular if it is monolithic or not
104 #   - want to link against all available WX libs
105 # Basically, the intent here is to mimic what wx-config would do by
106 # default (i.e., `wx-config --libs`).
108 # Possible solution:
109 #   Add a reserved keyword "std" that initializes to what wx-config
110 # would default to. If the user has not set the wxWidgets_USE_LIBS,
111 # default to "std" instead of "base core" as it is now. To implement
112 # "std" will basically boil down to a FOR_EACH lib-FOUND, but maybe
113 # checking whether a minimal set was found.
116 # FIXME: This and all the DBG_MSG calls should be removed after the
117 # module stabilizes.
119 # Helper macro to control the debugging output globally. There are
120 # two versions for controlling how verbose your output should be.
121 MACRO(DBG_MSG _MSG)
122 #  MESSAGE(STATUS
123 #    "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): ${_MSG}")
124 ENDMACRO(DBG_MSG)
125 MACRO(DBG_MSG_V _MSG)
126 #  MESSAGE(STATUS
127 #    "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): ${_MSG}")
128 ENDMACRO(DBG_MSG_V)
130 # Clear return values in case the module is loaded more than once.
131 SET(wxWidgets_FOUND FALSE)
132 SET(wxWidgets_INCLUDE_DIRS "")
133 SET(wxWidgets_LIBRARIES    "")
134 SET(wxWidgets_LIBRARY_DIRS "")
135 SET(wxWidgets_CXX_FLAGS    "")
137 # Using SYSTEM with INCLUDE_DIRECTORIES in conjunction with wxWidgets on
138 # the Mac produces compiler errors. Set wxWidgets_INCLUDE_DIRS_NO_SYSTEM
139 # to prevent UsewxWidgets.cmake from using SYSTEM.
141 # See cmake mailing list discussions for more info:
142 #   http://www.cmake.org/pipermail/cmake/2008-April/021115.html
143 #   http://www.cmake.org/pipermail/cmake/2008-April/021146.html
145 IF(APPLE)
146   SET(wxWidgets_INCLUDE_DIRS_NO_SYSTEM 1)
147 ENDIF(APPLE)
149 # DEPRECATED: This is a patch to support the DEPRECATED use of
150 # wxWidgets_USE_LIBS.
152 # If wxWidgets_USE_LIBS is set:
153 # - if using <components>, then override wxWidgets_USE_LIBS
154 # - else set wxWidgets_FIND_COMPONENTS to wxWidgets_USE_LIBS
155 IF(wxWidgets_USE_LIBS AND NOT wxWidgets_FIND_COMPONENTS)
156   SET(wxWidgets_FIND_COMPONENTS ${wxWidgets_USE_LIBS})
157 ENDIF(wxWidgets_USE_LIBS AND NOT wxWidgets_FIND_COMPONENTS)
158 DBG_MSG("wxWidgets_FIND_COMPONENTS : ${wxWidgets_FIND_COMPONENTS}")
160 # Add the convenience use file if available.
162 # Get dir of this file which may reside in:
163 # - CMAKE_MAKE_ROOT/Modules on CMake installation
164 # - CMAKE_MODULE_PATH if user prefers his own specialized version
165 SET(wxWidgets_USE_FILE "")
166 GET_FILENAME_COMPONENT(
167   wxWidgets_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
168 # Prefer an existing customized version, but the user might override
169 # the FindwxWidgets module and not the UsewxWidgets one.
170 IF(EXISTS "${wxWidgets_CURRENT_LIST_DIR}/UsewxWidgets.cmake")
171   SET(wxWidgets_USE_FILE
172     "${wxWidgets_CURRENT_LIST_DIR}/UsewxWidgets.cmake")
173 ELSE(EXISTS "${wxWidgets_CURRENT_LIST_DIR}/UsewxWidgets.cmake")
174   SET(wxWidgets_USE_FILE UsewxWidgets.cmake)
175 ENDIF(EXISTS "${wxWidgets_CURRENT_LIST_DIR}/UsewxWidgets.cmake")
177 #=====================================================================
178 #=====================================================================
179 IF(WIN32 AND NOT CYGWIN AND NOT MSYS)
180   SET(wxWidgets_FIND_STYLE "win32")
181 ELSE(WIN32 AND NOT CYGWIN AND NOT MSYS)
182   IF(UNIX OR MSYS)
183     SET(wxWidgets_FIND_STYLE "unix")
184   ENDIF(UNIX OR MSYS)
185 ENDIF(WIN32 AND NOT CYGWIN AND NOT MSYS)
187 #=====================================================================
188 # WIN32_FIND_STYLE
189 #=====================================================================
190 IF(wxWidgets_FIND_STYLE STREQUAL "win32")
191   # Useful common wx libs needed by almost all components.
192   SET(wxWidgets_COMMON_LIBRARIES png tiff jpeg zlib regex expat)
194   # DEPRECATED: Use FIND_PACKAGE(wxWidgets COMPONENTS mono) instead.
195   IF(NOT wxWidgets_FIND_COMPONENTS)
196     IF(wxWidgets_USE_MONOLITHIC)
197       SET(wxWidgets_FIND_COMPONENTS mono)
198     ELSE(wxWidgets_USE_MONOLITHIC)
199       SET(wxWidgets_FIND_COMPONENTS base core) # this is default
200     ENDIF(wxWidgets_USE_MONOLITHIC)
201   ENDIF(NOT wxWidgets_FIND_COMPONENTS)
203   # Always add the common required libs.
204   LIST(APPEND wxWidgets_FIND_COMPONENTS ${wxWidgets_COMMON_LIBRARIES})
206   #-------------------------------------------------------------------
207   # WIN32: Helper MACROS
208   #-------------------------------------------------------------------
209   #
210   # Get filename components for a configuration. For example,
211   #   if _CONFIGURATION = mswunivud, then _UNV=univ, _UCD=u _DBG=d
212   #   if _CONFIGURATION = mswu,      then _UNV="",   _UCD=u _DBG=""
213   #
214   MACRO(WX_GET_NAME_COMPONENTS _CONFIGURATION _UNV _UCD _DBG)
215     STRING(REGEX MATCH "univ" ${_UNV} "${_CONFIGURATION}")
216     STRING(REGEX REPLACE "msw.*(u)[d]*$" "u" ${_UCD} "${_CONFIGURATION}")
217     IF(${_UCD} STREQUAL ${_CONFIGURATION})
218       SET(${_UCD} "")
219     ENDIF(${_UCD} STREQUAL ${_CONFIGURATION})
220     STRING(REGEX MATCH "d$" ${_DBG} "${_CONFIGURATION}")
221   ENDMACRO(WX_GET_NAME_COMPONENTS)
223   #
224   # Find libraries associated to a configuration.
225   #
226   MACRO(WX_FIND_LIBS _UNV _UCD _DBG)
227     DBG_MSG_V("m_unv = ${_UNV}")
228     DBG_MSG_V("m_ucd = ${_UCD}")
229     DBG_MSG_V("m_dbg = ${_DBG}")
231     # FIXME: What if both regex libs are available. regex should be
232     # found outside the loop and only wx${LIB}${_UCD}${_DBG}.
233     # Find wxWidgets common libraries.
234     FOREACH(LIB ${wxWidgets_COMMON_LIBRARIES})
235       FIND_LIBRARY(WX_${LIB}${_DBG}
236         NAMES
237         wx${LIB}${_UCD}${_DBG} # for regex
238         wx${LIB}${_DBG}
239         PATHS ${WX_LIB_DIR}
240         NO_DEFAULT_PATH
241         )
242       MARK_AS_ADVANCED(WX_${LIB}${_DBG})
243     ENDFOREACH(LIB)
245     # Find wxWidgets multilib base libraries.
246     FIND_LIBRARY(WX_base${_DBG}
247       NAMES
248       wxbase29${_UCD}${_DBG}
249       wxbase28${_UCD}${_DBG}
250       wxbase27${_UCD}${_DBG}
251       wxbase26${_UCD}${_DBG}
252       wxbase25${_UCD}${_DBG}
253       PATHS ${WX_LIB_DIR}
254       NO_DEFAULT_PATH
255       )
256     MARK_AS_ADVANCED(WX_base${_DBG})
257     FOREACH(LIB net odbc xml)
258       FIND_LIBRARY(WX_${LIB}${_DBG}
259         NAMES
260         wxbase29${_UCD}${_DBG}_${LIB}
261         wxbase28${_UCD}${_DBG}_${LIB}
262         wxbase27${_UCD}${_DBG}_${LIB}
263         wxbase26${_UCD}${_DBG}_${LIB}
264         wxbase25${_UCD}${_DBG}_${LIB}
265         PATHS ${WX_LIB_DIR}
266         NO_DEFAULT_PATH
267         )
268       MARK_AS_ADVANCED(WX_${LIB}${_DBG})
269     ENDFOREACH(LIB)
271     # Find wxWidgets monolithic library.
272     FIND_LIBRARY(WX_mono${_DBG}
273       NAMES
274       wxmsw${_UNV}29${_UCD}${_DBG}
275       wxmsw${_UNV}28${_UCD}${_DBG}
276       wxmsw${_UNV}27${_UCD}${_DBG}
277       wxmsw${_UNV}26${_UCD}${_DBG}
278       wxmsw${_UNV}25${_UCD}${_DBG}
279       PATHS ${WX_LIB_DIR}
280       NO_DEFAULT_PATH
281       )
282     MARK_AS_ADVANCED(WX_mono${_DBG})
284     # Find wxWidgets multilib libraries.
285     FOREACH(LIB core adv aui html media xrc dbgrid gl qa richtext)
286       FIND_LIBRARY(WX_${LIB}${_DBG}
287         NAMES
288         wxmsw${_UNV}29${_UCD}${_DBG}_${LIB}
289         wxmsw${_UNV}28${_UCD}${_DBG}_${LIB}
290         wxmsw${_UNV}27${_UCD}${_DBG}_${LIB}
291         wxmsw${_UNV}26${_UCD}${_DBG}_${LIB}
292         wxmsw${_UNV}25${_UCD}${_DBG}_${LIB}
293         PATHS ${WX_LIB_DIR}
294         NO_DEFAULT_PATH
295         )
296       MARK_AS_ADVANCED(WX_${LIB}${_DBG})
297     ENDFOREACH(LIB)
298   ENDMACRO(WX_FIND_LIBS)
300   #
301   # Clear all library paths, so that FIND_LIBRARY refinds them.
302   #
303   # Clear a lib, reset its found flag, and mark as advanced.
304   MACRO(WX_CLEAR_LIB _LIB)
305     SET(${_LIB} "${_LIB}-NOTFOUND" CACHE FILEPATH "Cleared." FORCE)
306     SET(${_LIB}_FOUND FALSE)
307     MARK_AS_ADVANCED(${_LIB})
308   ENDMACRO(WX_CLEAR_LIB)
309   # Clear all debug or release library paths (arguments are "d" or "").
310   MACRO(WX_CLEAR_ALL_LIBS _DBG)
311     # Clear wxWidgets common libraries.
312     FOREACH(LIB ${wxWidgets_COMMON_LIBRARIES})
313       WX_CLEAR_LIB(WX_${LIB}${_DBG})
314     ENDFOREACH(LIB)
316     # Clear wxWidgets multilib base libraries.
317     WX_CLEAR_LIB(WX_base${_DBG})
318     FOREACH(LIB net odbc xml)
319       WX_CLEAR_LIB(WX_${LIB}${_DBG})
320     ENDFOREACH(LIB)
322     # Clear wxWidgets monolithic library.
323     WX_CLEAR_LIB(WX_mono${_DBG})
325     # Clear wxWidgets multilib libraries.
326     FOREACH(LIB core adv aui html media xrc dbgrid gl qa richtext)
327       WX_CLEAR_LIB(WX_${LIB}${_DBG})
328     ENDFOREACH(LIB)
329   ENDMACRO(WX_CLEAR_ALL_LIBS)
330   # Clear all wxWidgets debug libraries.
331   MACRO(WX_CLEAR_ALL_DBG_LIBS)
332     WX_CLEAR_ALL_LIBS("d")
333   ENDMACRO(WX_CLEAR_ALL_DBG_LIBS)
334   # Clear all wxWidgets release libraries.
335   MACRO(WX_CLEAR_ALL_REL_LIBS)
336     WX_CLEAR_ALL_LIBS("")
337   ENDMACRO(WX_CLEAR_ALL_REL_LIBS)
339   #
340   # Set the wxWidgets_LIBRARIES variable.
341   # Also, Sets output variable wxWidgets_FOUND to FALSE if it fails.
342   #
343   MACRO(WX_SET_LIBRARIES _LIBS _DBG)
344     DBG_MSG_V("Looking for ${${_LIBS}}")
345     IF(WX_USE_REL_AND_DBG)
346       FOREACH(LIB ${${_LIBS}})
347         DBG_MSG_V("Searching for ${LIB} and ${LIB}d")
348         DBG_MSG_V("WX_${LIB}  : ${WX_${LIB}}")
349         DBG_MSG_V("WX_${LIB}d : ${WX_${LIB}d}")
350         IF(WX_${LIB} AND WX_${LIB}d)
351           DBG_MSG_V("Found ${LIB} and ${LIB}d")
352           LIST(APPEND wxWidgets_LIBRARIES
353             debug ${WX_${LIB}d} optimized ${WX_${LIB}}
354             )
355         ELSE(WX_${LIB} AND WX_${LIB}d)
356           DBG_MSG_V("- not found due to missing WX_${LIB}=${WX_${LIB}} or WX_${LIB}d=${WX_${LIB}d}")
357           SET(wxWidgets_FOUND FALSE)
358         ENDIF(WX_${LIB} AND WX_${LIB}d)
359       ENDFOREACH(LIB)
360     ELSE(WX_USE_REL_AND_DBG)
361       FOREACH(LIB ${${_LIBS}})
362         DBG_MSG_V("Searching for ${LIB}${_DBG}")
363         DBG_MSG_V("WX_${LIB}${_DBG} : ${WX_${LIB}${_DBG}}")
364         IF(WX_${LIB}${_DBG})
365           DBG_MSG_V("Found ${LIB}${_DBG}")
366           LIST(APPEND wxWidgets_LIBRARIES ${WX_${LIB}${_DBG}})
367         ELSE(WX_${LIB}${_DBG})
368           DBG_MSG_V(
369             "- not found due to missing WX_${LIB}${_DBG}=${WX_${LIB}${_DBG}}")
370           SET(wxWidgets_FOUND FALSE)
371         ENDIF(WX_${LIB}${_DBG})
372       ENDFOREACH(LIB)
373     ENDIF(WX_USE_REL_AND_DBG)
375     DBG_MSG_V("OpenGL")
376     LIST(FIND ${_LIBS} gl WX_USE_GL)
377     IF(NOT WX_USE_GL EQUAL -1)
378       DBG_MSG_V("- is required.")
379       LIST(APPEND wxWidgets_LIBRARIES opengl32 glu32)
380     ENDIF(NOT WX_USE_GL EQUAL -1)
382     LIST(APPEND wxWidgets_LIBRARIES winmm comctl32 rpcrt4 wsock32)
383   ENDMACRO(WX_SET_LIBRARIES)
385   #-------------------------------------------------------------------
386   # WIN32: Start actual work.
387   #-------------------------------------------------------------------
389   # Look for an installation tree.
390   FIND_PATH(wxWidgets_ROOT_DIR 
391     NAMES include/wx/wx.h
392     PATHS
393       $ENV{wxWidgets_ROOT_DIR}
394       $ENV{WXWIN}
395       "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\wxWidgets_is1;Inno Setup: App Path]"  # WX 2.6.x
396       C:/
397       D:/
398       $ENV{ProgramFiles}
399     PATH_SUFFIXES 
400       wxWidgets-2.9.4
401       wxWidgets-2.9.3
402       wxWidgets-2.9.2
403       wxWidgets-2.9.1
404       wxWidgets-2.9.0
405       wxWidgets-2.8.9
406       wxWidgets-2.8.8
407       wxWidgets-2.8.7
408       wxWidgets-2.8.6
409       wxWidgets-2.8.5
410       wxWidgets-2.8.4
411       wxWidgets-2.8.3
412       wxWidgets-2.8.2
413       wxWidgets-2.8.1
414       wxWidgets-2.8.0
415       wxWidgets-2.7.4
416       wxWidgets-2.7.3
417       wxWidgets-2.7.2
418       wxWidgets-2.7.1
419       wxWidgets-2.7.0
420       wxWidgets-2.7.0-1
421       wxWidgets-2.6.4
422       wxWidgets-2.6.3
423       wxWidgets-2.6.2
424       wxWidgets-2.6.1
425       wxWidgets-2.5.4
426       wxWidgets-2.5.3
427       wxWidgets-2.5.2
428       wxWidgets-2.5.1
429       wxWidgets
430     DOC "wxWidgets base/installation directory?"
431     )
433   # If wxWidgets_ROOT_DIR changed, clear lib dir.
434   IF(NOT WX_ROOT_DIR STREQUAL wxWidgets_ROOT_DIR)
435     SET(WX_ROOT_DIR ${wxWidgets_ROOT_DIR}
436         CACHE INTERNAL "wxWidgets_ROOT_DIR")
437     SET(wxWidgets_LIB_DIR "wxWidgets_LIB_DIR-NOTFOUND"
438         CACHE PATH "Cleared." FORCE)
439   ENDIF(NOT WX_ROOT_DIR STREQUAL wxWidgets_ROOT_DIR)
441   IF(WX_ROOT_DIR)
442     # Select one default tree inside the already determined wx tree.
443     # Prefer static/shared order usually consistent with build
444     # settings.
445     IF(MINGW)
446       SET(WX_LIB_DIR_PREFIX gcc)
447     ELSE(MINGW)
448       SET(WX_LIB_DIR_PREFIX vc)
449     ENDIF(MINGW)
450     IF(BUILD_SHARED_LIBS)
451       FIND_PATH(wxWidgets_LIB_DIR
452         NAMES
453           msw/wx/setup.h
454           mswd/wx/setup.h
455           mswu/wx/setup.h
456           mswud/wx/setup.h
457           mswuniv/wx/setup.h
458           mswunivd/wx/setup.h
459           mswunivu/wx/setup.h
460           mswunivud/wx/setup.h
461         PATHS
462         ${WX_ROOT_DIR}/lib/${WX_LIB_DIR_PREFIX}_dll   # prefer shared
463         ${WX_ROOT_DIR}/lib/${WX_LIB_DIR_PREFIX}_lib
464         DOC "Path to wxWidgets libraries?"
465         NO_DEFAULT_PATH
466         )
467     ELSE(BUILD_SHARED_LIBS)
468       FIND_PATH(wxWidgets_LIB_DIR
469         NAMES
470           msw/wx/setup.h
471           mswd/wx/setup.h
472           mswu/wx/setup.h
473           mswud/wx/setup.h
474           mswuniv/wx/setup.h
475           mswunivd/wx/setup.h
476           mswunivu/wx/setup.h
477           mswunivud/wx/setup.h
478         PATHS
479         ${WX_ROOT_DIR}/lib/${WX_LIB_DIR_PREFIX}_lib   # prefer static
480         ${WX_ROOT_DIR}/lib/${WX_LIB_DIR_PREFIX}_dll
481         DOC "Path to wxWidgets libraries?"
482         NO_DEFAULT_PATH
483         )
484     ENDIF(BUILD_SHARED_LIBS)
486     # If wxWidgets_LIB_DIR changed, clear all libraries.
487     IF(NOT WX_LIB_DIR STREQUAL wxWidgets_LIB_DIR)
488       SET(WX_LIB_DIR ${wxWidgets_LIB_DIR} CACHE INTERNAL "wxWidgets_LIB_DIR")
489       WX_CLEAR_ALL_DBG_LIBS()
490       WX_CLEAR_ALL_REL_LIBS()
491     ENDIF(NOT WX_LIB_DIR STREQUAL wxWidgets_LIB_DIR)
493     IF(WX_LIB_DIR)
494       # If building shared libs, define WXUSINGDLL to use dllimport.
495       IF(WX_LIB_DIR MATCHES ".*[dD][lL][lL].*")
496         SET(wxWidgets_DEFINITIONS WXUSINGDLL)
497         DBG_MSG_V("detected SHARED/DLL tree WX_LIB_DIR=${WX_LIB_DIR}")
498       ENDIF(WX_LIB_DIR MATCHES ".*[dD][lL][lL].*")
500       # Search for available configuration types.
501       FOREACH(CFG mswunivud mswunivd mswud mswd mswunivu mswuniv mswu msw)
502         SET(WX_${CFG}_FOUND FALSE)
503         IF(EXISTS ${WX_LIB_DIR}/${CFG})
504           LIST(APPEND WX_CONFIGURATION_LIST ${CFG})
505           SET(WX_${CFG}_FOUND TRUE)
506           SET(WX_CONFIGURATION ${CFG})
507         ENDIF(EXISTS ${WX_LIB_DIR}/${CFG})
508       ENDFOREACH(CFG)
509       DBG_MSG_V("WX_CONFIGURATION_LIST=${WX_CONFIGURATION_LIST}")
511       IF(WX_CONFIGURATION)
512         SET(wxWidgets_FOUND TRUE)
514         # If the selected configuration wasn't found force the default
515         # one. Otherwise, use it but still force a refresh for
516         # updating the doc string with the current list of available
517         # configurations.
518         IF(NOT WX_${wxWidgets_CONFIGURATION}_FOUND)
519           SET(wxWidgets_CONFIGURATION ${WX_CONFIGURATION} CACHE STRING
520             "Set wxWidgets configuration (${WX_CONFIGURATION_LIST})" FORCE)
521         ELSE(NOT WX_${wxWidgets_CONFIGURATION}_FOUND)
522           SET(wxWidgets_CONFIGURATION ${wxWidgets_CONFIGURATION} CACHE STRING
523             "Set wxWidgets configuration (${WX_CONFIGURATION_LIST})" FORCE)
524         ENDIF(NOT WX_${wxWidgets_CONFIGURATION}_FOUND)
526         # If release config selected, and both release/debug exist.
527         IF(WX_${wxWidgets_CONFIGURATION}d_FOUND)
528           OPTION(wxWidgets_USE_REL_AND_DBG
529             "Use release and debug configurations?" TRUE)
530           SET(WX_USE_REL_AND_DBG ${wxWidgets_USE_REL_AND_DBG})
531         ELSE(WX_${wxWidgets_CONFIGURATION}d_FOUND)
532           # If the option exists (already in cache), force it false.
533           IF(wxWidgets_USE_REL_AND_DBG)
534             SET(wxWidgets_USE_REL_AND_DBG FALSE CACHE BOOL
535               "No ${wxWidgets_CONFIGURATION}d found." FORCE)
536           ENDIF(wxWidgets_USE_REL_AND_DBG)
537           SET(WX_USE_REL_AND_DBG FALSE)
538         ENDIF(WX_${wxWidgets_CONFIGURATION}d_FOUND)
540         # Get configuration parameters from the name.
541         WX_GET_NAME_COMPONENTS(${wxWidgets_CONFIGURATION} UNV UCD DBG)
543         # Set wxWidgets main include directory.
544         IF(EXISTS ${WX_ROOT_DIR}/include/wx/wx.h)
545           SET(wxWidgets_INCLUDE_DIRS ${WX_ROOT_DIR}/include)
546         ELSE(EXISTS ${WX_ROOT_DIR}/include/wx/wx.h)
547           DBG_MSG("wxWidgets_FOUND FALSE because WX_ROOT_DIR=${WX_ROOT_DIR} has no ${WX_ROOT_DIR}/include/wx/wx.h")
548           SET(wxWidgets_FOUND FALSE)
549         ENDIF(EXISTS ${WX_ROOT_DIR}/include/wx/wx.h)
551         # Set wxWidgets lib setup include directory.
552         IF(EXISTS ${WX_LIB_DIR}/${wxWidgets_CONFIGURATION}/wx/setup.h)
553           LIST(APPEND wxWidgets_INCLUDE_DIRS
554             ${WX_LIB_DIR}/${wxWidgets_CONFIGURATION})
555         ELSE(EXISTS ${WX_LIB_DIR}/${wxWidgets_CONFIGURATION}/wx/setup.h)
556           DBG_MSG("WXWIDGET_FOUND FALSE because ${WX_LIB_DIR}/${wxWidgets_CONFIGURATION}/wx/setup.h does not exists.")
557           SET(wxWidgets_FOUND FALSE)
558         ENDIF(EXISTS ${WX_LIB_DIR}/${wxWidgets_CONFIGURATION}/wx/setup.h)
560         # Find wxWidgets libraries.
561         WX_FIND_LIBS("${UNV}" "${UCD}" "${DBG}")
562         IF(WX_USE_REL_AND_DBG)
563           WX_FIND_LIBS("${UNV}" "${UCD}" "d")
564         ENDIF(WX_USE_REL_AND_DBG)
566         # Settings for requested libs (i.e., include dir, libraries, etc.).
567         WX_SET_LIBRARIES(wxWidgets_FIND_COMPONENTS "${DBG}")
569         # Add necessary definitions for unicode builds
570         IF("${UCD}" STREQUAL "u")
571           LIST(APPEND wxWidgets_DEFINITIONS UNICODE _UNICODE)
572         ENDIF("${UCD}" STREQUAL "u")
574         # Add necessary definitions for debug builds
575         SET(wxWidgets_DEFINITIONS_DEBUG _DEBUG __WXDEBUG__)
577       ENDIF(WX_CONFIGURATION)
578     ENDIF(WX_LIB_DIR)
579   ENDIF(WX_ROOT_DIR)
581 #=====================================================================
582 # UNIX_FIND_STYLE
583 #=====================================================================
584 ELSE(wxWidgets_FIND_STYLE STREQUAL "win32")
585   IF(wxWidgets_FIND_STYLE STREQUAL "unix")
586     #-----------------------------------------------------------------
587     # UNIX: Helper MACROS
588     #-----------------------------------------------------------------
589     #
590     # Set the default values based on "wx-config --selected-config".
591     #
592     MACRO(WX_CONFIG_SELECT_GET_DEFAULT)
593       EXECUTE_PROCESS(
594         COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}" --selected-config
595         OUTPUT_VARIABLE _wx_selected_config
596         RESULT_VARIABLE _wx_result
597         ERROR_QUIET
598         )
599       IF(_wx_result EQUAL 0)
600         FOREACH(_opt_name debug static unicode universal)
601           STRING(TOUPPER ${_opt_name} _upper_opt_name)
602           IF(_wx_selected_config MATCHES ".*${_opt_name}.*")
603             SET(wxWidgets_DEFAULT_${_upper_opt_name} ON)
604           ELSE(_wx_selected_config MATCHES ".*${_opt_name}.*")
605             SET(wxWidgets_DEFAULT_${_upper_opt_name} OFF)
606           ENDIF(_wx_selected_config MATCHES ".*${_opt_name}.*")
607         ENDFOREACH(_opt_name)
608       ELSE(_wx_result EQUAL 0)
609         FOREACH(_upper_opt_name DEBUG STATIC UNICODE UNIVERSAL)
610           SET(wxWidgets_DEFAULT_${_upper_opt_name} OFF)
611         ENDFOREACH(_upper_opt_name)
612       ENDIF(_wx_result EQUAL 0)
613     ENDMACRO(WX_CONFIG_SELECT_GET_DEFAULT)
615     #
616     # Query a boolean configuration option to determine if the system
617     # has both builds available. If so, provide the selection option
618     # to the user.
619     #
620     MACRO(WX_CONFIG_SELECT_QUERY_BOOL _OPT_NAME _OPT_HELP)
621       EXECUTE_PROCESS(
622         COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}" --${_OPT_NAME}=yes
623         RESULT_VARIABLE _wx_result_yes
624         OUTPUT_QUIET
625         ERROR_QUIET
626         )
627       EXECUTE_PROCESS(
628         COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}" --${_OPT_NAME}=no
629         RESULT_VARIABLE _wx_result_no
630         OUTPUT_QUIET
631         ERROR_QUIET
632         )
633       STRING(TOUPPER ${_OPT_NAME} _UPPER_OPT_NAME)
634       IF(_wx_result_yes EQUAL 0 AND _wx_result_no EQUAL 0)
635         OPTION(wxWidgets_USE_${_UPPER_OPT_NAME}
636           ${_OPT_HELP} ${wxWidgets_DEFAULT_${_UPPER_OPT_NAME}})
637       ELSE(_wx_result_yes EQUAL 0 AND _wx_result_no EQUAL 0)
638         # If option exists (already in cache), force to available one.
639         IF(DEFINED wxWidgets_USE_${_UPPER_OPT_NAME})
640           IF(_wx_result_yes EQUAL 0)
641             SET(wxWidgets_USE_${_UPPER_OPT_NAME} ON  CACHE BOOL ${_OPT_HELP} FORCE)
642           ELSE(_wx_result_yes EQUAL 0)
643             SET(wxWidgets_USE_${_UPPER_OPT_NAME} OFF CACHE BOOL ${_OPT_HELP} FORCE)
644           ENDIF(_wx_result_yes EQUAL 0)
645         ENDIF(DEFINED wxWidgets_USE_${_UPPER_OPT_NAME})
646       ENDIF(_wx_result_yes EQUAL 0 AND _wx_result_no EQUAL 0)
647     ENDMACRO(WX_CONFIG_SELECT_QUERY_BOOL)
649     # 
650     # Set wxWidgets_SELECT_OPTIONS to wx-config options for selecting
651     # among multiple builds.
652     #
653     MACRO(WX_CONFIG_SELECT_SET_OPTIONS)
654       SET(wxWidgets_SELECT_OPTIONS "")
655       FOREACH(_opt_name debug static unicode universal)
656         STRING(TOUPPER ${_opt_name} _upper_opt_name)
657         IF(DEFINED wxWidgets_USE_${_upper_opt_name})
658           IF(wxWidgets_USE_${_upper_opt_name})
659             LIST(APPEND wxWidgets_SELECT_OPTIONS --${_opt_name}=yes)
660           ELSE(wxWidgets_USE_${_upper_opt_name})
661             LIST(APPEND wxWidgets_SELECT_OPTIONS --${_opt_name}=no)
662           ENDIF(wxWidgets_USE_${_upper_opt_name})
663         ENDIF(DEFINED wxWidgets_USE_${_upper_opt_name})
664       ENDFOREACH(_opt_name)
665     ENDMACRO(WX_CONFIG_SELECT_SET_OPTIONS)
667     #-----------------------------------------------------------------
668     # UNIX: Start actual work.
669     #-----------------------------------------------------------------
670     # Support cross-compiling, only search in the target platform.
671     FIND_PROGRAM(wxWidgets_CONFIG_EXECUTABLE wx-config
672       ONLY_CMAKE_FIND_ROOT_PATH
673       )
675     IF(wxWidgets_CONFIG_EXECUTABLE)
676       SET(wxWidgets_FOUND TRUE)
678       # get defaults based on "wx-config --selected-config"
679       WX_CONFIG_SELECT_GET_DEFAULT()
681       # for each option: if both builds are available, provide option
682       WX_CONFIG_SELECT_QUERY_BOOL(debug "Use debug build?")
683       WX_CONFIG_SELECT_QUERY_BOOL(unicode "Use unicode build?")
684       WX_CONFIG_SELECT_QUERY_BOOL(universal "Use universal build?")
685       WX_CONFIG_SELECT_QUERY_BOOL(static "Link libraries statically?")
687       # process selection to set wxWidgets_SELECT_OPTIONS
688       WX_CONFIG_SELECT_SET_OPTIONS()
689       DBG_MSG("wxWidgets_SELECT_OPTIONS=${wxWidgets_SELECT_OPTIONS}")
691       # run the wx-config program to get cxxflags
692       EXECUTE_PROCESS(
693         COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}"
694           ${wxWidgets_SELECT_OPTIONS} --cxxflags
695         OUTPUT_VARIABLE wxWidgets_CXX_FLAGS
696         RESULT_VARIABLE RET
697         ERROR_QUIET
698         )
699       IF(RET EQUAL 0)
700         STRING(STRIP "${wxWidgets_CXX_FLAGS}" wxWidgets_CXX_FLAGS)
701         SEPARATE_ARGUMENTS(wxWidgets_CXX_FLAGS)
703         DBG_MSG_V("wxWidgets_CXX_FLAGS=${wxWidgets_CXX_FLAGS}")
705         # parse definitions from cxxflags; drop -D* from CXXFLAGS and the -D prefix
706         STRING(REGEX MATCHALL "-D[^;]+"
707           wxWidgets_DEFINITIONS  "${wxWidgets_CXX_FLAGS}")
708         STRING(REGEX REPLACE "-D[^;]+;" ""
709           wxWidgets_CXX_FLAGS "${wxWidgets_CXX_FLAGS}")
710         STRING(REPLACE "-D" ""
711           wxWidgets_DEFINITIONS "${wxWidgets_DEFINITIONS}")
713         # parse include dirs from cxxflags; drop -I prefix
714         STRING(REGEX MATCHALL "-I[^;]+"
715           wxWidgets_INCLUDE_DIRS "${wxWidgets_CXX_FLAGS}")
716         STRING(REGEX REPLACE "-I[^;]+;" ""
717           wxWidgets_CXX_FLAGS "${wxWidgets_CXX_FLAGS}")
718         STRING(REPLACE "-I" ""
719           wxWidgets_INCLUDE_DIRS "${wxWidgets_INCLUDE_DIRS}")
721         DBG_MSG_V("wxWidgets_DEFINITIONS=${wxWidgets_DEFINITIONS}")
722         DBG_MSG_V("wxWidgets_INCLUDE_DIRS=${wxWidgets_INCLUDE_DIRS}")
723         DBG_MSG_V("wxWidgets_CXX_FLAGS=${wxWidgets_CXX_FLAGS}")
725       ELSE(RET EQUAL 0)
726         SET(wxWidgets_FOUND FALSE)
727         DBG_MSG_V(
728           "${wxWidgets_CONFIG_EXECUTABLE} --cxxflags FAILED with RET=${RET}")
729       ENDIF(RET EQUAL 0)
731       # run the wx-config program to get the libs
732       # - NOTE: wx-config doesn't verify that the libs requested exist
733       #         it just produces the names. Maybe a TRY_COMPILE would
734       #         be useful here...
735       STRING(REPLACE ";" ","
736         wxWidgets_FIND_COMPONENTS "${wxWidgets_FIND_COMPONENTS}")
737       EXECUTE_PROCESS(
738         COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}"
739           ${wxWidgets_SELECT_OPTIONS} --libs ${wxWidgets_FIND_COMPONENTS}
740         OUTPUT_VARIABLE wxWidgets_LIBRARIES
741         RESULT_VARIABLE RET
742         ERROR_QUIET
743         )
744       IF(RET EQUAL 0)
745         STRING(STRIP "${wxWidgets_LIBRARIES}" wxWidgets_LIBRARIES)
746         SEPARATE_ARGUMENTS(wxWidgets_LIBRARIES)
747         STRING(REPLACE "-framework;" "-framework "
748           wxWidgets_LIBRARIES "${wxWidgets_LIBRARIES}")
749         STRING(REPLACE "-arch;" "-arch "
750           wxWidgets_LIBRARIES "${wxWidgets_LIBRARIES}")
751         STRING(REPLACE "-isysroot;" "-isysroot "
752           wxWidgets_LIBRARIES "${wxWidgets_LIBRARIES}")
754         # extract linkdirs (-L) for rpath (i.e., LINK_DIRECTORIES)
755         STRING(REGEX MATCHALL "-L[^;]+"
756           wxWidgets_LIBRARY_DIRS "${wxWidgets_LIBRARIES}")
757         STRING(REPLACE "-L" ""
758           wxWidgets_LIBRARY_DIRS "${wxWidgets_LIBRARY_DIRS}")
760         DBG_MSG_V("wxWidgets_LIBRARIES=${wxWidgets_LIBRARIES}")
761         DBG_MSG_V("wxWidgets_LIBRARY_DIRS=${wxWidgets_LIBRARY_DIRS}")
763       ELSE(RET EQUAL 0)
764         SET(wxWidgets_FOUND FALSE)
765         DBG_MSG("${wxWidgets_CONFIG_EXECUTABLE} --libs ${wxWidgets_FIND_COMPONENTS} FAILED with RET=${RET}")
766       ENDIF(RET EQUAL 0)
767     ENDIF(wxWidgets_CONFIG_EXECUTABLE)
769 #=====================================================================
770 # Neither UNIX_FIND_STYLE, nor WIN32_FIND_STYLE
771 #=====================================================================
772   ELSE(wxWidgets_FIND_STYLE STREQUAL "unix")
773     IF(NOT wxWidgets_FIND_QUIETLY)
774       MESSAGE(STATUS
775         "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): \n"
776         "  Platform unknown/unsupported. It's neither WIN32 nor UNIX "
777         "find style."
778         )
779     ENDIF(NOT wxWidgets_FIND_QUIETLY)
780   ENDIF(wxWidgets_FIND_STYLE STREQUAL "unix")
781 ENDIF(wxWidgets_FIND_STYLE STREQUAL "win32")
783 # Debug output:
784 DBG_MSG("wxWidgets_FOUND           : ${wxWidgets_FOUND}")
785 DBG_MSG("wxWidgets_INCLUDE_DIRS    : ${wxWidgets_INCLUDE_DIRS}")
786 DBG_MSG("wxWidgets_LIBRARY_DIRS    : ${wxWidgets_LIBRARY_DIRS}")
787 DBG_MSG("wxWidgets_LIBRARIES       : ${wxWidgets_LIBRARIES}")
788 DBG_MSG("wxWidgets_CXX_FLAGS       : ${wxWidgets_CXX_FLAGS}")
789 DBG_MSG("wxWidgets_USE_FILE        : ${wxWidgets_USE_FILE}")
791 #=====================================================================
792 #=====================================================================
793 INCLUDE(FindPackageHandleStandardArgs)
794 FIND_PACKAGE_HANDLE_STANDARD_ARGS(wxWidgets DEFAULT_MSG wxWidgets_FOUND)
795 # Maintain consistency with all other variables.
796 SET(wxWidgets_FOUND ${WXWIDGETS_FOUND})
798 #=====================================================================
799 # Macros for use in wxWidgets apps.
800 # - This module will not fail to find wxWidgets based on the code
801 #   below. Hence, it's required to check for validity of:
803 # wxWidgets_wxrc_EXECUTABLE
804 #=====================================================================
806 # Resource file compiler.
807 FIND_PROGRAM(wxWidgets_wxrc_EXECUTABLE wxrc
808   ${wxWidgets_ROOT_DIR}/utils/wxrc/vc_msw
809   )
812 # WX_SPLIT_ARGUMENTS_ON(<keyword> <left> <right> <arg1> <arg2> ...)
814 # Sets <left> and <right> to contain arguments to the left and right,
815 # respectively, of <keyword>.
817 # Example usage:
818 #  FUNCTION(WXWIDGETS_ADD_RESOURCES outfiles)
819 #    WX_SPLIT_ARGUMENTS_ON(OPTIONS wxrc_files wxrc_options ${ARGN})
820 #    ...
821 #  ENDFUNCTION(WXWIDGETS_ADD_RESOURCES)
823 #  WXWIDGETS_ADD_RESOURCES(sources ${xrc_files} OPTIONS -e -o file.C)
825 # NOTE: This is a generic piece of code that should be renamed to
826 # SPLIT_ARGUMENTS_ON and put in a file serving the same purpose as
827 # FindPackageStandardArgs.cmake. At the time of this writing
828 # FindQt4.cmake has a QT4_EXTRACT_OPTIONS, which I basically copied
829 # here a bit more generalized. So, there are already two find modules
830 # using this approach.
832 FUNCTION(WX_SPLIT_ARGUMENTS_ON _keyword _leftvar _rightvar)
833   # FIXME: Document that the input variables will be cleared.
834   #LIST(APPEND ${_leftvar}  "")
835   #LIST(APPEND ${_rightvar} "")
836   SET(${_leftvar}  "")
837   SET(${_rightvar} "")
839   SET(_doing_right FALSE)
840   FOREACH(element ${ARGN})
841     IF("${element}" STREQUAL "${_keyword}")
842       SET(_doing_right TRUE)
843     ELSE("${element}" STREQUAL "${_keyword}")
844       IF(_doing_right)
845         LIST(APPEND ${_rightvar} "${element}")
846       ELSE(_doing_right)
847         LIST(APPEND ${_leftvar} "${element}")
848       ENDIF(_doing_right)
849     ENDIF("${element}" STREQUAL "${_keyword}")
850   ENDFOREACH(element)
852   SET(${_leftvar}  ${${_leftvar}}  PARENT_SCOPE)
853   SET(${_rightvar} ${${_rightvar}} PARENT_SCOPE)
854 ENDFUNCTION(WX_SPLIT_ARGUMENTS_ON)
857 # WX_GET_DEPENDENCIES_FROM_XML(
858 #   <depends>
859 #   <match_pattern>
860 #   <clean_pattern>
861 #   <xml_contents>
862 #   <depends_path>
863 #   )
865 # FIXME: Add documentation here...
867 FUNCTION(WX_GET_DEPENDENCIES_FROM_XML
868     _depends
869     _match_patt
870     _clean_patt
871     _xml_contents
872     _depends_path
873     )
875   STRING(REGEX MATCHALL
876     ${_match_patt}
877     dep_file_list
878     "${${_xml_contents}}"
879     )
880   FOREACH(dep_file ${dep_file_list})
881     STRING(REGEX REPLACE ${_clean_patt} "" dep_file "${dep_file}")
883     # make the file have an absolute path
884     IF(NOT IS_ABSOLUTE "${dep_file}")
885       SET(dep_file "${${_depends_path}}/${dep_file}")
886     ENDIF(NOT IS_ABSOLUTE "${dep_file}")
888     # append file to dependency list
889     LIST(APPEND ${_depends} "${dep_file}")
890   ENDFOREACH(dep_file)
892   SET(${_depends} ${${_depends}} PARENT_SCOPE)
893 ENDFUNCTION(WX_GET_DEPENDENCIES_FROM_XML)
896 # WXWIDGETS_ADD_RESOURCES(<sources> <xrc_files>
897 #                         OPTIONS <options> [NO_CPP_CODE])
899 # Adds a custom command for resource file compilation of the
900 # <xrc_files> and appends the output files to <sources>.
902 # Example usages:
903 #   WXWIDGETS_ADD_RESOURCES(sources xrc/main_frame.xrc)
904 #   WXWIDGETS_ADD_RESOURCES(sources ${xrc_files} OPTIONS -e -o altname.cxx)
906 FUNCTION(WXWIDGETS_ADD_RESOURCES _outfiles)
907   WX_SPLIT_ARGUMENTS_ON(OPTIONS rc_file_list rc_options ${ARGN})
909   # Parse files for dependencies.
910   SET(rc_file_list_abs "")
911   SET(rc_depends       "")
912   FOREACH(rc_file ${rc_file_list})
913     GET_FILENAME_COMPONENT(depends_path ${rc_file} PATH)
915     GET_FILENAME_COMPONENT(rc_file_abs ${rc_file} ABSOLUTE)
916     LIST(APPEND rc_file_list_abs "${rc_file_abs}")
918     # All files have absolute paths or paths relative to the location
919     # of the rc file.
920     FILE(READ "${rc_file_abs}" rc_file_contents)
922     # get bitmap/bitmap2 files
923     WX_GET_DEPENDENCIES_FROM_XML(
924       rc_depends
925       "<bitmap[^<]+"
926       "^<bitmap[^>]*>"
927       rc_file_contents
928       depends_path
929       )
931     # get url files
932     WX_GET_DEPENDENCIES_FROM_XML(
933       rc_depends
934       "<url[^<]+"
935       "^<url[^>]*>"
936       rc_file_contents
937       depends_path
938       )
940     # get wxIcon files
941     WX_GET_DEPENDENCIES_FROM_XML(
942       rc_depends
943       "<object[^>]*class=\"wxIcon\"[^<]+"
944       "^<object[^>]*>"
945       rc_file_contents
946       depends_path
947       )
948   ENDFOREACH(rc_file)
950   #
951   # Parse options.
952   # 
953   # If NO_CPP_CODE option specified, then produce .xrs file rather
954   # than a .cpp file (i.e., don't add the default --cpp-code option).
955   LIST(FIND rc_options NO_CPP_CODE index)
956   IF(index EQUAL -1)
957     LIST(APPEND rc_options --cpp-code)
958     # wxrc's default output filename for cpp code.
959     SET(outfile resource.cpp)
960   ELSE(index EQUAL -1)
961     LIST(REMOVE_AT rc_options ${index})
962     # wxrc's default output filename for xrs file.
963     SET(outfile resource.xrs)
964   ENDIF(index EQUAL -1)
966   # Get output name for use in ADD_CUSTOM_COMMAND.
967   # - short option scanning
968   LIST(FIND rc_options -o index)
969   IF(NOT index EQUAL -1)
970     MATH(EXPR filename_index "${index} + 1")
971     LIST(GET rc_options ${filename_index} outfile)
972     #LIST(REMOVE_AT rc_options ${index} ${filename_index})
973   ENDIF(NOT index EQUAL -1)
974   # - long option scanning
975   STRING(REGEX MATCH "--output=[^;]*" outfile_opt "${rc_options}")
976   IF(outfile_opt)
977     STRING(REPLACE "--output=" "" outfile "${outfile_opt}")
978   ENDIF(outfile_opt)
979   #STRING(REGEX REPLACE "--output=[^;]*;?" "" rc_options "${rc_options}")
980   #STRING(REGEX REPLACE ";$" "" rc_options "${rc_options}")
981   
982   IF(NOT IS_ABSOLUTE "${outfile}")
983     SET(outfile "${CMAKE_CURRENT_BINARY_DIR}/${outfile}")
984   ENDIF(NOT IS_ABSOLUTE "${outfile}")
985   ADD_CUSTOM_COMMAND(
986     OUTPUT "${outfile}"
987     COMMAND ${wxWidgets_wxrc_EXECUTABLE} ${rc_options} ${rc_file_list_abs}
988     DEPENDS ${rc_file_list_abs} ${rc_depends}
989     )
991   # Add generated header to output file list.
992   LIST(FIND rc_options -e short_index)
993   LIST(FIND rc_options --extra-cpp-code long_index)
994   IF(NOT short_index EQUAL -1 OR NOT long_index EQUAL -1)
995     GET_FILENAME_COMPONENT(outfile_ext ${outfile} EXT)
996     STRING(REPLACE "${outfile_ext}" ".h" outfile_header "${outfile}")
997     LIST(APPEND ${_outfiles} "${outfile_header}")
998     SET_SOURCE_FILES_PROPERTIES(
999       "${outfile_header}" PROPERTIES GENERATED TRUE
1000       )
1001   ENDIF(NOT short_index EQUAL -1 OR NOT long_index EQUAL -1)
1003   # Add generated file to output file list.
1004   LIST(APPEND ${_outfiles} "${outfile}")
1006   SET(${_outfiles} ${${_outfiles}} PARENT_SCOPE)
1007 ENDFUNCTION(WXWIDGETS_ADD_RESOURCES)