5 # Find a wxWidgets (a.k.a., wxWindows) installation.
\r
7 # This module finds if wxWidgets is installed and selects a default
\r
8 # configuration to use. wxWidgets is a modular library. To specify the
\r
9 # modules that you will use, you need to name them as components to the
\r
12 # find_package(wxWidgets COMPONENTS core base ...)
\r
14 # There are two search branches: a windows style and a unix style. For
\r
15 # windows, the following variables are searched for and set to defaults
\r
16 # in case of multiple choices. Change them if the defaults are not
\r
17 # desired (i.e., these are the only variables you should change to
\r
18 # select a configuration):
\r
22 # wxWidgets_ROOT_DIR - Base wxWidgets directory
\r
23 # (e.g., C:/wxWidgets-2.6.3).
\r
24 # wxWidgets_LIB_DIR - Path to wxWidgets libraries
\r
25 # (e.g., C:/wxWidgets-2.6.3/lib/vc_lib).
\r
26 # wxWidgets_CONFIGURATION - Configuration to use
\r
27 # (e.g., msw, mswd, mswu, mswunivud, etc.)
\r
28 # wxWidgets_EXCLUDE_COMMON_LIBRARIES
\r
29 # - Set to TRUE to exclude linking of
\r
30 # commonly required libs (e.g., png tiff
\r
31 # jpeg zlib regex expat).
\r
35 # For unix style it uses the wx-config utility. You can select between
\r
36 # debug/release, unicode/ansi, universal/non-universal, and
\r
37 # static/shared in the QtDialog or ccmake interfaces by turning ON/OFF
\r
38 # the following variables:
\r
42 # wxWidgets_USE_DEBUG
\r
43 # wxWidgets_USE_UNICODE
\r
44 # wxWidgets_USE_UNIVERSAL
\r
45 # wxWidgets_USE_STATIC
\r
49 # There is also a wxWidgets_CONFIG_OPTIONS variable for all other
\r
50 # options that need to be passed to the wx-config utility. For example,
\r
51 # to use the base toolkit found in the /usr/local path, set the variable
\r
52 # (before calling the FIND_PACKAGE command) as such:
\r
56 # set(wxWidgets_CONFIG_OPTIONS --toolkit=base --prefix=/usr)
\r
60 # The following are set after the configuration is done for both windows
\r
65 # wxWidgets_FOUND - Set to TRUE if wxWidgets was found.
\r
66 # wxWidgets_INCLUDE_DIRS - Include directories for WIN32
\r
67 # i.e., where to find "wx/wx.h" and
\r
68 # "wx/setup.h"; possibly empty for unices.
\r
69 # wxWidgets_LIBRARIES - Path to the wxWidgets libraries.
\r
70 # wxWidgets_LIBRARY_DIRS - compile time link dirs, useful for
\r
71 # rpath on UNIX. Typically an empty string
\r
72 # in WIN32 environment.
\r
73 # wxWidgets_DEFINITIONS - Contains defines required to compile/link
\r
74 # against WX, e.g. WXUSINGDLL
\r
75 # wxWidgets_DEFINITIONS_DEBUG- Contains defines required to compile/link
\r
76 # against WX debug builds, e.g. __WXDEBUG__
\r
77 # wxWidgets_CXX_FLAGS - Include dirs and compiler flags for
\r
78 # unices, empty on WIN32. Essentially
\r
79 # "`wx-config --cxxflags`".
\r
80 # wxWidgets_USE_FILE - Convenience include file.
\r
88 # # Note that for MinGW users the order of libs is important!
\r
89 # find_package(wxWidgets COMPONENTS net gl core base)
\r
90 # if(wxWidgets_FOUND)
\r
91 # include(${wxWidgets_USE_FILE})
\r
92 # # and for each of your dependent executable/library targets:
\r
93 # target_link_libraries(<YourTarget> ${wxWidgets_LIBRARIES})
\r
98 # If wxWidgets is required (i.e., not an optional part):
\r
102 # find_package(wxWidgets REQUIRED net gl core base)
\r
103 # include(${wxWidgets_USE_FILE})
\r
104 # # and for each of your dependent executable/library targets:
\r
105 # target_link_libraries(<YourTarget> ${wxWidgets_LIBRARIES})
\r
107 #=============================================================================
\r
108 # Copyright 2004-2009 Kitware, Inc.
\r
109 # Copyright 2007-2009 Miguel A. Figueroa-Villanueva <miguelf at ieee dot org>
\r
111 # Distributed under the OSI-approved BSD License (the "License");
\r
112 # see accompanying file Copyright.txt for details.
\r
114 # This software is distributed WITHOUT ANY WARRANTY; without even the
\r
115 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
\r
116 # See the License for more information.
\r
117 #=============================================================================
\r
118 # (To distribute this file outside of CMake, substitute the full
\r
119 # License text for the above reference.)
\r
122 # FIXME: check this and provide a correct sample usage...
\r
123 # Remember to connect back to the upper text.
\r
124 # Sample usage with monolithic wx build:
\r
126 # find_package(wxWidgets COMPONENTS mono)
\r
131 # This module has been tested on the WIN32 platform with wxWidgets
\r
132 # 2.6.2, 2.6.3, and 2.5.3. However, it has been designed to
\r
133 # easily extend support to all possible builds, e.g., static/shared,
\r
134 # debug/release, unicode, universal, multilib/monolithic, etc..
\r
136 # If you want to use the module and your build type is not supported
\r
137 # out-of-the-box, please contact me to exchange information on how
\r
138 # your system is setup and I'll try to add support for it.
\r
142 # Miguel A. Figueroa-Villanueva (miguelf at ieee dot org).
\r
143 # Jan Woetzel (jw at mip.informatik.uni-kiel.de).
\r
145 # Based on previous works of:
\r
146 # Jan Woetzel (FindwxWindows.cmake),
\r
147 # Jorgen Bodde and Jerry Fath (FindwxWin.cmake).
\r
151 # (1) Option/Setting to use all available wx libs
\r
152 # In contrast to expert developer who lists the
\r
153 # minimal set of required libs in wxWidgets_USE_LIBS
\r
154 # there is the newbie user:
\r
155 # - who just wants to link against WX with more 'magic'
\r
156 # - doesn't know the internal structure of WX or how it was built,
\r
157 # in particular if it is monolithic or not
\r
158 # - want to link against all available WX libs
\r
159 # Basically, the intent here is to mimic what wx-config would do by
\r
160 # default (i.e., `wx-config --libs`).
\r
162 # Possible solution:
\r
163 # Add a reserved keyword "std" that initializes to what wx-config
\r
164 # would default to. If the user has not set the wxWidgets_USE_LIBS,
\r
165 # default to "std" instead of "base core" as it is now. To implement
\r
166 # "std" will basically boil down to a FOR_EACH lib-FOUND, but maybe
\r
167 # checking whether a minimal set was found.
\r
170 # FIXME: This and all the DBG_MSG calls should be removed after the
\r
171 # module stabilizes.
\r
173 # Helper macro to control the debugging output globally. There are
\r
174 # two versions for controlling how verbose your output should be.
\r
175 macro(DBG_MSG _MSG)
\r
177 # "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): ${_MSG}")
\r
179 macro(DBG_MSG_V _MSG)
\r
181 # "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): ${_MSG}")
\r
184 # Clear return values in case the module is loaded more than once.
\r
185 set(wxWidgets_FOUND FALSE)
\r
186 set(wxWidgets_INCLUDE_DIRS "")
\r
187 set(wxWidgets_LIBRARIES "")
\r
188 set(wxWidgets_LIBRARY_DIRS "")
\r
189 set(wxWidgets_CXX_FLAGS "")
\r
191 # DEPRECATED: This is a patch to support the DEPRECATED use of
\r
192 # wxWidgets_USE_LIBS.
\r
194 # If wxWidgets_USE_LIBS is set:
\r
195 # - if using <components>, then override wxWidgets_USE_LIBS
\r
196 # - else set wxWidgets_FIND_COMPONENTS to wxWidgets_USE_LIBS
\r
197 if(wxWidgets_USE_LIBS AND NOT wxWidgets_FIND_COMPONENTS)
\r
198 set(wxWidgets_FIND_COMPONENTS ${wxWidgets_USE_LIBS})
\r
200 DBG_MSG("wxWidgets_FIND_COMPONENTS : ${wxWidgets_FIND_COMPONENTS}")
\r
202 # Add the convenience use file if available.
\r
204 # Get dir of this file which may reside in:
\r
205 # - CMAKE_MAKE_ROOT/Modules on CMake installation
\r
206 # - CMAKE_MODULE_PATH if user prefers his own specialized version
\r
207 set(wxWidgets_USE_FILE "")
\r
208 get_filename_component(
\r
209 wxWidgets_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
\r
210 # Prefer an existing customized version, but the user might override
\r
211 # the FindwxWidgets module and not the UsewxWidgets one.
\r
212 if(EXISTS "${wxWidgets_CURRENT_LIST_DIR}/UsewxWidgets.cmake")
\r
213 set(wxWidgets_USE_FILE
\r
214 "${wxWidgets_CURRENT_LIST_DIR}/UsewxWidgets.cmake")
\r
216 set(wxWidgets_USE_FILE UsewxWidgets)
\r
219 #=====================================================================
\r
220 # Determine whether unix or win32 paths should be used
\r
221 #=====================================================================
\r
222 if(WIN32 AND NOT CYGWIN AND NOT MSYS AND NOT CMAKE_CROSSCOMPILING)
\r
223 set(wxWidgets_FIND_STYLE "win32")
\r
225 set(wxWidgets_FIND_STYLE "unix")
\r
228 #=====================================================================
\r
230 #=====================================================================
\r
231 if(wxWidgets_FIND_STYLE STREQUAL "win32")
\r
232 # Useful common wx libs needed by almost all components.
\r
233 set(wxWidgets_COMMON_LIBRARIES png tiff jpeg zlib regex expat)
\r
235 # DEPRECATED: Use find_package(wxWidgets COMPONENTS mono) instead.
\r
236 if(NOT wxWidgets_FIND_COMPONENTS)
\r
237 if(wxWidgets_USE_MONOLITHIC)
\r
238 set(wxWidgets_FIND_COMPONENTS mono)
\r
240 set(wxWidgets_FIND_COMPONENTS core base) # this is default
\r
244 # Add the common (usually required libs) unless
\r
245 # wxWidgets_EXCLUDE_COMMON_LIBRARIES has been set.
\r
246 if(NOT wxWidgets_EXCLUDE_COMMON_LIBRARIES)
\r
247 list(APPEND wxWidgets_FIND_COMPONENTS
\r
248 ${wxWidgets_COMMON_LIBRARIES})
\r
251 #-------------------------------------------------------------------
\r
252 # WIN32: Helper MACROS
\r
253 #-------------------------------------------------------------------
\r
255 # Get filename components for a configuration. For example,
\r
256 # if _CONFIGURATION = mswunivud, then _UNV=univ, _UCD=u _DBG=d
\r
257 # if _CONFIGURATION = mswu, then _UNV="", _UCD=u _DBG=""
\r
259 macro(WX_GET_NAME_COMPONENTS _CONFIGURATION _UNV _UCD _DBG)
\r
260 string(REGEX MATCH "univ" ${_UNV} "${_CONFIGURATION}")
\r
261 string(REGEX REPLACE "msw.*(u)[d]*$" "u" ${_UCD} "${_CONFIGURATION}")
\r
262 if(${_UCD} STREQUAL ${_CONFIGURATION})
\r
265 string(REGEX MATCH "d$" ${_DBG} "${_CONFIGURATION}")
\r
269 # Find libraries associated to a configuration.
\r
271 macro(WX_FIND_LIBS _UNV _UCD _DBG)
\r
272 DBG_MSG_V("m_unv = ${_UNV}")
\r
273 DBG_MSG_V("m_ucd = ${_UCD}")
\r
274 DBG_MSG_V("m_dbg = ${_DBG}")
\r
276 # FIXME: What if both regex libs are available. regex should be
\r
277 # found outside the loop and only wx${LIB}${_UCD}${_DBG}.
\r
278 # Find wxWidgets common libraries.
\r
279 foreach(LIB ${wxWidgets_COMMON_LIBRARIES} scintilla)
\r
280 find_library(WX_${LIB}${_DBG}
\r
282 wx${LIB}${_UCD}${_DBG} # for regex
\r
284 PATHS ${WX_LIB_DIR}
\r
287 mark_as_advanced(WX_${LIB}${_DBG})
\r
290 # Find wxWidgets multilib base libraries.
\r
291 find_library(WX_base${_DBG}
\r
293 wxbase31${_UCD}${_DBG}
\r
294 wxbase30${_UCD}${_DBG}
\r
295 wxbase29${_UCD}${_DBG}
\r
296 wxbase28${_UCD}${_DBG}
\r
297 wxbase27${_UCD}${_DBG}
\r
298 wxbase26${_UCD}${_DBG}
\r
299 wxbase25${_UCD}${_DBG}
\r
300 PATHS ${WX_LIB_DIR}
\r
303 mark_as_advanced(WX_base${_DBG})
\r
304 foreach(LIB net odbc xml)
\r
305 find_library(WX_${LIB}${_DBG}
\r
307 wxbase31${_UCD}${_DBG}_${LIB}
\r
308 wxbase30${_UCD}${_DBG}_${LIB}
\r
309 wxbase29${_UCD}${_DBG}_${LIB}
\r
310 wxbase28${_UCD}${_DBG}_${LIB}
\r
311 wxbase27${_UCD}${_DBG}_${LIB}
\r
312 wxbase26${_UCD}${_DBG}_${LIB}
\r
313 wxbase25${_UCD}${_DBG}_${LIB}
\r
314 PATHS ${WX_LIB_DIR}
\r
317 mark_as_advanced(WX_${LIB}${_DBG})
\r
320 # Find wxWidgets monolithic library.
\r
321 find_library(WX_mono${_DBG}
\r
323 wxmsw${_UNV}31${_UCD}${_DBG}
\r
324 wxmsw${_UNV}30${_UCD}${_DBG}
\r
325 wxmsw${_UNV}29${_UCD}${_DBG}
\r
326 wxmsw${_UNV}28${_UCD}${_DBG}
\r
327 wxmsw${_UNV}27${_UCD}${_DBG}
\r
328 wxmsw${_UNV}26${_UCD}${_DBG}
\r
329 wxmsw${_UNV}25${_UCD}${_DBG}
\r
330 PATHS ${WX_LIB_DIR}
\r
333 mark_as_advanced(WX_mono${_DBG})
\r
335 # Find wxWidgets multilib libraries.
\r
336 foreach(LIB core adv aui html media xrc dbgrid gl qa richtext
\r
337 stc ribbon propgrid webview)
\r
338 find_library(WX_${LIB}${_DBG}
\r
340 wxmsw${_UNV}31${_UCD}${_DBG}_${LIB}
\r
341 wxmsw${_UNV}30${_UCD}${_DBG}_${LIB}
\r
342 wxmsw${_UNV}29${_UCD}${_DBG}_${LIB}
\r
343 wxmsw${_UNV}28${_UCD}${_DBG}_${LIB}
\r
344 wxmsw${_UNV}27${_UCD}${_DBG}_${LIB}
\r
345 wxmsw${_UNV}26${_UCD}${_DBG}_${LIB}
\r
346 wxmsw${_UNV}25${_UCD}${_DBG}_${LIB}
\r
347 PATHS ${WX_LIB_DIR}
\r
350 mark_as_advanced(WX_${LIB}${_DBG})
\r
355 # Clear all library paths, so that FIND_LIBRARY refinds them.
\r
357 # Clear a lib, reset its found flag, and mark as advanced.
\r
358 macro(WX_CLEAR_LIB _LIB)
\r
359 set(${_LIB} "${_LIB}-NOTFOUND" CACHE FILEPATH "Cleared." FORCE)
\r
360 set(${_LIB}_FOUND FALSE)
\r
361 mark_as_advanced(${_LIB})
\r
363 # Clear all debug or release library paths (arguments are "d" or "").
\r
364 macro(WX_CLEAR_ALL_LIBS _DBG)
\r
365 # Clear wxWidgets common libraries.
\r
366 foreach(LIB ${wxWidgets_COMMON_LIBRARIES} scintilla)
\r
367 WX_CLEAR_LIB(WX_${LIB}${_DBG})
\r
370 # Clear wxWidgets multilib base libraries.
\r
371 WX_CLEAR_LIB(WX_base${_DBG})
\r
372 foreach(LIB net odbc xml)
\r
373 WX_CLEAR_LIB(WX_${LIB}${_DBG})
\r
376 # Clear wxWidgets monolithic library.
\r
377 WX_CLEAR_LIB(WX_mono${_DBG})
\r
379 # Clear wxWidgets multilib libraries.
\r
380 foreach(LIB core adv aui html media xrc dbgrid gl qa richtext
\r
381 webview stc ribbon propgrid)
\r
382 WX_CLEAR_LIB(WX_${LIB}${_DBG})
\r
385 # Clear all wxWidgets debug libraries.
\r
386 macro(WX_CLEAR_ALL_DBG_LIBS)
\r
387 WX_CLEAR_ALL_LIBS("d")
\r
389 # Clear all wxWidgets release libraries.
\r
390 macro(WX_CLEAR_ALL_REL_LIBS)
\r
391 WX_CLEAR_ALL_LIBS("")
\r
395 # Set the wxWidgets_LIBRARIES variable.
\r
396 # Also, Sets output variable wxWidgets_FOUND to FALSE if it fails.
\r
398 macro(WX_SET_LIBRARIES _LIBS _DBG)
\r
399 DBG_MSG_V("Looking for ${${_LIBS}}")
\r
400 if(WX_USE_REL_AND_DBG)
\r
401 foreach(LIB ${${_LIBS}})
\r
402 DBG_MSG_V("Searching for ${LIB} and ${LIB}d")
\r
403 DBG_MSG_V("WX_${LIB} : ${WX_${LIB}}")
\r
404 DBG_MSG_V("WX_${LIB}d : ${WX_${LIB}d}")
\r
405 if(WX_${LIB} AND WX_${LIB}d)
\r
406 DBG_MSG_V("Found ${LIB} and ${LIB}d")
\r
407 list(APPEND wxWidgets_LIBRARIES
\r
408 debug ${WX_${LIB}d} optimized ${WX_${LIB}}
\r
411 DBG_MSG_V("- not found due to missing WX_${LIB}=${WX_${LIB}} or WX_${LIB}d=${WX_${LIB}d}")
\r
412 set(wxWidgets_FOUND FALSE)
\r
416 foreach(LIB ${${_LIBS}})
\r
417 DBG_MSG_V("Searching for ${LIB}${_DBG}")
\r
418 DBG_MSG_V("WX_${LIB}${_DBG} : ${WX_${LIB}${_DBG}}")
\r
419 if(WX_${LIB}${_DBG})
\r
420 DBG_MSG_V("Found ${LIB}${_DBG}")
\r
421 list(APPEND wxWidgets_LIBRARIES ${WX_${LIB}${_DBG}})
\r
424 "- not found due to missing WX_${LIB}${_DBG}=${WX_${LIB}${_DBG}}")
\r
425 set(wxWidgets_FOUND FALSE)
\r
430 DBG_MSG_V("OpenGL")
\r
431 list(FIND ${_LIBS} gl WX_USE_GL)
\r
432 if(NOT WX_USE_GL EQUAL -1)
\r
433 DBG_MSG_V("- is required.")
\r
434 list(APPEND wxWidgets_LIBRARIES opengl32 glu32)
\r
437 list(APPEND wxWidgets_LIBRARIES winmm comctl32 rpcrt4 wsock32)
\r
440 #-------------------------------------------------------------------
\r
441 # WIN32: Start actual work.
\r
442 #-------------------------------------------------------------------
\r
444 # Look for an installation tree.
\r
445 find_path(wxWidgets_ROOT_DIR
\r
446 NAMES include/wx/wx.h
\r
449 ENV wxWidgets_ROOT_DIR
\r
451 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\wxWidgets_is1;Inno Setup: App Path]" # WX 2.6.x
\r
490 DOC "wxWidgets base/installation directory"
\r
493 # If wxWidgets_ROOT_DIR changed, clear lib dir.
\r
494 if(NOT WX_ROOT_DIR STREQUAL wxWidgets_ROOT_DIR)
\r
495 set(WX_ROOT_DIR ${wxWidgets_ROOT_DIR}
\r
496 CACHE INTERNAL "wxWidgets_ROOT_DIR")
\r
497 set(wxWidgets_LIB_DIR "wxWidgets_LIB_DIR-NOTFOUND"
\r
498 CACHE PATH "Cleared." FORCE)
\r
502 # Select one default tree inside the already determined wx tree.
\r
503 # Prefer static/shared order usually consistent with build
\r
506 set(WX_LIB_DIR_PREFIX gcc)
\r
507 elseif(CMAKE_CL_64)
\r
508 set(WX_LIB_DIR_PREFIX vc_x64)
\r
510 set(WX_LIB_DIR_PREFIX vc)
\r
512 if(BUILD_SHARED_LIBS)
\r
513 find_path(wxWidgets_LIB_DIR
\r
520 mswunivd/wx/setup.h
\r
521 mswunivu/wx/setup.h
\r
522 mswunivud/wx/setup.h
\r
524 ${WX_ROOT_DIR}/lib/${WX_LIB_DIR_PREFIX}_dll # prefer shared
\r
525 ${WX_ROOT_DIR}/lib/${WX_LIB_DIR_PREFIX}_lib
\r
526 DOC "Path to wxWidgets libraries"
\r
530 find_path(wxWidgets_LIB_DIR
\r
537 mswunivd/wx/setup.h
\r
538 mswunivu/wx/setup.h
\r
539 mswunivud/wx/setup.h
\r
541 ${WX_ROOT_DIR}/lib/${WX_LIB_DIR_PREFIX}_lib # prefer static
\r
542 ${WX_ROOT_DIR}/lib/${WX_LIB_DIR_PREFIX}_dll
\r
543 DOC "Path to wxWidgets libraries"
\r
548 # If wxWidgets_LIB_DIR changed, clear all libraries.
\r
549 if(NOT WX_LIB_DIR STREQUAL wxWidgets_LIB_DIR)
\r
550 set(WX_LIB_DIR ${wxWidgets_LIB_DIR} CACHE INTERNAL "wxWidgets_LIB_DIR")
\r
551 WX_CLEAR_ALL_DBG_LIBS()
\r
552 WX_CLEAR_ALL_REL_LIBS()
\r
556 # If building shared libs, define WXUSINGDLL to use dllimport.
\r
557 if(WX_LIB_DIR MATCHES "[dD][lL][lL]")
\r
558 set(wxWidgets_DEFINITIONS WXUSINGDLL)
\r
559 DBG_MSG_V("detected SHARED/DLL tree WX_LIB_DIR=${WX_LIB_DIR}")
\r
562 # Search for available configuration types.
\r
563 foreach(CFG mswunivud mswunivd mswud mswd mswunivu mswuniv mswu msw)
\r
564 set(WX_${CFG}_FOUND FALSE)
\r
565 if(EXISTS ${WX_LIB_DIR}/${CFG})
\r
566 list(APPEND WX_CONFIGURATION_LIST ${CFG})
\r
567 set(WX_${CFG}_FOUND TRUE)
\r
568 set(WX_CONFIGURATION ${CFG})
\r
571 DBG_MSG_V("WX_CONFIGURATION_LIST=${WX_CONFIGURATION_LIST}")
\r
573 if(WX_CONFIGURATION)
\r
574 set(wxWidgets_FOUND TRUE)
\r
576 # If the selected configuration wasn't found force the default
\r
577 # one. Otherwise, use it but still force a refresh for
\r
578 # updating the doc string with the current list of available
\r
580 if(NOT WX_${wxWidgets_CONFIGURATION}_FOUND)
\r
581 set(wxWidgets_CONFIGURATION ${WX_CONFIGURATION} CACHE STRING
\r
582 "Set wxWidgets configuration (${WX_CONFIGURATION_LIST})" FORCE)
\r
584 set(wxWidgets_CONFIGURATION ${wxWidgets_CONFIGURATION} CACHE STRING
\r
585 "Set wxWidgets configuration (${WX_CONFIGURATION_LIST})" FORCE)
\r
588 # If release config selected, and both release/debug exist.
\r
589 if(WX_${wxWidgets_CONFIGURATION}d_FOUND)
\r
590 option(wxWidgets_USE_REL_AND_DBG
\r
591 "Use release and debug configurations?" TRUE)
\r
592 set(WX_USE_REL_AND_DBG ${wxWidgets_USE_REL_AND_DBG})
\r
594 # If the option exists (already in cache), force it false.
\r
595 if(wxWidgets_USE_REL_AND_DBG)
\r
596 set(wxWidgets_USE_REL_AND_DBG FALSE CACHE BOOL
\r
597 "No ${wxWidgets_CONFIGURATION}d found." FORCE)
\r
599 set(WX_USE_REL_AND_DBG FALSE)
\r
602 # Get configuration parameters from the name.
\r
603 WX_GET_NAME_COMPONENTS(${wxWidgets_CONFIGURATION} UNV UCD DBG)
\r
605 # Set wxWidgets lib setup include directory.
\r
606 if(EXISTS ${WX_LIB_DIR}/${wxWidgets_CONFIGURATION}/wx/setup.h)
\r
607 set(wxWidgets_INCLUDE_DIRS
\r
608 ${WX_LIB_DIR}/${wxWidgets_CONFIGURATION})
\r
610 DBG_MSG("wxWidgets_FOUND FALSE because ${WX_LIB_DIR}/${wxWidgets_CONFIGURATION}/wx/setup.h does not exists.")
\r
611 set(wxWidgets_FOUND FALSE)
\r
614 # Set wxWidgets main include directory.
\r
615 if(EXISTS ${WX_ROOT_DIR}/include/wx/wx.h)
\r
616 list(APPEND wxWidgets_INCLUDE_DIRS ${WX_ROOT_DIR}/include)
\r
618 DBG_MSG("wxWidgets_FOUND FALSE because WX_ROOT_DIR=${WX_ROOT_DIR} has no ${WX_ROOT_DIR}/include/wx/wx.h")
\r
619 set(wxWidgets_FOUND FALSE)
\r
622 # Find wxWidgets libraries.
\r
623 WX_FIND_LIBS("${UNV}" "${UCD}" "${DBG}")
\r
624 if(WX_USE_REL_AND_DBG)
\r
625 WX_FIND_LIBS("${UNV}" "${UCD}" "d")
\r
628 # Settings for requested libs (i.e., include dir, libraries, etc.).
\r
629 WX_SET_LIBRARIES(wxWidgets_FIND_COMPONENTS "${DBG}")
\r
631 # Add necessary definitions for unicode builds
\r
632 if("${UCD}" STREQUAL "u")
\r
633 list(APPEND wxWidgets_DEFINITIONS UNICODE _UNICODE)
\r
636 # Add necessary definitions for debug builds
\r
637 set(wxWidgets_DEFINITIONS_DEBUG _DEBUG __WXDEBUG__)
\r
643 #=====================================================================
\r
645 #=====================================================================
\r
647 if(wxWidgets_FIND_STYLE STREQUAL "unix")
\r
648 #-----------------------------------------------------------------
\r
649 # UNIX: Helper MACROS
\r
650 #-----------------------------------------------------------------
\r
652 # Set the default values based on "wx-config --selected-config".
\r
654 macro(WX_CONFIG_SELECT_GET_DEFAULT)
\r
656 COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}"
\r
657 ${wxWidgets_CONFIG_OPTIONS} --selected-config
\r
658 OUTPUT_VARIABLE _wx_selected_config
\r
659 RESULT_VARIABLE _wx_result
\r
662 if(_wx_result EQUAL 0)
\r
663 foreach(_opt_name debug static unicode universal)
\r
664 string(TOUPPER ${_opt_name} _upper_opt_name)
\r
665 if(_wx_selected_config MATCHES "${_opt_name}")
\r
666 set(wxWidgets_DEFAULT_${_upper_opt_name} ON)
\r
668 set(wxWidgets_DEFAULT_${_upper_opt_name} OFF)
\r
672 foreach(_upper_opt_name DEBUG STATIC UNICODE UNIVERSAL)
\r
673 set(wxWidgets_DEFAULT_${_upper_opt_name} OFF)
\r
679 # Query a boolean configuration option to determine if the system
\r
680 # has both builds available. If so, provide the selection option
\r
683 macro(WX_CONFIG_SELECT_QUERY_BOOL _OPT_NAME _OPT_HELP)
\r
685 COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}"
\r
686 ${wxWidgets_CONFIG_OPTIONS} --${_OPT_NAME}=yes
\r
687 RESULT_VARIABLE _wx_result_yes
\r
692 COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}"
\r
693 ${wxWidgets_CONFIG_OPTIONS} --${_OPT_NAME}=no
\r
694 RESULT_VARIABLE _wx_result_no
\r
698 string(TOUPPER ${_OPT_NAME} _UPPER_OPT_NAME)
\r
699 if(_wx_result_yes EQUAL 0 AND _wx_result_no EQUAL 0)
\r
700 option(wxWidgets_USE_${_UPPER_OPT_NAME}
\r
701 ${_OPT_HELP} ${wxWidgets_DEFAULT_${_UPPER_OPT_NAME}})
\r
703 # If option exists (already in cache), force to available one.
\r
704 if(DEFINED wxWidgets_USE_${_UPPER_OPT_NAME})
\r
705 if(_wx_result_yes EQUAL 0)
\r
706 set(wxWidgets_USE_${_UPPER_OPT_NAME} ON CACHE BOOL ${_OPT_HELP} FORCE)
\r
708 set(wxWidgets_USE_${_UPPER_OPT_NAME} OFF CACHE BOOL ${_OPT_HELP} FORCE)
\r
715 # Set wxWidgets_SELECT_OPTIONS to wx-config options for selecting
\r
716 # among multiple builds.
\r
718 macro(WX_CONFIG_SELECT_SET_OPTIONS)
\r
719 set(wxWidgets_SELECT_OPTIONS ${wxWidgets_CONFIG_OPTIONS})
\r
720 foreach(_opt_name debug static unicode universal)
\r
721 string(TOUPPER ${_opt_name} _upper_opt_name)
\r
722 if(DEFINED wxWidgets_USE_${_upper_opt_name})
\r
723 if(wxWidgets_USE_${_upper_opt_name})
\r
724 list(APPEND wxWidgets_SELECT_OPTIONS --${_opt_name}=yes)
\r
726 list(APPEND wxWidgets_SELECT_OPTIONS --${_opt_name}=no)
\r
732 #-----------------------------------------------------------------
\r
733 # UNIX: Start actual work.
\r
734 #-----------------------------------------------------------------
\r
735 # Support cross-compiling, only search in the target platform.
\r
736 find_program(wxWidgets_CONFIG_EXECUTABLE
\r
737 NAMES wx-config wx-config-3.1 wx-config-3.0 wx-config-2.9 wx-config-2.8
\r
738 DOC "Location of wxWidgets library configuration provider binary (wx-config)."
\r
739 ONLY_CMAKE_FIND_ROOT_PATH
\r
742 if(wxWidgets_CONFIG_EXECUTABLE)
\r
743 set(wxWidgets_FOUND TRUE)
\r
745 # get defaults based on "wx-config --selected-config"
\r
746 WX_CONFIG_SELECT_GET_DEFAULT()
\r
748 # for each option: if both builds are available, provide option
\r
749 WX_CONFIG_SELECT_QUERY_BOOL(debug "Use debug build?")
\r
750 WX_CONFIG_SELECT_QUERY_BOOL(unicode "Use unicode build?")
\r
751 WX_CONFIG_SELECT_QUERY_BOOL(universal "Use universal build?")
\r
752 WX_CONFIG_SELECT_QUERY_BOOL(static "Link libraries statically?")
\r
754 # process selection to set wxWidgets_SELECT_OPTIONS
\r
755 WX_CONFIG_SELECT_SET_OPTIONS()
\r
756 DBG_MSG("wxWidgets_SELECT_OPTIONS=${wxWidgets_SELECT_OPTIONS}")
\r
758 # run the wx-config program to get cxxflags
\r
760 COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}"
\r
761 ${wxWidgets_SELECT_OPTIONS} --cxxflags
\r
762 OUTPUT_VARIABLE wxWidgets_CXX_FLAGS
\r
763 RESULT_VARIABLE RET
\r
767 string(STRIP "${wxWidgets_CXX_FLAGS}" wxWidgets_CXX_FLAGS)
\r
768 separate_arguments(wxWidgets_CXX_FLAGS)
\r
770 DBG_MSG_V("wxWidgets_CXX_FLAGS=${wxWidgets_CXX_FLAGS}")
\r
772 # parse definitions from cxxflags;
\r
773 # drop -D* from CXXFLAGS and the -D prefix
\r
774 string(REGEX MATCHALL "-D[^;]+"
\r
775 wxWidgets_DEFINITIONS "${wxWidgets_CXX_FLAGS}")
\r
776 string(REGEX REPLACE "-D[^;]+(;|$)" ""
\r
777 wxWidgets_CXX_FLAGS "${wxWidgets_CXX_FLAGS}")
\r
778 string(REGEX REPLACE ";$" ""
\r
779 wxWidgets_CXX_FLAGS "${wxWidgets_CXX_FLAGS}")
\r
780 string(REPLACE "-D" ""
\r
781 wxWidgets_DEFINITIONS "${wxWidgets_DEFINITIONS}")
\r
783 # parse include dirs from cxxflags; drop -I prefix
\r
784 string(REGEX MATCHALL "-I[^;]+"
\r
785 wxWidgets_INCLUDE_DIRS "${wxWidgets_CXX_FLAGS}")
\r
786 string(REGEX REPLACE "-I[^;]+;" ""
\r
787 wxWidgets_CXX_FLAGS "${wxWidgets_CXX_FLAGS}")
\r
788 string(REPLACE "-I" ""
\r
789 wxWidgets_INCLUDE_DIRS "${wxWidgets_INCLUDE_DIRS}")
\r
791 DBG_MSG_V("wxWidgets_DEFINITIONS=${wxWidgets_DEFINITIONS}")
\r
792 DBG_MSG_V("wxWidgets_INCLUDE_DIRS=${wxWidgets_INCLUDE_DIRS}")
\r
793 DBG_MSG_V("wxWidgets_CXX_FLAGS=${wxWidgets_CXX_FLAGS}")
\r
796 set(wxWidgets_FOUND FALSE)
\r
798 "${wxWidgets_CONFIG_EXECUTABLE} --cxxflags FAILED with RET=${RET}")
\r
801 # run the wx-config program to get the libs
\r
802 # - NOTE: wx-config doesn't verify that the libs requested exist
\r
803 # it just produces the names. Maybe a TRY_COMPILE would
\r
804 # be useful here...
\r
805 string(REPLACE ";" ","
\r
806 wxWidgets_FIND_COMPONENTS "${wxWidgets_FIND_COMPONENTS}")
\r
808 COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}"
\r
809 ${wxWidgets_SELECT_OPTIONS} --libs ${wxWidgets_FIND_COMPONENTS}
\r
810 OUTPUT_VARIABLE wxWidgets_LIBRARIES
\r
811 RESULT_VARIABLE RET
\r
815 string(STRIP "${wxWidgets_LIBRARIES}" wxWidgets_LIBRARIES)
\r
816 separate_arguments(wxWidgets_LIBRARIES)
\r
817 string(REPLACE "-framework;" "-framework "
\r
818 wxWidgets_LIBRARIES "${wxWidgets_LIBRARIES}")
\r
819 string(REPLACE "-arch;" "-arch "
\r
820 wxWidgets_LIBRARIES "${wxWidgets_LIBRARIES}")
\r
821 string(REPLACE "-isysroot;" "-isysroot "
\r
822 wxWidgets_LIBRARIES "${wxWidgets_LIBRARIES}")
\r
824 # extract linkdirs (-L) for rpath (i.e., LINK_DIRECTORIES)
\r
825 string(REGEX MATCHALL "-L[^;]+"
\r
826 wxWidgets_LIBRARY_DIRS "${wxWidgets_LIBRARIES}")
\r
827 string(REPLACE "-L" ""
\r
828 wxWidgets_LIBRARY_DIRS "${wxWidgets_LIBRARY_DIRS}")
\r
830 DBG_MSG_V("wxWidgets_LIBRARIES=${wxWidgets_LIBRARIES}")
\r
831 DBG_MSG_V("wxWidgets_LIBRARY_DIRS=${wxWidgets_LIBRARY_DIRS}")
\r
834 set(wxWidgets_FOUND FALSE)
\r
835 DBG_MSG("${wxWidgets_CONFIG_EXECUTABLE} --libs ${wxWidgets_FIND_COMPONENTS} FAILED with RET=${RET}")
\r
839 #=====================================================================
\r
840 # Neither UNIX_FIND_STYLE, nor WIN32_FIND_STYLE
\r
841 #=====================================================================
\r
843 if(NOT wxWidgets_FIND_QUIETLY)
\r
845 "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): \n"
\r
846 " Platform unknown/unsupported. It's neither WIN32 nor UNIX "
\r
853 # Check if a specfic version was requested by find_package().
\r
854 if(wxWidgets_FOUND)
\r
855 find_file(_filename wx/version.h PATHS ${wxWidgets_INCLUDE_DIRS} NO_DEFAULT_PATH)
\r
856 dbg_msg("_filename: ${_filename}")
\r
859 message(FATAL_ERROR "wxWidgets wx/version.h file not found in ${wxWidgets_INCLUDE_DIRS}.")
\r
862 file(READ ${_filename} _wx_version_h)
\r
864 string(REGEX REPLACE "^(.*\n)?#define +wxMAJOR_VERSION +([0-9]+).*"
\r
865 "\\2" wxWidgets_VERSION_MAJOR "${_wx_version_h}" )
\r
866 string(REGEX REPLACE "^(.*\n)?#define +wxMINOR_VERSION +([0-9]+).*"
\r
867 "\\2" wxWidgets_VERSION_MINOR "${_wx_version_h}" )
\r
868 string(REGEX REPLACE "^(.*\n)?#define +wxRELEASE_NUMBER +([0-9]+).*"
\r
869 "\\2" wxWidgets_VERSION_PATCH "${_wx_version_h}" )
\r
870 set(wxWidgets_VERSION_STRING
\r
871 "${wxWidgets_VERSION_MAJOR}.${wxWidgets_VERSION_MINOR}.${wxWidgets_VERSION_PATCH}" )
\r
872 dbg_msg("wxWidgets_VERSION_STRING: ${wxWidgets_VERSION_STRING}")
\r
876 DBG_MSG("wxWidgets_FOUND : ${wxWidgets_FOUND}")
\r
877 DBG_MSG("wxWidgets_INCLUDE_DIRS : ${wxWidgets_INCLUDE_DIRS}")
\r
878 DBG_MSG("wxWidgets_LIBRARY_DIRS : ${wxWidgets_LIBRARY_DIRS}")
\r
879 DBG_MSG("wxWidgets_LIBRARIES : ${wxWidgets_LIBRARIES}")
\r
880 DBG_MSG("wxWidgets_CXX_FLAGS : ${wxWidgets_CXX_FLAGS}")
\r
881 DBG_MSG("wxWidgets_USE_FILE : ${wxWidgets_USE_FILE}")
\r
883 #=====================================================================
\r
884 #=====================================================================
\r
886 include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
\r
888 find_package_handle_standard_args(wxWidgets
\r
889 REQUIRED_VARS wxWidgets_LIBRARIES wxWidgets_INCLUDE_DIRS
\r
890 VERSION_VAR wxWidgets_VERSION_STRING
\r
893 #=====================================================================
\r
894 # Macros for use in wxWidgets apps.
\r
895 # - This module will not fail to find wxWidgets based on the code
\r
896 # below. Hence, it's required to check for validity of:
\r
898 # wxWidgets_wxrc_EXECUTABLE
\r
899 #=====================================================================
\r
901 # Resource file compiler.
\r
902 find_program(wxWidgets_wxrc_EXECUTABLE wxrc
\r
903 ${wxWidgets_ROOT_DIR}/utils/wxrc/vc_msw
\r
904 DOC "Location of wxWidgets resource file compiler binary (wxrc)"
\r
908 # WX_SPLIT_ARGUMENTS_ON(<keyword> <left> <right> <arg1> <arg2> ...)
\r
910 # Sets <left> and <right> to contain arguments to the left and right,
\r
911 # respectively, of <keyword>.
\r
914 # function(WXWIDGETS_ADD_RESOURCES outfiles)
\r
915 # WX_SPLIT_ARGUMENTS_ON(OPTIONS wxrc_files wxrc_options ${ARGN})
\r
919 # WXWIDGETS_ADD_RESOURCES(sources ${xrc_files} OPTIONS -e -o file.C)
\r
921 # NOTE: This is a generic piece of code that should be renamed to
\r
922 # SPLIT_ARGUMENTS_ON and put in a file serving the same purpose as
\r
923 # FindPackageStandardArgs.cmake. At the time of this writing
\r
924 # FindQt4.cmake has a QT4_EXTRACT_OPTIONS, which I basically copied
\r
925 # here a bit more generalized. So, there are already two find modules
\r
926 # using this approach.
\r
928 function(WX_SPLIT_ARGUMENTS_ON _keyword _leftvar _rightvar)
\r
929 # FIXME: Document that the input variables will be cleared.
\r
930 #list(APPEND ${_leftvar} "")
\r
931 #list(APPEND ${_rightvar} "")
\r
932 set(${_leftvar} "")
\r
933 set(${_rightvar} "")
\r
935 set(_doing_right FALSE)
\r
936 foreach(element ${ARGN})
\r
937 if("${element}" STREQUAL "${_keyword}")
\r
938 set(_doing_right TRUE)
\r
941 list(APPEND ${_rightvar} "${element}")
\r
943 list(APPEND ${_leftvar} "${element}")
\r
948 set(${_leftvar} ${${_leftvar}} PARENT_SCOPE)
\r
949 set(${_rightvar} ${${_rightvar}} PARENT_SCOPE)
\r
953 # WX_GET_DEPENDENCIES_FROM_XML(
\r
961 # FIXME: Add documentation here...
\r
963 function(WX_GET_DEPENDENCIES_FROM_XML
\r
971 string(REGEX MATCHALL
\r
974 "${${_xml_contents}}"
\r
976 foreach(dep_file ${dep_file_list})
\r
977 string(REGEX REPLACE ${_clean_patt} "" dep_file "${dep_file}")
\r
979 # make the file have an absolute path
\r
980 if(NOT IS_ABSOLUTE "${dep_file}")
\r
981 set(dep_file "${${_depends_path}}/${dep_file}")
\r
984 # append file to dependency list
\r
985 list(APPEND ${_depends} "${dep_file}")
\r
988 set(${_depends} ${${_depends}} PARENT_SCOPE)
\r
992 # WXWIDGETS_ADD_RESOURCES(<sources> <xrc_files>
\r
993 # OPTIONS <options> [NO_CPP_CODE])
\r
995 # Adds a custom command for resource file compilation of the
\r
996 # <xrc_files> and appends the output files to <sources>.
\r
999 # WXWIDGETS_ADD_RESOURCES(sources xrc/main_frame.xrc)
\r
1000 # WXWIDGETS_ADD_RESOURCES(sources ${xrc_files} OPTIONS -e -o altname.cxx)
\r
1002 function(WXWIDGETS_ADD_RESOURCES _outfiles)
\r
1003 WX_SPLIT_ARGUMENTS_ON(OPTIONS rc_file_list rc_options ${ARGN})
\r
1005 # Parse files for dependencies.
\r
1006 set(rc_file_list_abs "")
\r
1007 set(rc_depends "")
\r
1008 foreach(rc_file ${rc_file_list})
\r
1009 get_filename_component(depends_path ${rc_file} PATH)
\r
1011 get_filename_component(rc_file_abs ${rc_file} ABSOLUTE)
\r
1012 list(APPEND rc_file_list_abs "${rc_file_abs}")
\r
1014 # All files have absolute paths or paths relative to the location
\r
1016 file(READ "${rc_file_abs}" rc_file_contents)
\r
1018 # get bitmap/bitmap2 files
\r
1019 WX_GET_DEPENDENCIES_FROM_XML(
\r
1028 WX_GET_DEPENDENCIES_FROM_XML(
\r
1036 # get wxIcon files
\r
1037 WX_GET_DEPENDENCIES_FROM_XML(
\r
1039 "<object[^>]*class=\"wxIcon\"[^<]+"
\r
1049 # If NO_CPP_CODE option specified, then produce .xrs file rather
\r
1050 # than a .cpp file (i.e., don't add the default --cpp-code option).
\r
1051 list(FIND rc_options NO_CPP_CODE index)
\r
1052 if(index EQUAL -1)
\r
1053 list(APPEND rc_options --cpp-code)
\r
1054 # wxrc's default output filename for cpp code.
\r
1055 set(outfile resource.cpp)
\r
1057 list(REMOVE_AT rc_options ${index})
\r
1058 # wxrc's default output filename for xrs file.
\r
1059 set(outfile resource.xrs)
\r
1062 # Get output name for use in ADD_CUSTOM_COMMAND.
\r
1063 # - short option scanning
\r
1064 list(FIND rc_options -o index)
\r
1065 if(NOT index EQUAL -1)
\r
1066 math(EXPR filename_index "${index} + 1")
\r
1067 list(GET rc_options ${filename_index} outfile)
\r
1068 #list(REMOVE_AT rc_options ${index} ${filename_index})
\r
1070 # - long option scanning
\r
1071 string(REGEX MATCH "--output=[^;]*" outfile_opt "${rc_options}")
\r
1073 string(REPLACE "--output=" "" outfile "${outfile_opt}")
\r
1075 #string(REGEX REPLACE "--output=[^;]*;?" "" rc_options "${rc_options}")
\r
1076 #string(REGEX REPLACE ";$" "" rc_options "${rc_options}")
\r
1078 if(NOT IS_ABSOLUTE "${outfile}")
\r
1079 set(outfile "${CMAKE_CURRENT_BINARY_DIR}/${outfile}")
\r
1081 add_custom_command(
\r
1082 OUTPUT "${outfile}"
\r
1083 COMMAND ${wxWidgets_wxrc_EXECUTABLE} ${rc_options} ${rc_file_list_abs}
\r
1084 DEPENDS ${rc_file_list_abs} ${rc_depends}
\r
1087 # Add generated header to output file list.
\r
1088 list(FIND rc_options -e short_index)
\r
1089 list(FIND rc_options --extra-cpp-code long_index)
\r
1090 if(NOT short_index EQUAL -1 OR NOT long_index EQUAL -1)
\r
1091 get_filename_component(outfile_ext ${outfile} EXT)
\r
1092 string(REPLACE "${outfile_ext}" ".h" outfile_header "${outfile}")
\r
1093 list(APPEND ${_outfiles} "${outfile_header}")
\r
1094 set_source_files_properties(
\r
1095 "${outfile_header}" PROPERTIES GENERATED TRUE
\r
1099 # Add generated file to output file list.
\r
1100 list(APPEND ${_outfiles} "${outfile}")
\r
1102 set(${_outfiles} ${${_outfiles}} PARENT_SCOPE)
\r