FindwxWindows.cmake 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  1. #.rst:
  2. # FindwxWindows
  3. # -------------
  4. #
  5. # Find wxWindows (wxWidgets) installation
  6. #
  7. # This module finds if wxWindows/wxWidgets is installed and determines
  8. # where the include files and libraries are. It also determines what
  9. # the name of the library is. Please note this file is DEPRECATED and
  10. # replaced by FindwxWidgets.cmake. This code sets the following
  11. # variables:
  12. #
  13. # ::
  14. #
  15. # WXWINDOWS_FOUND = system has WxWindows
  16. # WXWINDOWS_LIBRARIES = path to the wxWindows libraries
  17. # on Unix/Linux with additional
  18. # linker flags from
  19. # "wx-config --libs"
  20. # CMAKE_WXWINDOWS_CXX_FLAGS = Compiler flags for wxWindows,
  21. # essentially "`wx-config --cxxflags`"
  22. # on Linux
  23. # WXWINDOWS_INCLUDE_DIR = where to find "wx/wx.h" and "wx/setup.h"
  24. # WXWINDOWS_LINK_DIRECTORIES = link directories, useful for rpath on
  25. # Unix
  26. # WXWINDOWS_DEFINITIONS = extra defines
  27. #
  28. #
  29. #
  30. # OPTIONS If you need OpenGL support please
  31. #
  32. # ::
  33. #
  34. # set(WXWINDOWS_USE_GL 1)
  35. #
  36. # in your CMakeLists.txt *before* you include this file.
  37. #
  38. # ::
  39. #
  40. # HAVE_ISYSTEM - true required to replace -I by -isystem on g++
  41. #
  42. #
  43. #
  44. # For convenience include Use_wxWindows.cmake in your project's
  45. # CMakeLists.txt using
  46. # include(${CMAKE_CURRENT_LIST_DIR}/Use_wxWindows.cmake).
  47. #
  48. # USAGE
  49. #
  50. # ::
  51. #
  52. # set(WXWINDOWS_USE_GL 1)
  53. # find_package(wxWindows)
  54. #
  55. #
  56. #
  57. # NOTES wxWidgets 2.6.x is supported for monolithic builds e.g.
  58. # compiled in wx/build/msw dir as:
  59. #
  60. # ::
  61. #
  62. # nmake -f makefile.vc BUILD=debug SHARED=0 USE_OPENGL=1 MONOLITHIC=1
  63. #
  64. #
  65. #
  66. # DEPRECATED
  67. #
  68. # ::
  69. #
  70. # CMAKE_WX_CAN_COMPILE
  71. # WXWINDOWS_LIBRARY
  72. # CMAKE_WX_CXX_FLAGS
  73. # WXWINDOWS_INCLUDE_PATH
  74. #
  75. #
  76. #
  77. # AUTHOR Jan Woetzel <http://www.mip.informatik.uni-kiel.de/~jw>
  78. # (07/2003-01/2006)
  79. #=============================================================================
  80. # Copyright 2000-2009 Kitware, Inc.
  81. # Copyright 2003-2006 Jan Woetzel
  82. #
  83. # Distributed under the OSI-approved BSD License (the "License");
  84. # see accompanying file Copyright.txt for details.
  85. #
  86. # This software is distributed WITHOUT ANY WARRANTY; without even the
  87. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  88. # See the License for more information.
  89. #=============================================================================
  90. # (To distribute this file outside of CMake, substitute the full
  91. # License text for the above reference.)
  92. # ------------------------------------------------------------------
  93. #
  94. # -removed OPTION for CMAKE_WXWINDOWS_USE_GL. Force the developer to SET it before calling this.
  95. # -major update for wx 2.6.2 and monolithic build option. (10/2005)
  96. #
  97. # STATUS
  98. # tested with:
  99. # cmake 1.6.7, Linux (Suse 7.3), wxWindows 2.4.0, gcc 2.95
  100. # cmake 1.6.7, Linux (Suse 8.2), wxWindows 2.4.0, gcc 3.3
  101. # cmake 1.6.7, Linux (Suse 8.2), wxWindows 2.4.1-patch1, gcc 3.3
  102. # cmake 1.6.7, MS Windows XP home, wxWindows 2.4.1, MS Visual Studio .net 7 2002 (static build)
  103. # cmake 2.0.5 on Windows XP and Suse Linux 9.2
  104. # cmake 2.0.6 on Windows XP and Suse Linux 9.2, wxWidgets 2.6.2 MONOLITHIC build
  105. # cmake 2.2.2 on Windows XP, MS Visual Studio .net 2003 7.1 wxWidgets 2.6.2 MONOLITHIC build
  106. #
  107. # TODO
  108. # -OPTION for unicode builds
  109. # -further testing of DLL linking under MS WIN32
  110. # -better support for non-monolithic builds
  111. #
  112. if(WIN32)
  113. set(WIN32_STYLE_FIND 1)
  114. endif()
  115. if(MINGW)
  116. set(WIN32_STYLE_FIND 0)
  117. set(UNIX_STYLE_FIND 1)
  118. endif()
  119. if(UNIX)
  120. set(UNIX_STYLE_FIND 1)
  121. endif()
  122. if(WIN32_STYLE_FIND)
  123. ## ######################################################################
  124. ##
  125. ## Windows specific:
  126. ##
  127. ## candidates for root/base directory of wxwindows
  128. ## should have subdirs include and lib containing include/wx/wx.h
  129. ## fix the root dir to avoid mixing of headers/libs from different
  130. ## versions/builds:
  131. ## WX supports monolithic and multiple smaller libs (since 2.5.x), we prefer monolithic for now.
  132. ## monolithic = WX is built as a single big library
  133. ## e.g. compile on WIN32 as "nmake -f makefile.vc MONOLITHIC=1 BUILD=debug SHARED=0 USE_OPENGL=1" (JW)
  134. option(WXWINDOWS_USE_MONOLITHIC "Use monolithic build of WX??" ON)
  135. mark_as_advanced(WXWINDOWS_USE_MONOLITHIC)
  136. ## GL libs used?
  137. option(WXWINDOWS_USE_GL "Use Wx with GL support(glcanvas)?" ON)
  138. mark_as_advanced(WXWINDOWS_USE_GL)
  139. ## avoid mixing of headers and libs between multiple installed WX versions,
  140. ## select just one tree here:
  141. find_path(WXWINDOWS_ROOT_DIR include/wx/wx.h
  142. HINTS
  143. ENV WXWIN
  144. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\wxWidgets_is1;Inno Setup: App Path]" ## WX 2.6.x
  145. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\wxWindows_is1;Inno Setup: App Path]" ## WX 2.4.x
  146. PATHS
  147. C:/wxWidgets-2.6.2
  148. D:/wxWidgets-2.6.2
  149. C:/wxWidgets-2.6.1
  150. D:/wxWidgets-2.6.1
  151. C:/wxWindows-2.4.2
  152. D:/wxWindows-2.4.2
  153. )
  154. # message("DBG found WXWINDOWS_ROOT_DIR: ${WXWINDOWS_ROOT_DIR}")
  155. ## find libs for combination of static/shared with release/debug
  156. ## be careful if you add something here,
  157. ## avoid mixing of headers and libs of different wx versions,
  158. ## there may be multiple WX versions installed.
  159. set (WXWINDOWS_POSSIBLE_LIB_PATHS
  160. "${WXWINDOWS_ROOT_DIR}/lib"
  161. )
  162. ## monolithic?
  163. if (WXWINDOWS_USE_MONOLITHIC)
  164. find_library(WXWINDOWS_STATIC_LIBRARY
  165. NAMES wx wxmsw wxmsw26
  166. PATHS
  167. "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
  168. ${WXWINDOWS_POSSIBLE_LIB_PATHS}
  169. DOC "wxWindows static release build library" )
  170. find_library(WXWINDOWS_STATIC_DEBUG_LIBRARY
  171. NAMES wxd wxmswd wxmsw26d
  172. PATHS
  173. "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
  174. ${WXWINDOWS_POSSIBLE_LIB_PATHS}
  175. DOC "wxWindows static debug build library" )
  176. find_library(WXWINDOWS_SHARED_LIBRARY
  177. NAMES wxmsw26 wxmsw262 wxmsw24 wxmsw242 wxmsw241 wxmsw240 wx23_2 wx22_9
  178. PATHS
  179. "${WXWINDOWS_ROOT_DIR}/lib/vc_dll"
  180. ${WXWINDOWS_POSSIBLE_LIB_PATHS}
  181. DOC "wxWindows shared release build library" )
  182. find_library(WXWINDOWS_SHARED_DEBUG_LIBRARY
  183. NAMES wxmsw26d wxmsw262d wxmsw24d wxmsw241d wxmsw240d wx23_2d wx22_9d
  184. PATHS
  185. "${WXWINDOWS_ROOT_DIR}/lib/vc_dll"
  186. ${WXWINDOWS_POSSIBLE_LIB_PATHS}
  187. DOC "wxWindows shared debug build library " )
  188. ##
  189. ## required for WXWINDOWS_USE_GL
  190. ## gl lib is always build separate:
  191. ##
  192. find_library(WXWINDOWS_STATIC_LIBRARY_GL
  193. NAMES wx_gl wxmsw_gl wxmsw26_gl
  194. PATHS
  195. "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
  196. ${WXWINDOWS_POSSIBLE_LIB_PATHS}
  197. DOC "wxWindows static release build GL library" )
  198. find_library(WXWINDOWS_STATIC_DEBUG_LIBRARY_GL
  199. NAMES wxd_gl wxmswd_gl wxmsw26d_gl
  200. PATHS
  201. "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
  202. ${WXWINDOWS_POSSIBLE_LIB_PATHS}
  203. DOC "wxWindows static debug build GL library" )
  204. find_library(WXWINDOWS_STATIC_DEBUG_LIBRARY_PNG
  205. NAMES wxpngd
  206. PATHS
  207. "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
  208. ${WXWINDOWS_POSSIBLE_LIB_PATHS}
  209. DOC "wxWindows static debug png library" )
  210. find_library(WXWINDOWS_STATIC_LIBRARY_PNG
  211. NAMES wxpng
  212. PATHS
  213. "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
  214. ${WXWINDOWS_POSSIBLE_LIB_PATHS}
  215. DOC "wxWindows static png library" )
  216. find_library(WXWINDOWS_STATIC_DEBUG_LIBRARY_TIFF
  217. NAMES wxtiffd
  218. PATHS
  219. "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
  220. ${WXWINDOWS_POSSIBLE_LIB_PATHS}
  221. DOC "wxWindows static debug tiff library" )
  222. find_library(WXWINDOWS_STATIC_LIBRARY_TIFF
  223. NAMES wxtiff
  224. PATHS
  225. "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
  226. ${WXWINDOWS_POSSIBLE_LIB_PATHS}
  227. DOC "wxWindows static tiff library" )
  228. find_library(WXWINDOWS_STATIC_DEBUG_LIBRARY_JPEG
  229. NAMES wxjpegd wxjpgd
  230. PATHS
  231. "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
  232. ${WXWINDOWS_POSSIBLE_LIB_PATHS}
  233. DOC "wxWindows static debug jpeg library" )
  234. find_library(WXWINDOWS_STATIC_LIBRARY_JPEG
  235. NAMES wxjpeg wxjpg
  236. PATHS
  237. "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
  238. ${WXWINDOWS_POSSIBLE_LIB_PATHS}
  239. DOC "wxWindows static jpeg library" )
  240. find_library(WXWINDOWS_STATIC_DEBUG_LIBRARY_ZLIB
  241. NAMES wxzlibd
  242. PATHS
  243. "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
  244. ${WXWINDOWS_POSSIBLE_LIB_PATHS}
  245. DOC "wxWindows static debug zlib library" )
  246. find_library(WXWINDOWS_STATIC_LIBRARY_ZLIB
  247. NAMES wxzlib
  248. PATHS
  249. "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
  250. ${WXWINDOWS_POSSIBLE_LIB_PATHS}
  251. DOC "wxWindows static zib library" )
  252. find_library(WXWINDOWS_STATIC_DEBUG_LIBRARY_REGEX
  253. NAMES wxregexd
  254. PATHS
  255. "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
  256. ${WXWINDOWS_POSSIBLE_LIB_PATHS}
  257. DOC "wxWindows static debug regex library" )
  258. find_library(WXWINDOWS_STATIC_LIBRARY_REGEX
  259. NAMES wxregex
  260. PATHS
  261. "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
  262. ${WXWINDOWS_POSSIBLE_LIB_PATHS}
  263. DOC "wxWindows static regex library" )
  264. ## untested:
  265. find_library(WXWINDOWS_SHARED_LIBRARY_GL
  266. NAMES wx_gl wxmsw_gl wxmsw26_gl
  267. PATHS
  268. "${WXWINDOWS_ROOT_DIR}/lib/vc_dll"
  269. ${WXWINDOWS_POSSIBLE_LIB_PATHS}
  270. DOC "wxWindows shared release build GL library" )
  271. find_library(WXWINDOWS_SHARED_DEBUG_LIBRARY_GL
  272. NAMES wxd_gl wxmswd_gl wxmsw26d_gl
  273. PATHS
  274. "${WXWINDOWS_ROOT_DIR}/lib/vc_dll"
  275. ${WXWINDOWS_POSSIBLE_LIB_PATHS}
  276. DOC "wxWindows shared debug build GL library" )
  277. else ()
  278. ## WX is built as multiple small pieces libraries instead of monolithic
  279. ## DEPECATED (jw) replaced by more general WXWINDOWS_USE_MONOLITHIC ON/OFF
  280. # option(WXWINDOWS_SEPARATE_LIBS_BUILD "Is wxWindows build with separate libs?" OFF)
  281. ## HACK: This is very dirty.
  282. ## because the libs of a particular version are explicitly listed
  283. ## and NOT searched/verified.
  284. ## TODO: Really search for each lib, then decide for
  285. ## monolithic x debug x shared x GL (=16 combinations) for at least 18 libs
  286. ## --> about 288 combinations
  287. ## thus we need a different approach so solve this correctly ...
  288. 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).")
  289. set(WXWINDOWS_STATIC_LIBS ${WXWINDOWS_STATIC_LIBS}
  290. wxbase26
  291. wxbase26_net
  292. wxbase26_odbc
  293. wxbase26_xml
  294. wxmsw26_adv
  295. wxmsw26_core
  296. wxmsw26_dbgrid
  297. wxmsw26_gl
  298. wxmsw26_html
  299. wxmsw26_media
  300. wxmsw26_qa
  301. wxmsw26_xrc
  302. wxexpat
  303. wxjpeg
  304. wxpng
  305. wxregex
  306. wxtiff
  307. wxzlib
  308. comctl32
  309. rpcrt4
  310. wsock32
  311. )
  312. ## HACK: feed in to optimized / debug libraries if both were FOUND.
  313. set(WXWINDOWS_STATIC_DEBUG_LIBS ${WXWINDOWS_STATIC_DEBUG_LIBS}
  314. wxbase26d
  315. wxbase26d_net
  316. wxbase26d_odbc
  317. wxbase26d_xml
  318. wxmsw26d_adv
  319. wxmsw26d_core
  320. wxmsw26d_dbgrid
  321. wxmsw26d_gl
  322. wxmsw26d_html
  323. wxmsw26d_media
  324. wxmsw26d_qa
  325. wxmsw26d_xrc
  326. wxexpatd
  327. wxjpegd
  328. wxpngd
  329. wxregexd
  330. wxtiffd
  331. wxzlibd
  332. comctl32
  333. rpcrt4
  334. wsock32
  335. )
  336. endif ()
  337. ##
  338. ## now we should have found all WX libs available on the system.
  339. ## let the user decide which of the available onse to use.
  340. ##
  341. ## if there is at least one shared lib available
  342. ## let user choose whether to use shared or static wxwindows libs
  343. if(WXWINDOWS_SHARED_LIBRARY OR WXWINDOWS_SHARED_DEBUG_LIBRARY)
  344. ## default value OFF because wxWindows MSVS default build is static
  345. option(WXWINDOWS_USE_SHARED_LIBS
  346. "Use shared versions (dll) of wxWindows libraries?" OFF)
  347. mark_as_advanced(WXWINDOWS_USE_SHARED_LIBS)
  348. endif()
  349. ## add system libraries wxwindows always seems to depend on
  350. set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
  351. comctl32
  352. rpcrt4
  353. wsock32
  354. )
  355. if (NOT WXWINDOWS_USE_SHARED_LIBS)
  356. set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
  357. ## these ones dont seem required, in particular ctl3d32 is not neccesary (Jan Woetzel 07/2003)
  358. # ctl3d32
  359. debug ${WXWINDOWS_STATIC_DEBUG_LIBRARY_ZLIB} optimized ${WXWINDOWS_STATIC_LIBRARY_ZLIB}
  360. debug ${WXWINDOWS_STATIC_DEBUG_LIBRARY_REGEX} optimized ${WXWINDOWS_STATIC_LIBRARY_REGEX}
  361. debug ${WXWINDOWS_STATIC_DEBUG_LIBRARY_PNG} optimized ${WXWINDOWS_STATIC_LIBRARY_PNG}
  362. debug ${WXWINDOWS_STATIC_DEBUG_LIBRARY_JPEG} optimized ${WXWINDOWS_STATIC_LIBRARY_JPEG}
  363. debug ${WXWINDOWS_STATIC_DEBUG_LIBRARY_TIFF} optimized ${WXWINDOWS_STATIC_LIBRARY_TIFF}
  364. )
  365. endif ()
  366. ## opengl/glu: TODO/FIXME: better use FindOpenGL.cmake here
  367. ## assume release versions of glu an dopengl, here.
  368. if (WXWINDOWS_USE_GL)
  369. set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
  370. opengl32
  371. glu32 )
  372. endif ()
  373. ##
  374. ## select between use of shared or static wxWindows lib then set libs to use
  375. ## for debug and optimized build. so the user can switch between debug and
  376. ## release build e.g. within MS Visual Studio without running cmake with a
  377. ## different build directory again.
  378. ##
  379. ## then add the build specific include dir for wx/setup.h
  380. ##
  381. if(WXWINDOWS_USE_SHARED_LIBS)
  382. ##message("DBG wxWindows use shared lib selected.")
  383. ## assume that both builds use the same setup(.h) for simplicity
  384. ## shared: both wx (debug and release) found?
  385. ## assume that both builds use the same setup(.h) for simplicity
  386. if(WXWINDOWS_SHARED_DEBUG_LIBRARY AND WXWINDOWS_SHARED_LIBRARY)
  387. ##message("DBG wx shared: debug and optimized found.")
  388. find_path(WXWINDOWS_INCLUDE_DIR_SETUPH wx/setup.h
  389. ${WXWINDOWS_ROOT_DIR}/lib/mswdlld
  390. ${WXWINDOWS_ROOT_DIR}/lib/mswdll
  391. ${WXWINDOWS_ROOT_DIR}/lib/vc_dll/mswd
  392. ${WXWINDOWS_ROOT_DIR}/lib/vc_dll/msw )
  393. set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
  394. debug ${WXWINDOWS_SHARED_DEBUG_LIBRARY}
  395. optimized ${WXWINDOWS_SHARED_LIBRARY} )
  396. if (WXWINDOWS_USE_GL)
  397. set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
  398. debug ${WXWINDOWS_SHARED_DEBUG_LIBRARY_GL}
  399. optimized ${WXWINDOWS_SHARED_LIBRARY_GL} )
  400. endif ()
  401. endif()
  402. ## shared: only debug wx lib found?
  403. if(WXWINDOWS_SHARED_DEBUG_LIBRARY)
  404. if(NOT WXWINDOWS_SHARED_LIBRARY)
  405. ##message("DBG wx shared: debug (but no optimized) found.")
  406. find_path(WXWINDOWS_INCLUDE_DIR_SETUPH wx/setup.h
  407. ${WXWINDOWS_ROOT_DIR}/lib/mswdlld
  408. ${WXWINDOWS_ROOT_DIR}/lib/vc_dll/mswd )
  409. set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
  410. ${WXWINDOWS_SHARED_DEBUG_LIBRARY} )
  411. if (WXWINDOWS_USE_GL)
  412. set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
  413. ${WXWINDOWS_SHARED_DEBUG_LIBRARY_GL} )
  414. endif ()
  415. endif()
  416. endif()
  417. ## shared: only release wx lib found?
  418. if(NOT WXWINDOWS_SHARED_DEBUG_LIBRARY)
  419. if(WXWINDOWS_SHARED_LIBRARY)
  420. ##message("DBG wx shared: optimized (but no debug) found.")
  421. find_path(WXWINDOWS_INCLUDE_DIR_SETUPH wx/setup.h
  422. ${WXWINDOWS_ROOT_DIR}/lib/mswdll
  423. ${WXWINDOWS_ROOT_DIR}/lib/vc_dll/msw )
  424. set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
  425. ${WXWINDOWS_SHARED_DEBUG_LIBRARY} )
  426. if (WXWINDOWS_USE_GL)
  427. set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
  428. ${WXWINDOWS_SHARED_DEBUG_LIBRARY_GL} )
  429. endif ()
  430. endif()
  431. endif()
  432. ## shared: none found?
  433. if(NOT WXWINDOWS_SHARED_DEBUG_LIBRARY)
  434. if(NOT WXWINDOWS_SHARED_LIBRARY)
  435. message(STATUS
  436. "No shared wxWindows lib found, but WXWINDOWS_USE_SHARED_LIBS=${WXWINDOWS_USE_SHARED_LIBS}.")
  437. endif()
  438. endif()
  439. #########################################################################################
  440. else()
  441. ##jw: DEPRECATED if(NOT WXWINDOWS_SEPARATE_LIBS_BUILD)
  442. ## static: both wx (debug and release) found?
  443. ## assume that both builds use the same setup(.h) for simplicity
  444. if(WXWINDOWS_STATIC_DEBUG_LIBRARY AND WXWINDOWS_STATIC_LIBRARY)
  445. ##message("DBG wx static: debug and optimized found.")
  446. find_path(WXWINDOWS_INCLUDE_DIR_SETUPH wx/setup.h
  447. ${WXWINDOWS_ROOT_DIR}/lib/mswd
  448. ${WXWINDOWS_ROOT_DIR}/lib/msw
  449. ${WXWINDOWS_ROOT_DIR}/lib/vc_lib/mswd
  450. ${WXWINDOWS_ROOT_DIR}/lib/vc_lib/msw )
  451. set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
  452. debug ${WXWINDOWS_STATIC_DEBUG_LIBRARY}
  453. optimized ${WXWINDOWS_STATIC_LIBRARY} )
  454. if (WXWINDOWS_USE_GL)
  455. set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
  456. debug ${WXWINDOWS_STATIC_DEBUG_LIBRARY_GL}
  457. optimized ${WXWINDOWS_STATIC_LIBRARY_GL} )
  458. endif ()
  459. endif()
  460. ## static: only debug wx lib found?
  461. if(WXWINDOWS_STATIC_DEBUG_LIBRARY)
  462. if(NOT WXWINDOWS_STATIC_LIBRARY)
  463. ##message("DBG wx static: debug (but no optimized) found.")
  464. find_path(WXWINDOWS_INCLUDE_DIR_SETUPH wx/setup.h
  465. ${WXWINDOWS_ROOT_DIR}/lib/mswd
  466. ${WXWINDOWS_ROOT_DIR}/lib/vc_lib/mswd )
  467. set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
  468. ${WXWINDOWS_STATIC_DEBUG_LIBRARY} )
  469. if (WXWINDOWS_USE_GL)
  470. set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
  471. ${WXWINDOWS_STATIC_DEBUG_LIBRARY_GL} )
  472. endif ()
  473. endif()
  474. endif()
  475. ## static: only release wx lib found?
  476. if(NOT WXWINDOWS_STATIC_DEBUG_LIBRARY)
  477. if(WXWINDOWS_STATIC_LIBRARY)
  478. ##message("DBG wx static: optimized (but no debug) found.")
  479. find_path(WXWINDOWS_INCLUDE_DIR_SETUPH wx/setup.h
  480. ${WXWINDOWS_ROOT_DIR}/lib/msw
  481. ${WXWINDOWS_ROOT_DIR}/lib/vc_lib/msw )
  482. set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
  483. ${WXWINDOWS_STATIC_LIBRARY} )
  484. if (WXWINDOWS_USE_GL)
  485. set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
  486. ${WXWINDOWS_STATIC_LIBRARY_GL} )
  487. endif ()
  488. endif()
  489. endif()
  490. ## static: none found?
  491. if(NOT WXWINDOWS_STATIC_DEBUG_LIBRARY AND NOT WXWINDOWS_SEPARATE_LIBS_BUILD)
  492. if(NOT WXWINDOWS_STATIC_LIBRARY)
  493. message(STATUS
  494. "No static wxWindows lib found, but WXWINDOWS_USE_SHARED_LIBS=${WXWINDOWS_USE_SHARED_LIBS}.")
  495. endif()
  496. endif()
  497. endif()
  498. ## not neccessary in wxWindows 2.4.1 and 2.6.2
  499. ## but it may fix a previous bug, see
  500. ## http://lists.wxwindows.org/cgi-bin/ezmlm-cgi?8:mss:37574:200305:mpdioeneabobmgjenoap
  501. option(WXWINDOWS_SET_DEFINITIONS "Set additional defines for wxWindows" OFF)
  502. mark_as_advanced(WXWINDOWS_SET_DEFINITIONS)
  503. if (WXWINDOWS_SET_DEFINITIONS)
  504. set(WXWINDOWS_DEFINITIONS "-DWINVER=0x400")
  505. else ()
  506. # clear:
  507. set(WXWINDOWS_DEFINITIONS "")
  508. endif ()
  509. ## Find the include directories for wxwindows
  510. ## the first, build specific for wx/setup.h was determined before.
  511. ## add inc dir for general for "wx/wx.h"
  512. find_path(WXWINDOWS_INCLUDE_DIR wx/wx.h
  513. "${WXWINDOWS_ROOT_DIR}/include" )
  514. ## append the build specific include dir for wx/setup.h:
  515. if (WXWINDOWS_INCLUDE_DIR_SETUPH)
  516. set(WXWINDOWS_INCLUDE_DIR ${WXWINDOWS_INCLUDE_DIR} ${WXWINDOWS_INCLUDE_DIR_SETUPH} )
  517. endif ()
  518. mark_as_advanced(
  519. WXWINDOWS_ROOT_DIR
  520. WXWINDOWS_INCLUDE_DIR
  521. WXWINDOWS_INCLUDE_DIR_SETUPH
  522. WXWINDOWS_STATIC_LIBRARY
  523. WXWINDOWS_STATIC_LIBRARY_GL
  524. WXWINDOWS_STATIC_DEBUG_LIBRARY
  525. WXWINDOWS_STATIC_DEBUG_LIBRARY_GL
  526. WXWINDOWS_STATIC_LIBRARY_ZLIB
  527. WXWINDOWS_STATIC_DEBUG_LIBRARY_ZLIB
  528. WXWINDOWS_STATIC_LIBRARY_REGEX
  529. WXWINDOWS_STATIC_DEBUG_LIBRARY_REGEX
  530. WXWINDOWS_STATIC_LIBRARY_PNG
  531. WXWINDOWS_STATIC_DEBUG_LIBRARY_PNG
  532. WXWINDOWS_STATIC_LIBRARY_JPEG
  533. WXWINDOWS_STATIC_DEBUG_LIBRARY_JPEG
  534. WXWINDOWS_STATIC_DEBUG_LIBRARY_TIFF
  535. WXWINDOWS_STATIC_LIBRARY_TIFF
  536. WXWINDOWS_SHARED_LIBRARY
  537. WXWINDOWS_SHARED_DEBUG_LIBRARY
  538. WXWINDOWS_SHARED_LIBRARY_GL
  539. WXWINDOWS_SHARED_DEBUG_LIBRARY_GL
  540. )
  541. else()
  542. if (UNIX_STYLE_FIND)
  543. ## ######################################################################
  544. ##
  545. ## UNIX/Linux specific:
  546. ##
  547. ## use backquoted wx-config to query and set flags and libs:
  548. ## 06/2003 Jan Woetzel
  549. ##
  550. option(WXWINDOWS_USE_SHARED_LIBS "Use shared versions (.so) of wxWindows libraries" ON)
  551. mark_as_advanced(WXWINDOWS_USE_SHARED_LIBS)
  552. # JW removed option and force the develper th SET it.
  553. # option(WXWINDOWS_USE_GL "use wxWindows with GL support (use additional
  554. # --gl-libs for wx-config)?" OFF)
  555. # wx-config should be in your path anyhow, usually no need to set WXWIN or
  556. # search in ../wx or ../../wx
  557. find_program(CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE wx-config
  558. HINTS
  559. ENV WXWIN
  560. $ENV{WXWIN}/bin
  561. PATHS
  562. ../wx/bin
  563. ../../wx/bin )
  564. # check whether wx-config was found:
  565. if(CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE)
  566. # use shared/static wx lib?
  567. # remember: always link shared to use systems GL etc. libs (no static
  568. # linking, just link *against* static .a libs)
  569. if(WXWINDOWS_USE_SHARED_LIBS)
  570. set(WX_CONFIG_ARGS_LIBS "--libs")
  571. else()
  572. set(WX_CONFIG_ARGS_LIBS "--static --libs")
  573. endif()
  574. # do we need additionial wx GL stuff like GLCanvas ?
  575. if(WXWINDOWS_USE_GL)
  576. set(WX_CONFIG_ARGS_LIBS "${WX_CONFIG_ARGS_LIBS} --gl-libs" )
  577. endif()
  578. ##message("DBG: WX_CONFIG_ARGS_LIBS=${WX_CONFIG_ARGS_LIBS}===")
  579. # set CXXFLAGS to be fed into CMAKE_CXX_FLAGS by the user:
  580. if (HAVE_ISYSTEM) # does the compiler support -isystem ?
  581. if (NOT APPLE) # -isystem seem sto be unsuppored on Mac
  582. if(CMAKE_COMPILER_IS_GNUCC AND CMAKE_COMPILER_IS_GNUCXX )
  583. if (CMAKE_CXX_COMPILER MATCHES g\\+\\+)
  584. set(CMAKE_WXWINDOWS_CXX_FLAGS "`${CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE} --cxxflags|sed -e s/-I/-isystem/g`")
  585. else()
  586. set(CMAKE_WXWINDOWS_CXX_FLAGS "`${CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE} --cxxflags`")
  587. endif()
  588. endif()
  589. endif ()
  590. endif ()
  591. ##message("DBG: for compilation:
  592. ##CMAKE_WXWINDOWS_CXX_FLAGS=${CMAKE_WXWINDOWS_CXX_FLAGS}===")
  593. # keep the back-quoted string for clarity
  594. set(WXWINDOWS_LIBRARIES "`${CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE} ${WX_CONFIG_ARGS_LIBS}`")
  595. ##message("DBG2: for linking:
  596. ##WXWINDOWS_LIBRARIES=${WXWINDOWS_LIBRARIES}===")
  597. # evaluate wx-config output to separate linker flags and linkdirs for
  598. # rpath:
  599. exec_program(${CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE}
  600. ARGS ${WX_CONFIG_ARGS_LIBS}
  601. OUTPUT_VARIABLE WX_CONFIG_LIBS )
  602. ## extract linkdirs (-L) for rpath
  603. ## use regular expression to match wildcard equivalent "-L*<endchar>"
  604. ## with <endchar> is a space or a semicolon
  605. string(REGEX MATCHALL "[-][L]([^ ;])+" WXWINDOWS_LINK_DIRECTORIES_WITH_PREFIX "${WX_CONFIG_LIBS}" )
  606. # message("DBG WXWINDOWS_LINK_DIRECTORIES_WITH_PREFIX=${WXWINDOWS_LINK_DIRECTORIES_WITH_PREFIX}")
  607. ## remove prefix -L because we need the pure directory for LINK_DIRECTORIES
  608. ## replace -L by ; because the separator seems to be lost otherwise (bug or
  609. ## feature?)
  610. if(WXWINDOWS_LINK_DIRECTORIES_WITH_PREFIX)
  611. string(REGEX REPLACE "[-][L]" ";" WXWINDOWS_LINK_DIRECTORIES ${WXWINDOWS_LINK_DIRECTORIES_WITH_PREFIX} )
  612. # message("DBG WXWINDOWS_LINK_DIRECTORIES=${WXWINDOWS_LINK_DIRECTORIES}")
  613. endif()
  614. ## replace space separated string by semicolon separated vector to make it
  615. ## work with LINK_DIRECTORIES
  616. separate_arguments(WXWINDOWS_LINK_DIRECTORIES)
  617. mark_as_advanced(
  618. CMAKE_WXWINDOWS_CXX_FLAGS
  619. WXWINDOWS_INCLUDE_DIR
  620. WXWINDOWS_LIBRARIES
  621. CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE
  622. )
  623. ## we really need wx-config...
  624. else()
  625. 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.")
  626. mark_as_advanced(CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE)
  627. endif()
  628. else()
  629. message(STATUS "FindwxWindows.cmake: Platform unknown/unsupported by FindwxWindows.cmake. It's neither WIN32 nor UNIX")
  630. endif()
  631. endif()
  632. if(WXWINDOWS_LIBRARIES)
  633. if(WXWINDOWS_INCLUDE_DIR OR CMAKE_WXWINDOWS_CXX_FLAGS)
  634. ## found all we need.
  635. set(WXWINDOWS_FOUND 1)
  636. ## set deprecated variables for backward compatibility:
  637. set(CMAKE_WX_CAN_COMPILE ${WXWINDOWS_FOUND})
  638. set(WXWINDOWS_LIBRARY ${WXWINDOWS_LIBRARIES})
  639. set(WXWINDOWS_INCLUDE_PATH ${WXWINDOWS_INCLUDE_DIR})
  640. set(WXWINDOWS_LINK_DIRECTORIES ${WXWINDOWS_LINK_DIRECTORIES})
  641. set(CMAKE_WX_CXX_FLAGS ${CMAKE_WXWINDOWS_CXX_FLAGS})
  642. endif()
  643. endif()