1 # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 # file Copyright.txt or https://cmake.org/licensing for details.
4 #[=======================================================================[.rst:
10 Replaced by :module:`FindwxWidgets`.
12 Find wxWindows (wxWidgets) installation
14 This module finds if wxWindows/wxWidgets is installed and determines
15 where the include files and libraries are. It also determines what
16 the name of the library is. This code sets the following variables:
20 WXWINDOWS_FOUND = system has WxWindows
21 WXWINDOWS_LIBRARIES = path to the wxWindows libraries
22 on Unix/Linux with additional
25 CMAKE_WXWINDOWS_CXX_FLAGS = Compiler flags for wxWindows,
26 essentially "`wx-config --cxxflags`"
28 WXWINDOWS_INCLUDE_DIR = where to find "wx/wx.h" and "wx/setup.h"
29 WXWINDOWS_LINK_DIRECTORIES = link directories, useful for rpath on
31 WXWINDOWS_DEFINITIONS = extra defines
35 OPTIONS If you need OpenGL support please
39 set(WXWINDOWS_USE_GL 1)
41 in your CMakeLists.txt *before* you include this file.
45 HAVE_ISYSTEM - true required to replace -I by -isystem on g++
49 For convenience include Use_wxWindows.cmake in your project's
51 include(${CMAKE_CURRENT_LIST_DIR}/Use_wxWindows.cmake).
57 set(WXWINDOWS_USE_GL 1)
58 find_package(wxWindows)
62 NOTES wxWidgets 2.6.x is supported for monolithic builds e.g.
63 compiled in wx/build/msw dir as:
67 nmake -f makefile.vc BUILD=debug SHARED=0 USE_OPENGL=1 MONOLITHIC=1
78 WXWINDOWS_INCLUDE_PATH
82 AUTHOR Jan Woetzel (07/2003-01/2006)
83 #]=======================================================================]
85 # ------------------------------------------------------------------
87 # -removed OPTION for CMAKE_WXWINDOWS_USE_GL. Force the developer to SET it before calling this.
88 # -major update for wx 2.6.2 and monolithic build option. (10/2005)
92 # cmake 1.6.7, Linux (Suse 7.3), wxWindows 2.4.0, gcc 2.95
93 # cmake 1.6.7, Linux (Suse 8.2), wxWindows 2.4.0, gcc 3.3
94 # cmake 1.6.7, Linux (Suse 8.2), wxWindows 2.4.1-patch1, gcc 3.3
95 # cmake 1.6.7, MS Windows XP home, wxWindows 2.4.1, MS Visual Studio .net 7 2002 (static build)
96 # cmake 2.0.5 on Windows XP and Suse Linux 9.2
97 # cmake 2.0.6 on Windows XP and Suse Linux 9.2, wxWidgets 2.6.2 MONOLITHIC build
98 # cmake 2.2.2 on Windows XP, MS Visual Studio .net 2003 7.1 wxWidgets 2.6.2 MONOLITHIC build
101 # -OPTION for unicode builds
102 # -further testing of DLL linking under MS WIN32
103 # -better support for non-monolithic builds
108 set(WIN32_STYLE_FIND 1)
111 set(WIN32_STYLE_FIND 0)
112 set(UNIX_STYLE_FIND 1)
115 set(UNIX_STYLE_FIND 1)
121 ## ######################################################################
125 ## candidates for root/base directory of wxwindows
126 ## should have subdirs include and lib containing include/wx/wx.h
127 ## fix the root dir to avoid mixing of headers/libs from different
130 ## WX supports monolithic and multiple smaller libs (since 2.5.x), we prefer monolithic for now.
131 ## monolithic = WX is built as a single big library
132 ## e.g. compile on WIN32 as "nmake -f makefile.vc MONOLITHIC=1 BUILD=debug SHARED=0 USE_OPENGL=1" (JW)
133 option(WXWINDOWS_USE_MONOLITHIC "Use monolithic build of WX??" ON)
134 mark_as_advanced(WXWINDOWS_USE_MONOLITHIC)
137 option(WXWINDOWS_USE_GL "Use Wx with GL support(glcanvas)?" ON)
138 mark_as_advanced(WXWINDOWS_USE_GL)
141 ## avoid mixing of headers and libs between multiple installed WX versions,
142 ## select just one tree here:
143 find_path(WXWINDOWS_ROOT_DIR include/wx/wx.h
146 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\wxWidgets_is1;Inno Setup: App Path]" ## WX 2.6.x
147 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\wxWindows_is1;Inno Setup: App Path]" ## WX 2.4.x
156 # message("DBG found WXWINDOWS_ROOT_DIR: ${WXWINDOWS_ROOT_DIR}")
159 ## find libs for combination of static/shared with release/debug
160 ## be careful if you add something here,
161 ## avoid mixing of headers and libs of different wx versions,
162 ## there may be multiple WX versions installed.
163 set (WXWINDOWS_POSSIBLE_LIB_PATHS
164 "${WXWINDOWS_ROOT_DIR}/lib"
168 if (WXWINDOWS_USE_MONOLITHIC)
170 find_library(WXWINDOWS_STATIC_LIBRARY
171 NAMES wx wxmsw wxmsw26
173 "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
174 ${WXWINDOWS_POSSIBLE_LIB_PATHS}
175 DOC "wxWindows static release build library" )
177 find_library(WXWINDOWS_STATIC_DEBUG_LIBRARY
178 NAMES wxd wxmswd wxmsw26d
180 "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
181 ${WXWINDOWS_POSSIBLE_LIB_PATHS}
182 DOC "wxWindows static debug build library" )
184 find_library(WXWINDOWS_SHARED_LIBRARY
185 NAMES wxmsw26 wxmsw262 wxmsw24 wxmsw242 wxmsw241 wxmsw240 wx23_2 wx22_9
187 "${WXWINDOWS_ROOT_DIR}/lib/vc_dll"
188 ${WXWINDOWS_POSSIBLE_LIB_PATHS}
189 DOC "wxWindows shared release build library" )
191 find_library(WXWINDOWS_SHARED_DEBUG_LIBRARY
192 NAMES wxmsw26d wxmsw262d wxmsw24d wxmsw241d wxmsw240d wx23_2d wx22_9d
194 "${WXWINDOWS_ROOT_DIR}/lib/vc_dll"
195 ${WXWINDOWS_POSSIBLE_LIB_PATHS}
196 DOC "wxWindows shared debug build library " )
200 ## required for WXWINDOWS_USE_GL
201 ## gl lib is always build separate:
203 find_library(WXWINDOWS_STATIC_LIBRARY_GL
204 NAMES wx_gl wxmsw_gl wxmsw26_gl
206 "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
207 ${WXWINDOWS_POSSIBLE_LIB_PATHS}
208 DOC "wxWindows static release build GL library" )
210 find_library(WXWINDOWS_STATIC_DEBUG_LIBRARY_GL
211 NAMES wxd_gl wxmswd_gl wxmsw26d_gl
213 "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
214 ${WXWINDOWS_POSSIBLE_LIB_PATHS}
215 DOC "wxWindows static debug build GL library" )
218 find_library(WXWINDOWS_STATIC_DEBUG_LIBRARY_PNG
221 "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
222 ${WXWINDOWS_POSSIBLE_LIB_PATHS}
223 DOC "wxWindows static debug png library" )
225 find_library(WXWINDOWS_STATIC_LIBRARY_PNG
228 "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
229 ${WXWINDOWS_POSSIBLE_LIB_PATHS}
230 DOC "wxWindows static png library" )
232 find_library(WXWINDOWS_STATIC_DEBUG_LIBRARY_TIFF
235 "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
236 ${WXWINDOWS_POSSIBLE_LIB_PATHS}
237 DOC "wxWindows static debug tiff library" )
239 find_library(WXWINDOWS_STATIC_LIBRARY_TIFF
242 "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
243 ${WXWINDOWS_POSSIBLE_LIB_PATHS}
244 DOC "wxWindows static tiff library" )
246 find_library(WXWINDOWS_STATIC_DEBUG_LIBRARY_JPEG
249 "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
250 ${WXWINDOWS_POSSIBLE_LIB_PATHS}
251 DOC "wxWindows static debug jpeg library" )
253 find_library(WXWINDOWS_STATIC_LIBRARY_JPEG
256 "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
257 ${WXWINDOWS_POSSIBLE_LIB_PATHS}
258 DOC "wxWindows static jpeg library" )
260 find_library(WXWINDOWS_STATIC_DEBUG_LIBRARY_ZLIB
263 "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
264 ${WXWINDOWS_POSSIBLE_LIB_PATHS}
265 DOC "wxWindows static debug zlib library" )
267 find_library(WXWINDOWS_STATIC_LIBRARY_ZLIB
270 "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
271 ${WXWINDOWS_POSSIBLE_LIB_PATHS}
272 DOC "wxWindows static zib library" )
274 find_library(WXWINDOWS_STATIC_DEBUG_LIBRARY_REGEX
277 "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
278 ${WXWINDOWS_POSSIBLE_LIB_PATHS}
279 DOC "wxWindows static debug regex library" )
281 find_library(WXWINDOWS_STATIC_LIBRARY_REGEX
284 "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
285 ${WXWINDOWS_POSSIBLE_LIB_PATHS}
286 DOC "wxWindows static regex library" )
291 find_library(WXWINDOWS_SHARED_LIBRARY_GL
292 NAMES wx_gl wxmsw_gl wxmsw26_gl
294 "${WXWINDOWS_ROOT_DIR}/lib/vc_dll"
295 ${WXWINDOWS_POSSIBLE_LIB_PATHS}
296 DOC "wxWindows shared release build GL library" )
298 find_library(WXWINDOWS_SHARED_DEBUG_LIBRARY_GL
299 NAMES wxd_gl wxmswd_gl wxmsw26d_gl
301 "${WXWINDOWS_ROOT_DIR}/lib/vc_dll"
302 ${WXWINDOWS_POSSIBLE_LIB_PATHS}
303 DOC "wxWindows shared debug build GL library" )
307 ## WX is built as multiple small pieces libraries instead of monolithic
309 ## DEPRECATED (jw) replaced by more general WXWINDOWS_USE_MONOLITHIC ON/OFF
310 # option(WXWINDOWS_SEPARATE_LIBS_BUILD "Is wxWindows build with separate libs?" OFF)
312 ## HACK: This is very dirty.
313 ## because the libs of a particular version are explicitly listed
314 ## and NOT searched/verified.
315 ## TODO: Really search for each lib, then decide for
316 ## monolithic x debug x shared x GL (=16 combinations) for at least 18 libs
317 ## --> about 288 combinations
318 ## thus we need a different approach so solve this correctly ...
320 message(STATUS "Warning: You are trying to use wxWidgets without monolithic build (WXWINDOWS_SEPARATE_LIBS_BUILD). This is a HACK, libraries are not verified! (JW).")
322 set(WXWINDOWS_STATIC_LIBS ${WXWINDOWS_STATIC_LIBS}
345 ## HACK: feed in to optimized / debug libraries if both were FOUND.
346 set(WXWINDOWS_STATIC_DEBUG_LIBS ${WXWINDOWS_STATIC_DEBUG_LIBS}
373 ## now we should have found all WX libs available on the system.
374 ## let the user decide which of the available onse to use.
377 ## if there is at least one shared lib available
378 ## let user choose whether to use shared or static wxwindows libs
379 if(WXWINDOWS_SHARED_LIBRARY OR WXWINDOWS_SHARED_DEBUG_LIBRARY)
380 ## default value OFF because wxWindows MSVS default build is static
381 option(WXWINDOWS_USE_SHARED_LIBS
382 "Use shared versions (dll) of wxWindows libraries?" OFF)
383 mark_as_advanced(WXWINDOWS_USE_SHARED_LIBS)
386 ## add system libraries wxwindows always seems to depend on
387 set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
393 if (NOT WXWINDOWS_USE_SHARED_LIBS)
394 set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
395 ## these ones don't seem required, in particular ctl3d32 is not necessary (Jan Woetzel 07/2003)
397 debug ${WXWINDOWS_STATIC_DEBUG_LIBRARY_ZLIB} optimized ${WXWINDOWS_STATIC_LIBRARY_ZLIB}
398 debug ${WXWINDOWS_STATIC_DEBUG_LIBRARY_REGEX} optimized ${WXWINDOWS_STATIC_LIBRARY_REGEX}
399 debug ${WXWINDOWS_STATIC_DEBUG_LIBRARY_PNG} optimized ${WXWINDOWS_STATIC_LIBRARY_PNG}
400 debug ${WXWINDOWS_STATIC_DEBUG_LIBRARY_JPEG} optimized ${WXWINDOWS_STATIC_LIBRARY_JPEG}
401 debug ${WXWINDOWS_STATIC_DEBUG_LIBRARY_TIFF} optimized ${WXWINDOWS_STATIC_LIBRARY_TIFF}
405 ## opengl/glu: TODO/FIXME: better use FindOpenGL.cmake here
406 ## assume release versions of glu an dopengl, here.
407 if (WXWINDOWS_USE_GL)
408 set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
414 ## select between use of shared or static wxWindows lib then set libs to use
415 ## for debug and optimized build. so the user can switch between debug and
416 ## release build e.g. within MS Visual Studio without running cmake with a
417 ## different build directory again.
419 ## then add the build specific include dir for wx/setup.h
422 if(WXWINDOWS_USE_SHARED_LIBS)
423 ##message("DBG wxWindows use shared lib selected.")
424 ## assume that both builds use the same setup(.h) for simplicity
426 ## shared: both wx (debug and release) found?
427 ## assume that both builds use the same setup(.h) for simplicity
428 if(WXWINDOWS_SHARED_DEBUG_LIBRARY AND WXWINDOWS_SHARED_LIBRARY)
429 ##message("DBG wx shared: debug and optimized found.")
430 find_path(WXWINDOWS_INCLUDE_DIR_SETUPH wx/setup.h
431 ${WXWINDOWS_ROOT_DIR}/lib/mswdlld
432 ${WXWINDOWS_ROOT_DIR}/lib/mswdll
433 ${WXWINDOWS_ROOT_DIR}/lib/vc_dll/mswd
434 ${WXWINDOWS_ROOT_DIR}/lib/vc_dll/msw )
435 set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
436 debug ${WXWINDOWS_SHARED_DEBUG_LIBRARY}
437 optimized ${WXWINDOWS_SHARED_LIBRARY} )
438 if (WXWINDOWS_USE_GL)
439 set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
440 debug ${WXWINDOWS_SHARED_DEBUG_LIBRARY_GL}
441 optimized ${WXWINDOWS_SHARED_LIBRARY_GL} )
445 ## shared: only debug wx lib found?
446 if(WXWINDOWS_SHARED_DEBUG_LIBRARY)
447 if(NOT WXWINDOWS_SHARED_LIBRARY)
448 ##message("DBG wx shared: debug (but no optimized) found.")
449 find_path(WXWINDOWS_INCLUDE_DIR_SETUPH wx/setup.h
450 ${WXWINDOWS_ROOT_DIR}/lib/mswdlld
451 ${WXWINDOWS_ROOT_DIR}/lib/vc_dll/mswd )
452 set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
453 ${WXWINDOWS_SHARED_DEBUG_LIBRARY} )
454 if (WXWINDOWS_USE_GL)
455 set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
456 ${WXWINDOWS_SHARED_DEBUG_LIBRARY_GL} )
461 ## shared: only release wx lib found?
462 if(NOT WXWINDOWS_SHARED_DEBUG_LIBRARY)
463 if(WXWINDOWS_SHARED_LIBRARY)
464 ##message("DBG wx shared: optimized (but no debug) found.")
465 find_path(WXWINDOWS_INCLUDE_DIR_SETUPH wx/setup.h
466 ${WXWINDOWS_ROOT_DIR}/lib/mswdll
467 ${WXWINDOWS_ROOT_DIR}/lib/vc_dll/msw )
468 set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
469 ${WXWINDOWS_SHARED_DEBUG_LIBRARY} )
470 if (WXWINDOWS_USE_GL)
471 set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
472 ${WXWINDOWS_SHARED_DEBUG_LIBRARY_GL} )
477 ## shared: none found?
478 if(NOT WXWINDOWS_SHARED_DEBUG_LIBRARY)
479 if(NOT WXWINDOWS_SHARED_LIBRARY)
481 "No shared wxWindows lib found, but WXWINDOWS_USE_SHARED_LIBS=${WXWINDOWS_USE_SHARED_LIBS}.")
485 #########################################################################################
488 ##jw: DEPRECATED if(NOT WXWINDOWS_SEPARATE_LIBS_BUILD)
490 ## static: both wx (debug and release) found?
491 ## assume that both builds use the same setup(.h) for simplicity
492 if(WXWINDOWS_STATIC_DEBUG_LIBRARY AND WXWINDOWS_STATIC_LIBRARY)
493 ##message("DBG wx static: debug and optimized found.")
494 find_path(WXWINDOWS_INCLUDE_DIR_SETUPH wx/setup.h
495 ${WXWINDOWS_ROOT_DIR}/lib/mswd
496 ${WXWINDOWS_ROOT_DIR}/lib/msw
497 ${WXWINDOWS_ROOT_DIR}/lib/vc_lib/mswd
498 ${WXWINDOWS_ROOT_DIR}/lib/vc_lib/msw )
499 set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
500 debug ${WXWINDOWS_STATIC_DEBUG_LIBRARY}
501 optimized ${WXWINDOWS_STATIC_LIBRARY} )
502 if (WXWINDOWS_USE_GL)
503 set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
504 debug ${WXWINDOWS_STATIC_DEBUG_LIBRARY_GL}
505 optimized ${WXWINDOWS_STATIC_LIBRARY_GL} )
509 ## static: only debug wx lib found?
510 if(WXWINDOWS_STATIC_DEBUG_LIBRARY)
511 if(NOT WXWINDOWS_STATIC_LIBRARY)
512 ##message("DBG wx static: debug (but no optimized) found.")
513 find_path(WXWINDOWS_INCLUDE_DIR_SETUPH wx/setup.h
514 ${WXWINDOWS_ROOT_DIR}/lib/mswd
515 ${WXWINDOWS_ROOT_DIR}/lib/vc_lib/mswd )
516 set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
517 ${WXWINDOWS_STATIC_DEBUG_LIBRARY} )
518 if (WXWINDOWS_USE_GL)
519 set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
520 ${WXWINDOWS_STATIC_DEBUG_LIBRARY_GL} )
525 ## static: only release wx lib found?
526 if(NOT WXWINDOWS_STATIC_DEBUG_LIBRARY)
527 if(WXWINDOWS_STATIC_LIBRARY)
528 ##message("DBG wx static: optimized (but no debug) found.")
529 find_path(WXWINDOWS_INCLUDE_DIR_SETUPH wx/setup.h
530 ${WXWINDOWS_ROOT_DIR}/lib/msw
531 ${WXWINDOWS_ROOT_DIR}/lib/vc_lib/msw )
532 set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
533 ${WXWINDOWS_STATIC_LIBRARY} )
534 if (WXWINDOWS_USE_GL)
535 set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
536 ${WXWINDOWS_STATIC_LIBRARY_GL} )
541 ## static: none found?
542 if(NOT WXWINDOWS_STATIC_DEBUG_LIBRARY AND NOT WXWINDOWS_SEPARATE_LIBS_BUILD)
543 if(NOT WXWINDOWS_STATIC_LIBRARY)
545 "No static wxWindows lib found, but WXWINDOWS_USE_SHARED_LIBS=${WXWINDOWS_USE_SHARED_LIBS}.")
551 ## not necessary in wxWindows 2.4.1 and 2.6.2
552 ## but it may fix a previous bug, see
553 ## http://lists.wxwindows.org/cgi-bin/ezmlm-cgi?8:mss:37574:200305:mpdioeneabobmgjenoap
554 option(WXWINDOWS_SET_DEFINITIONS "Set additional defines for wxWindows" OFF)
555 mark_as_advanced(WXWINDOWS_SET_DEFINITIONS)
556 if (WXWINDOWS_SET_DEFINITIONS)
557 set(WXWINDOWS_DEFINITIONS "-DWINVER=0x400")
560 set(WXWINDOWS_DEFINITIONS "")
565 ## Find the include directories for wxwindows
566 ## the first, build specific for wx/setup.h was determined before.
567 ## add inc dir for general for "wx/wx.h"
568 find_path(WXWINDOWS_INCLUDE_DIR wx/wx.h
569 "${WXWINDOWS_ROOT_DIR}/include" )
570 ## append the build specific include dir for wx/setup.h:
571 if (WXWINDOWS_INCLUDE_DIR_SETUPH)
572 set(WXWINDOWS_INCLUDE_DIR ${WXWINDOWS_INCLUDE_DIR} ${WXWINDOWS_INCLUDE_DIR_SETUPH} )
579 WXWINDOWS_INCLUDE_DIR
580 WXWINDOWS_INCLUDE_DIR_SETUPH
581 WXWINDOWS_STATIC_LIBRARY
582 WXWINDOWS_STATIC_LIBRARY_GL
583 WXWINDOWS_STATIC_DEBUG_LIBRARY
584 WXWINDOWS_STATIC_DEBUG_LIBRARY_GL
585 WXWINDOWS_STATIC_LIBRARY_ZLIB
586 WXWINDOWS_STATIC_DEBUG_LIBRARY_ZLIB
587 WXWINDOWS_STATIC_LIBRARY_REGEX
588 WXWINDOWS_STATIC_DEBUG_LIBRARY_REGEX
589 WXWINDOWS_STATIC_LIBRARY_PNG
590 WXWINDOWS_STATIC_DEBUG_LIBRARY_PNG
591 WXWINDOWS_STATIC_LIBRARY_JPEG
592 WXWINDOWS_STATIC_DEBUG_LIBRARY_JPEG
593 WXWINDOWS_STATIC_DEBUG_LIBRARY_TIFF
594 WXWINDOWS_STATIC_LIBRARY_TIFF
595 WXWINDOWS_SHARED_LIBRARY
596 WXWINDOWS_SHARED_DEBUG_LIBRARY
597 WXWINDOWS_SHARED_LIBRARY_GL
598 WXWINDOWS_SHARED_DEBUG_LIBRARY_GL
605 ## ######################################################################
607 ## UNIX/Linux specific:
609 ## use backquoted wx-config to query and set flags and libs:
610 ## 06/2003 Jan Woetzel
613 option(WXWINDOWS_USE_SHARED_LIBS "Use shared versions (.so) of wxWindows libraries" ON)
614 mark_as_advanced(WXWINDOWS_USE_SHARED_LIBS)
616 # JW removed option and force the developer to SET it.
617 # option(WXWINDOWS_USE_GL "use wxWindows with GL support (use additional
618 # --gl-libs for wx-config)?" OFF)
620 # wx-config should be in your path anyhow, usually no need to set WXWIN or
621 # search in ../wx or ../../wx
622 find_program(CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE
623 NAMES $ENV{WX_CONFIG} wx-config
631 # check whether wx-config was found:
632 if(CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE)
634 # use shared/static wx lib?
635 # remember: always link shared to use systems GL etc. libs (no static
636 # linking, just link *against* static .a libs)
637 if(WXWINDOWS_USE_SHARED_LIBS)
638 set(WX_CONFIG_ARGS_LIBS --libs)
640 set(WX_CONFIG_ARGS_LIBS --static --libs)
643 # do we need additionial wx GL stuff like GLCanvas ?
645 list(APPEND WX_CONFIG_ARGS_LIBS --gl-libs)
647 ##message("DBG: WX_CONFIG_ARGS_LIBS=${WX_CONFIG_ARGS_LIBS}===")
649 # set CXXFLAGS to be fed into CMAKE_CXX_FLAGS by the user:
650 if (HAVE_ISYSTEM) # does the compiler support -isystem ?
651 if (NOT APPLE) # -isystem seems to be unsupported on Mac
652 if(CMAKE_COMPILER_IS_GNUCC AND CMAKE_COMPILER_IS_GNUCXX )
653 if (CMAKE_CXX_COMPILER MATCHES g\\+\\+)
654 set(CMAKE_WXWINDOWS_CXX_FLAGS "`${CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE} --cxxflags|sed -e s/-I/-isystem/g`")
656 set(CMAKE_WXWINDOWS_CXX_FLAGS "`${CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE} --cxxflags`")
661 ##message("DBG: for compilation:
662 ##CMAKE_WXWINDOWS_CXX_FLAGS=${CMAKE_WXWINDOWS_CXX_FLAGS}===")
664 # keep the back-quoted string for clarity
665 string(REPLACE ";" " " _wx_config_args_libs "${WX_CONFIG_ARGS_LIBS}")
666 set(WXWINDOWS_LIBRARIES "`${CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE} ${_wx_config_args_libs}`")
667 ##message("DBG2: for linking:
668 ##WXWINDOWS_LIBRARIES=${WXWINDOWS_LIBRARIES}===")
670 # evaluate wx-config output to separate linker flags and linkdirs for
672 execute_process(COMMAND ${CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE}
673 ${WX_CONFIG_ARGS_LIBS}
674 OUTPUT_VARIABLE WX_CONFIG_LIBS )
676 ## extract linkdirs (-L) for rpath
677 ## use regular expression to match wildcard equivalent "-L*<endchar>"
678 ## with <endchar> is a space or a semicolon
679 string(REGEX MATCHALL "[-][L]([^ ;])+" WXWINDOWS_LINK_DIRECTORIES_WITH_PREFIX "${WX_CONFIG_LIBS}" )
680 # message("DBG WXWINDOWS_LINK_DIRECTORIES_WITH_PREFIX=${WXWINDOWS_LINK_DIRECTORIES_WITH_PREFIX}")
682 ## remove prefix -L because we need the pure directory for LINK_DIRECTORIES
683 ## replace -L by ; because the separator seems to be lost otherwise (bug or
685 if(WXWINDOWS_LINK_DIRECTORIES_WITH_PREFIX)
686 string(REGEX REPLACE "[-][L]" ";" WXWINDOWS_LINK_DIRECTORIES ${WXWINDOWS_LINK_DIRECTORIES_WITH_PREFIX} )
687 # message("DBG WXWINDOWS_LINK_DIRECTORIES=${WXWINDOWS_LINK_DIRECTORIES}")
691 ## replace space separated string by semicolon separated vector to make it
692 ## work with LINK_DIRECTORIES
693 separate_arguments(WXWINDOWS_LINK_DIRECTORIES)
696 CMAKE_WXWINDOWS_CXX_FLAGS
697 WXWINDOWS_INCLUDE_DIR
699 CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE
703 ## we really need wx-config...
705 message(STATUS "Cannot find wx-config anywhere on the system. Please put the file into your path or specify it in CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE.")
706 mark_as_advanced(CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE)
712 message(STATUS "FindwxWindows.cmake: Platform unknown/unsupported by FindwxWindows.cmake. It's neither WIN32 nor UNIX")
717 if(WXWINDOWS_LIBRARIES)
718 if(WXWINDOWS_INCLUDE_DIR OR CMAKE_WXWINDOWS_CXX_FLAGS)
719 ## found all we need.
720 set(WXWINDOWS_FOUND 1)
722 ## set deprecated variables for backward compatibility:
723 set(CMAKE_WX_CAN_COMPILE ${WXWINDOWS_FOUND})
724 set(WXWINDOWS_LIBRARY ${WXWINDOWS_LIBRARIES})
725 set(WXWINDOWS_INCLUDE_PATH ${WXWINDOWS_INCLUDE_DIR})
726 set(WXWINDOWS_LINK_DIRECTORIES ${WXWINDOWS_LINK_DIRECTORIES})
727 set(CMAKE_WX_CXX_FLAGS ${CMAKE_WXWINDOWS_CXX_FLAGS})