FindwxWindows.cmake 24 KB

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