FindwxWindows.cmake 24 KB

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