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