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