FindwxWindows.cmake 24 KB

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