FindwxWidgets.cmake 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. # - Find a wxWidgets (a.k.a., wxWindows) installation.
  2. # This module finds if wxWidgets is installed and selects a default
  3. # configuration to use.
  4. #
  5. # The following variables are searched for and set to defaults in case
  6. # of multiple choices. Change them if the defaults are not desired:
  7. #
  8. # wxWidgets_ROOT_DIR - Base wxWidgets directory
  9. # (e.g., C:/wxWidgets-2.6.3).
  10. # wxWidgets_LIB_DIR - Path to wxWidgets libraries
  11. # (e.g., C:/wxWidgets-2.6.3/lib/vc_lib).
  12. # wxWidgets_CONFIGURATION - Configuration to use
  13. # (e.g., msw, mswd, mswu, mswunivud, etc.)
  14. #
  15. # The following are set after configuration is done:
  16. #
  17. # wxWidgets_FOUND - Set to TRUE if wxWidgets was found.
  18. # wxWidgets_INCLUDE_DIRS - Include directories for WIN32
  19. # i.e., where to find "wx/wx.h" and
  20. # "wx/setup.h"; possibly empty for unices.
  21. # wxWidgets_LIBRARIES - Path to the wxWidgets libraries.
  22. # wxWidgets_LIBRARY_DIRS - compile time link dirs, useful for
  23. # rpath on UNIX. Typically an empty string
  24. # in WIN32 environment.
  25. # wxWidgets_DEFINITIONS - Contains defines required to compile/link
  26. # against WX, e.g. -DWXUSINGDLL
  27. # wxWidgets_CXX_FLAGS - Include dirs and ompiler flags for
  28. # unices, empty on WIN32. Esentially
  29. # "`wx-config --cxxflags`".
  30. # wxWidgets_USE_FILE - Convenience include file.
  31. #
  32. # Sample usage:
  33. # FIND_PACKAGE(wxWidgets COMPONENTS base core gl net)
  34. # IF(wxWidgets_FOUND)
  35. # INCLUDE(${wxWidgets_USE_FILE})
  36. # # and for each of your dependant executable/library targets:
  37. # TARGET_LINK_LIBRARIES(<YourTarget> ${wxWidgets_LIBRARIES})
  38. # ENDIF(wxWidgets_FOUND)
  39. #
  40. #
  41. # Sample usage with monolithic wx build:
  42. #
  43. # SET(wxWidgets_USE_LIBS msw26 expat jpeg gl png regex tiff zlib)
  44. # ...
  45. # NOTES
  46. #
  47. # This module has been tested on the WIN32 platform with wxWidgets
  48. # 2.6.2, 2.6.3, and 2.5.3. However, it has been designed to
  49. # easily extend support to all possible builds, e.g., static/shared,
  50. # debug/release, unicode, universal, multilib/monolithic, etc..
  51. #
  52. # If you want to use the module and your build type is not supported
  53. # out-of-the-box, please contact me to exchange information on how
  54. # your system is setup and I'll try to add support for it.
  55. #
  56. # AUTHOR
  57. #
  58. # Miguel A. Figueroa-Villanueva (miguelf at ieee dot org).
  59. # Jan Woetzel (jw at mip.informatik.uni-kiel.de).
  60. #
  61. # Based on previous works of:
  62. # Jan Woetzel (FindwxWindows.cmake),
  63. # Jorgen Bodde and Jerry Fath (FindwxWin.cmake).
  64. # TODO/ideas
  65. #
  66. # (1) Option/Setting to use all available wx libs
  67. # In contrast to expert developer who lists the
  68. # minimal set of required libs in wxWidgets_USE_LIBS
  69. # there is the newbie user:
  70. # - who just wants to link against WX with more 'magic'
  71. # - doesn't know the internal structure of WX or how it was built,
  72. # in particular if it is monolithic or not
  73. # - want to link against all available WX libs
  74. # Basically, the intent here is to mimic what wx-config would do by
  75. # default (i.e., `wx-config --libs`).
  76. #
  77. # Possible solution:
  78. # Add a reserved keyword "std" that initializes to what wx-config
  79. # would default to. If the user has not set the wxWidgets_USE_LIBS,
  80. # default to "std" instead of "base core" as it is now. To implement
  81. # "std" will basically boil down to a FOR_EACH lib-FOUND, but maybe
  82. # checking whether a minimal set was found.
  83. # FIXME: This and all the DBG_MSG calls should be removed after the
  84. # module stabilizes.
  85. #
  86. # Helper macro to control the debugging output globally. There are
  87. # two versions for controlling how verbose your output should be.
  88. MACRO(DBG_MSG _MSG)
  89. # MESSAGE(STATUS
  90. # "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): ${_MSG}")
  91. ENDMACRO(DBG_MSG)
  92. MACRO(DBG_MSG_V _MSG)
  93. # MESSAGE(STATUS
  94. # "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): ${_MSG}")
  95. ENDMACRO(DBG_MSG_V)
  96. # Clear return values in case the module is loaded more than once.
  97. SET(wxWidgets_FOUND FALSE)
  98. SET(wxWidgets_INCLUDE_DIRS "")
  99. SET(wxWidgets_LIBRARIES "")
  100. SET(wxWidgets_LIBRARY_DIRS "")
  101. SET(wxWidgets_CXX_FLAGS "")
  102. # FIXME: This is a patch to support the DEPRECATED use of
  103. # wxWidgets_USE_LIBS.
  104. #
  105. # If wxWidgets_USE_LIBS is set:
  106. # - if using <components>, then override wxWidgets_USE_LIBS
  107. # - else set wxWidgets_FIND_COMPONENTS to wxWidgets_USE_LIBS
  108. IF(wxWidgets_USE_LIBS AND NOT wxWidgets_FIND_COMPONENTS)
  109. SET(wxWidgets_FIND_COMPONENTS ${wxWidgets_USE_LIBS})
  110. ENDIF(wxWidgets_USE_LIBS AND NOT wxWidgets_FIND_COMPONENTS)
  111. DBG_MSG("wxWidgets_FIND_COMPONENTS : ${wxWidgets_FIND_COMPONENTS}")
  112. # Add the convenience use file if available.
  113. #
  114. # Get dir of this file which may reside in:
  115. # - CMAKE_MAKE_ROOT/Modules on CMake installation
  116. # - CMAKE_MODULE_PATH if user prefers his own specialized version
  117. SET(wxWidgets_USE_FILE "")
  118. GET_FILENAME_COMPONENT(
  119. wxWidgets_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
  120. # Prefer an existing customized version, but the user might override
  121. # the FindwxWidgets module and not the UsewxWidgets one.
  122. IF(EXISTS "${wxWidgets_CURRENT_LIST_DIR}/UsewxWidgets.cmake")
  123. SET(wxWidgets_USE_FILE
  124. "${wxWidgets_CURRENT_LIST_DIR}/UsewxWidgets.cmake")
  125. ELSE(EXISTS "${wxWidgets_CURRENT_LIST_DIR}/UsewxWidgets.cmake")
  126. SET(wxWidgets_USE_FILE UsewxWidgets.cmake)
  127. ENDIF(EXISTS "${wxWidgets_CURRENT_LIST_DIR}/UsewxWidgets.cmake")
  128. #=====================================================================
  129. #=====================================================================
  130. IF(WIN32)
  131. SET(WIN32_STYLE_FIND 1)
  132. ENDIF(WIN32)
  133. IF(MINGW)
  134. SET(WIN32_STYLE_FIND 0)
  135. SET(UNIX_STYLE_FIND 1)
  136. ENDIF(MINGW)
  137. IF(UNIX)
  138. SET(UNIX_STYLE_FIND 1)
  139. ENDIF(UNIX)
  140. #=====================================================================
  141. # WIN32_STYLE_FIND
  142. #=====================================================================
  143. IF(WIN32_STYLE_FIND)
  144. # FIXME: I think this should be removed... how difficult is it to
  145. # do with out it?
  146. # FIND_PACKAGE(wxWidgets COMPONENTS msw25d)
  147. # If the user knows enough to want monolithic, then he probably
  148. # knows enough to do the above...
  149. #
  150. # BTW, what happens in this case?
  151. # FIND_PACKAGE(wxWidgets)
  152. # Check these out and then remove comment. However, I think this
  153. # will probably have to stay for backward compatibility, but in
  154. # that case document it as a variable or list as deprecated.
  155. #
  156. # global settings for std and common wx libs logic could determine
  157. # _USE_MONOLITHIC automatically but let the user decide for now.
  158. IF(wxWidgets_USE_MONOLITHIC)
  159. SET(wxWidgets_STD_LIBRARIES mono)
  160. ELSE(wxWidgets_USE_MONOLITHIC)
  161. SET(wxWidgets_STD_LIBRARIES base core) # this is default
  162. ENDIF(wxWidgets_USE_MONOLITHIC)
  163. #useful common wx libs needed by almost all components
  164. SET(wxWidgets_COMMON_LIBRARIES png tiff jpeg zlib regex expat)
  165. #-------------------------------------------------------------------
  166. # WIN32: Helper MACROS
  167. #-------------------------------------------------------------------
  168. #
  169. # Get filename components for a configuration. For example,
  170. # if _CONFIGURATION = mswunivud, then _UNV=univ, _UCD=u _DBG=d
  171. # if _CONFIGURATION = mswu, then _UNV="", _UCD=u _DBG=""
  172. #
  173. MACRO(WX_GET_NAME_COMPONENTS _CONFIGURATION _UNV _UCD _DBG)
  174. STRING(REGEX MATCH "univ" ${_UNV} "${_CONFIGURATION}")
  175. STRING(REGEX REPLACE "msw.*(u)[d]*$" "u" ${_UCD} "${_CONFIGURATION}")
  176. IF(${_UCD} STREQUAL ${_CONFIGURATION})
  177. SET(${_UCD} "")
  178. ENDIF(${_UCD} STREQUAL ${_CONFIGURATION})
  179. STRING(REGEX MATCH "d$" ${_DBG} "${_CONFIGURATION}")
  180. ENDMACRO(WX_GET_NAME_COMPONENTS)
  181. #
  182. # Find libraries associated to a configuration.
  183. #
  184. MACRO(WX_FIND_LIBS _UNV _UCD _DBG)
  185. DBG_MSG_V("m_unv = ${_UNV}")
  186. DBG_MSG_V("m_ucd = ${_UCD}")
  187. DBG_MSG_V("m_dbg = ${_DBG}")
  188. # Find wxWidgets common libraries
  189. FOREACH(LIB png tiff jpeg zlib regex expat)
  190. FIND_LIBRARY(WX_${LIB}${_DBG}
  191. NAMES
  192. wx${LIB}${_UCD}${_DBG} # for regex
  193. wx${LIB}${_DBG}
  194. PATHS ${WX_LIB_DIR}
  195. NO_DEFAULT_PATH
  196. )
  197. MARK_AS_ADVANCED(WX_${LIB}${_DBG})
  198. ENDFOREACH(LIB)
  199. # Find wxWidgets multilib base libraries
  200. FIND_LIBRARY(WX_base${_DBG}
  201. NAMES
  202. wxbase29${_UCD}${_DBG}
  203. wxbase28${_UCD}${_DBG}
  204. wxbase27${_UCD}${_DBG}
  205. wxbase26${_UCD}${_DBG}
  206. wxbase25${_UCD}${_DBG}
  207. PATHS ${WX_LIB_DIR}
  208. NO_DEFAULT_PATH
  209. )
  210. MARK_AS_ADVANCED(WX_base${_DBG})
  211. FOREACH(LIB net odbc xml)
  212. FIND_LIBRARY(WX_${LIB}${_DBG}
  213. NAMES
  214. wxbase29${_UCD}${_DBG}_${LIB}
  215. wxbase28${_UCD}${_DBG}_${LIB}
  216. wxbase27${_UCD}${_DBG}_${LIB}
  217. wxbase26${_UCD}${_DBG}_${LIB}
  218. wxbase25${_UCD}${_DBG}_${LIB}
  219. PATHS ${WX_LIB_DIR}
  220. NO_DEFAULT_PATH
  221. )
  222. MARK_AS_ADVANCED(WX_${LIB}${_DBG})
  223. ENDFOREACH(LIB)
  224. # Find wxWidgets monolithic library
  225. FIND_LIBRARY(WX_mono${_DBG}
  226. NAMES
  227. wxmsw${_UNV}29${_UCD}${_DBG}
  228. wxmsw${_UNV}28${_UCD}${_DBG}
  229. wxmsw${_UNV}27${_UCD}${_DBG}
  230. wxmsw${_UNV}26${_UCD}${_DBG}
  231. wxmsw${_UNV}25${_UCD}${_DBG}
  232. PATHS ${WX_LIB_DIR}
  233. NO_DEFAULT_PATH
  234. )
  235. MARK_AS_ADVANCED(WX_mono${_DBG})
  236. # Find wxWidgets multilib libraries
  237. FOREACH(LIB core adv aui html media xrc dbgrid gl qa)
  238. FIND_LIBRARY(WX_${LIB}${_DBG}
  239. NAMES
  240. wxmsw${_UNV}29${_UCD}${_DBG}_${LIB}
  241. wxmsw${_UNV}28${_UCD}${_DBG}_${LIB}
  242. wxmsw${_UNV}27${_UCD}${_DBG}_${LIB}
  243. wxmsw${_UNV}26${_UCD}${_DBG}_${LIB}
  244. wxmsw${_UNV}25${_UCD}${_DBG}_${LIB}
  245. PATHS ${WX_LIB_DIR}
  246. NO_DEFAULT_PATH
  247. )
  248. MARK_AS_ADVANCED(WX_${LIB}${_DBG})
  249. ENDFOREACH(LIB)
  250. ENDMACRO(WX_FIND_LIBS)
  251. #
  252. # Clear all library paths, so that FIND_LIBRARY refinds them.
  253. #
  254. # Clear a lib, reset its found flag, and mark as advanced.
  255. MACRO(WX_CLEAR_LIB _LIB)
  256. SET(${_LIB} "${_LIB}-NOTFOUND" CACHE FILEPATH "Cleared." FORCE)
  257. SET(${_LIB}_FOUND FALSE)
  258. MARK_AS_ADVANCED(${_LIB})
  259. ENDMACRO(WX_CLEAR_LIB)
  260. # Clear all debug or release library paths (arguments are "d" or "").
  261. MACRO(WX_CLEAR_ALL_LIBS _DBG)
  262. # Clear wxWidgets common libraries
  263. FOREACH(LIB png tiff jpeg zlib regex expat)
  264. WX_CLEAR_LIB(WX_${LIB}${_DBG})
  265. ENDFOREACH(LIB)
  266. # Clear wxWidgets multilib base libraries
  267. WX_CLEAR_LIB(WX_base${_DBG})
  268. FOREACH(LIB net odbc xml)
  269. WX_CLEAR_LIB(WX_${LIB}${_DBG})
  270. ENDFOREACH(LIB)
  271. # Clear wxWidgets monolithic library
  272. WX_CLEAR_LIB(WX_mono${_DBG})
  273. # Clear wxWidgets multilib libraries
  274. FOREACH(LIB core adv aui html media xrc dbgrid gl qa)
  275. WX_CLEAR_LIB(WX_${LIB}${_DBG})
  276. ENDFOREACH(LIB)
  277. ENDMACRO(WX_CLEAR_ALL_LIBS)
  278. # Clear all wxWidgets debug libraries.
  279. MACRO(WX_CLEAR_ALL_DBG_LIBS)
  280. WX_CLEAR_ALL_LIBS("d")
  281. ENDMACRO(WX_CLEAR_ALL_DBG_LIBS)
  282. # Clear all wxWidgets release libraries.
  283. MACRO(WX_CLEAR_ALL_REL_LIBS)
  284. WX_CLEAR_ALL_LIBS("")
  285. ENDMACRO(WX_CLEAR_ALL_REL_LIBS)
  286. #
  287. # Set the wxWidgets_LIBRARIES variable.
  288. # Also, Sets output variable wxWidgets_FOUND to FALSE if it fails.
  289. #
  290. MACRO(WX_SET_LIBRARIES _LIBS _DBG)
  291. DBG_MSG_V("Looking for ${${_LIBS}}")
  292. IF(WX_USE_REL_AND_DBG)
  293. FOREACH(LIB ${${_LIBS}})
  294. DBG_MSG_V("Searching for ${LIB} and ${LIB}d")
  295. DBG_MSG_V("WX_${LIB} : ${WX_${LIB}}")
  296. DBG_MSG_V("WX_${LIB}d : ${WX_${LIB}d}")
  297. IF(WX_${LIB} AND WX_${LIB}d)
  298. DBG_MSG_V("Found ${LIB} and ${LIB}d")
  299. SET(wxWidgets_LIBRARIES ${wxWidgets_LIBRARIES}
  300. debug ${WX_${LIB}d}
  301. optimized ${WX_${LIB}}
  302. )
  303. ELSE(WX_${LIB} AND WX_${LIB}d)
  304. DBG_MSG_V("- not found due to missing WX_${LIB}=${WX_${LIB}} or WX_${LIB}d=${WX_${LIB}d}")
  305. SET(wxWidgets_FOUND FALSE)
  306. ENDIF(WX_${LIB} AND WX_${LIB}d)
  307. ENDFOREACH(LIB)
  308. ELSE(WX_USE_REL_AND_DBG)
  309. FOREACH(LIB ${${_LIBS}})
  310. DBG_MSG_V("Searching for ${LIB}${_DBG}")
  311. DBG_MSG_V("WX_${LIB}${_DBG} : ${WX_${LIB}${_DBG}}")
  312. IF(WX_${LIB}${_DBG})
  313. DBG_MSG_V("Found ${LIB}${_DBG}")
  314. SET(wxWidgets_LIBRARIES ${wxWidgets_LIBRARIES}
  315. ${WX_${LIB}${_DBG}}
  316. )
  317. ELSE(WX_${LIB}${_DBG})
  318. DBG_MSG_V(
  319. "- not found due to missing WX_${LIB}${_DBG}=${WX_${LIB}${_DBG}}")
  320. SET(wxWidgets_FOUND FALSE)
  321. ENDIF(WX_${LIB}${_DBG})
  322. ENDFOREACH(LIB)
  323. ENDIF(WX_USE_REL_AND_DBG)
  324. DBG_MSG_V("OpenGL")
  325. LIST(FIND ${_LIBS} gl WX_USE_GL)
  326. IF(NOT WX_USE_GL EQUAL -1)
  327. DBG_MSG_V("- is required.")
  328. SET(wxWidgets_LIBRARIES ${wxWidgets_LIBRARIES}
  329. opengl32
  330. glu32
  331. )
  332. ENDIF(NOT WX_USE_GL EQUAL -1)
  333. SET(wxWidgets_LIBRARIES ${wxWidgets_LIBRARIES}
  334. winmm
  335. comctl32
  336. rpcrt4
  337. wsock32
  338. )
  339. ENDMACRO(WX_SET_LIBRARIES)
  340. #-------------------------------------------------------------------
  341. # WIN32: Start actual work.
  342. #-------------------------------------------------------------------
  343. # Look for an installation tree.
  344. FIND_PATH(wxWidgets_ROOT_DIR
  345. NAMES include/wx/wx.h
  346. PATHS
  347. $ENV{wxWidgets_ROOT_DIR}
  348. $ENV{WXWIN}
  349. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\wxWidgets_is1;Inno Setup: App Path]" # WX 2.6.x
  350. C:/
  351. D:/
  352. $ENV{ProgramFiles}
  353. PATH_SUFFIXES
  354. wxWidgets-2.8.6
  355. wxWidgets-2.8.5
  356. wxWidgets-2.8.4
  357. wxWidgets-2.8.3
  358. wxWidgets-2.8.2
  359. wxWidgets-2.8.1
  360. wxWidgets-2.8.0
  361. wxWidgets-2.7.4
  362. wxWidgets-2.7.3
  363. wxWidgets-2.7.2
  364. wxWidgest-2.7.1
  365. wxWidgets-2.7.0
  366. wxWidgets-2.7.0-1
  367. wxWidgets-2.6.3
  368. wxWidgets-2.6.2
  369. wxWidgets-2.6.1
  370. wxWidgets-2.5.4
  371. wxWidgets-2.5.3
  372. wxWidgets-2.5.2
  373. wxWidgets-2.5.1
  374. wxWidgets
  375. DOC "wxWidgets base/installation directory?"
  376. )
  377. # If wxWidgets_ROOT_DIR changed, clear lib dir.
  378. IF(NOT WX_ROOT_DIR STREQUAL wxWidgets_ROOT_DIR)
  379. SET(WX_ROOT_DIR ${wxWidgets_ROOT_DIR} CACHE INTERNAL "wxWidgets_ROOT_DIR")
  380. SET(wxWidgets_LIB_DIR "wxWidgets_LIB_DIR-NOTFOUND" CACHE PATH "Cleared." FORCE)
  381. ENDIF(NOT WX_ROOT_DIR STREQUAL wxWidgets_ROOT_DIR)
  382. IF(WX_ROOT_DIR)
  383. # Select one default tree inside the already determined wx tree.
  384. # Prefer static/shared order usually consistent with build
  385. # settings.
  386. IF(BUILD_SHARED_LIBS)
  387. FIND_PATH(wxWidgets_LIB_DIR
  388. NAMES wxpng.lib wxpngd.lib
  389. PATHS
  390. ${WX_ROOT_DIR}/lib/vc_dll # prefer shared
  391. ${WX_ROOT_DIR}/lib/vc_lib
  392. DOC "Path to wxWidgets libraries?"
  393. NO_DEFAULT_PATH
  394. )
  395. ELSE(BUILD_SHARED_LIBS)
  396. FIND_PATH(wxWidgets_LIB_DIR
  397. NAMES wxpng.lib wxpngd.lib
  398. PATHS
  399. ${WX_ROOT_DIR}/lib/vc_lib # prefer static
  400. ${WX_ROOT_DIR}/lib/vc_dll
  401. DOC "Path to wxWidgets libraries?"
  402. NO_DEFAULT_PATH
  403. )
  404. ENDIF(BUILD_SHARED_LIBS)
  405. # If wxWidgets_LIB_DIR changed, clear all libraries.
  406. IF(NOT WX_LIB_DIR STREQUAL wxWidgets_LIB_DIR)
  407. SET(WX_LIB_DIR ${wxWidgets_LIB_DIR} CACHE INTERNAL "wxWidgets_LIB_DIR")
  408. WX_CLEAR_ALL_DBG_LIBS()
  409. WX_CLEAR_ALL_REL_LIBS()
  410. ENDIF(NOT WX_LIB_DIR STREQUAL wxWidgets_LIB_DIR)
  411. IF(WX_LIB_DIR)
  412. SET(wxWidgets_FOUND TRUE)
  413. # If building shared libs, define WXUSINGDLL to use dllimport.
  414. IF(WX_LIB_DIR MATCHES ".*[dD][lL][lL].*")
  415. SET(wxWidgets_DEFINITIONS "-DWXUSINGDLL")
  416. DBG_MSG_V("detected SHARED/DLL tree WX_LIB_DIR=${WX_LIB_DIR}")
  417. ENDIF(WX_LIB_DIR MATCHES ".*[dD][lL][lL].*")
  418. # Search for available configuration types.
  419. FOREACH(CFG mswunivud mswunivd mswud mswd mswunivu mswuniv mswu msw)
  420. SET(WX_${CFG}_FOUND FALSE)
  421. IF(EXISTS ${WX_LIB_DIR}/${CFG})
  422. SET(WX_CONFIGURATION_LIST ${WX_CONFIGURATION_LIST} ${CFG})
  423. SET(WX_${CFG}_FOUND TRUE)
  424. SET(WX_CONFIGURATION ${CFG})
  425. ENDIF(EXISTS ${WX_LIB_DIR}/${CFG})
  426. ENDFOREACH(CFG)
  427. DBG_MSG_V("WX_CONFIGURATION_LIST=${WX_CONFIGURATION_LIST}")
  428. IF(WX_CONFIGURATION)
  429. # If the selected configuration wasn't found force the default
  430. # one. Otherwise, use it but still force a refresh for
  431. # updating the doc string with the current list of available
  432. # configurations.
  433. IF(NOT WX_${wxWidgets_CONFIGURATION}_FOUND)
  434. SET(wxWidgets_CONFIGURATION ${WX_CONFIGURATION} CACHE STRING
  435. "Set wxWidgets configuration (${WX_CONFIGURATION_LIST})" FORCE)
  436. ELSE(NOT WX_${wxWidgets_CONFIGURATION}_FOUND)
  437. SET(wxWidgets_CONFIGURATION ${wxWidgets_CONFIGURATION} CACHE STRING
  438. "Set wxWidgets configuration (${WX_CONFIGURATION_LIST})" FORCE)
  439. ENDIF(NOT WX_${wxWidgets_CONFIGURATION}_FOUND)
  440. # If release config selected, and both release/debug exist.
  441. IF(WX_${wxWidgets_CONFIGURATION}d_FOUND)
  442. OPTION(wxWidgets_USE_REL_AND_DBG
  443. "Use release and debug configurations?" TRUE)
  444. SET(WX_USE_REL_AND_DBG ${wxWidgets_USE_REL_AND_DBG})
  445. ELSE(WX_${wxWidgets_CONFIGURATION}d_FOUND)
  446. # If the option exists (already in cache), force it false.
  447. IF(wxWidgets_USE_REL_AND_DBG)
  448. SET(wxWidgets_USE_REL_AND_DBG FALSE CACHE BOOL
  449. "No ${wxWidgets_CONFIGURATION}d found." FORCE)
  450. ENDIF(wxWidgets_USE_REL_AND_DBG)
  451. SET(WX_USE_REL_AND_DBG FALSE)
  452. ENDIF(WX_${wxWidgets_CONFIGURATION}d_FOUND)
  453. # Get configuration parameters from the name.
  454. WX_GET_NAME_COMPONENTS(${wxWidgets_CONFIGURATION} UNV UCD DBG)
  455. # Set wxWidgets main include directory.
  456. IF(EXISTS ${WX_ROOT_DIR}/include/wx/wx.h)
  457. SET(wxWidgets_INCLUDE_DIRS ${WX_ROOT_DIR}/include)
  458. ELSE(EXISTS ${WX_ROOT_DIR}/include/wx/wx.h)
  459. DBG_MSG("wxWidgets_FOUND FALSE because WX_ROOT_DIR=${WX_ROOT_DIR} has no ${WX_ROOT_DIR}/include/wx/wx.h")
  460. SET(wxWidgets_FOUND FALSE)
  461. ENDIF(EXISTS ${WX_ROOT_DIR}/include/wx/wx.h)
  462. # Set wxWidgets lib setup include directory.
  463. IF(EXISTS ${WX_LIB_DIR}/${wxWidgets_CONFIGURATION}/wx/setup.h)
  464. SET(wxWidgets_INCLUDE_DIRS ${wxWidgets_INCLUDE_DIRS}
  465. ${WX_LIB_DIR}/${wxWidgets_CONFIGURATION})
  466. ELSE(EXISTS ${WX_LIB_DIR}/${wxWidgets_CONFIGURATION}/wx/setup.h)
  467. DBG_MSG("WXWIDGET_FOUND FALSE because ${WX_LIB_DIR}/${wxWidgets_CONFIGURATION}/wx/setup.h does not exists.")
  468. SET(wxWidgets_FOUND FALSE)
  469. ENDIF(EXISTS ${WX_LIB_DIR}/${wxWidgets_CONFIGURATION}/wx/setup.h)
  470. # Find wxWidgets libraries.
  471. WX_FIND_LIBS("${UNV}" "${UCD}" "${DBG}")
  472. IF(WX_USE_REL_AND_DBG)
  473. WX_FIND_LIBS("${UNV}" "${UCD}" "d")
  474. ENDIF(WX_USE_REL_AND_DBG)
  475. # If no library was requested, set default minimum set (i.e.,
  476. # link to only core,base or mono).
  477. IF(NOT wxWidgets_FIND_COMPONENTS)
  478. SET(wxWidgets_FIND_COMPONENTS ${wxWidgets_STD_LIBRARIES})
  479. ENDIF(NOT wxWidgets_FIND_COMPONENTS)
  480. # Always add the common required libs.
  481. LIST(APPEND wxWidgets_FIND_COMPONENTS ${wxWidgets_COMMON_LIBRARIES})
  482. # Settings for requested libs (i.e., include dir, libraries, etc.).
  483. WX_SET_LIBRARIES(wxWidgets_FIND_COMPONENTS "${DBG}")
  484. ENDIF(WX_CONFIGURATION)
  485. ENDIF(WX_LIB_DIR)
  486. ENDIF(WX_ROOT_DIR)
  487. #=====================================================================
  488. # UNIX_STYLE_FIND
  489. #=====================================================================
  490. ELSE(WIN32_STYLE_FIND)
  491. IF(UNIX_STYLE_FIND)
  492. FIND_PROGRAM(wxWidgets_CONFIG_EXECUTABLE wx-config)
  493. IF(wxWidgets_CONFIG_EXECUTABLE)
  494. SET(wxWidgets_FOUND TRUE)
  495. # run the wx-config program to get cxxflags
  496. EXECUTE_PROCESS(
  497. COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}" --cxxflags
  498. OUTPUT_VARIABLE wxWidgets_CXX_FLAGS
  499. RESULT_VARIABLE RET
  500. )
  501. IF(RET EQUAL 0)
  502. STRING(STRIP "${wxWidgets_CXX_FLAGS}" wxWidgets_CXX_FLAGS)
  503. SEPARATE_ARGUMENTS(wxWidgets_CXX_FLAGS)
  504. DBG_MSG_V("wxWidgets_CXX_FLAGS=${wxWidgets_CXX_FLAGS}")
  505. # parse definitions from cxxflags; drop -D* from CXXFLAGS
  506. STRING(REGEX MATCHALL "-D[^;]+"
  507. wxWidgets_DEFINITIONS "${wxWidgets_CXX_FLAGS}")
  508. STRING(REGEX REPLACE "-D[^;]+;" ""
  509. wxWidgets_CXX_FLAGS "${wxWidgets_CXX_FLAGS}")
  510. # parse include dirs from cxxflags; drop -I prefix
  511. STRING(REGEX MATCHALL "-I[^;]+"
  512. wxWidgets_INCLUDE_DIRS "${wxWidgets_CXX_FLAGS}")
  513. STRING(REGEX REPLACE "-I[^;]+;" ""
  514. wxWidgets_CXX_FLAGS "${wxWidgets_CXX_FLAGS}")
  515. STRING(REPLACE "-I" ""
  516. wxWidgets_INCLUDE_DIRS "${wxWidgets_INCLUDE_DIRS}")
  517. # convert space to semicolons for list
  518. # SEPARATE_ARGUMENTS(wxWidgets_INCLUDE_DIRS)
  519. DBG_MSG_V("wxWidgets_DEFINITIONS=${wxWidgets_DEFINITIONS}")
  520. DBG_MSG_V("wxWidgets_INCLUDE_DIRS=${wxWidgets_INCLUDE_DIRS}")
  521. DBG_MSG_V("wxWidgets_CXX_FLAGS=${wxWidgets_CXX_FLAGS}")
  522. ELSE(RET EQUAL 0)
  523. SET(wxWidgets_FOUND FALSE)
  524. DBG_MSG_V(
  525. "${wxWidgets_CONFIG_EXECUTABLE} --cxxflags FAILED with RET=${RET}")
  526. ENDIF(RET EQUAL 0)
  527. # run the wx-config program to get the libs
  528. # - NOTE: wx-config doesn't verify that the libs requested exist
  529. # it just produces the names. Maybe a TRY_COMPILE would
  530. # be useful here...
  531. STRING(REPLACE ";" ","
  532. wxWidgets_FIND_COMPONENTS "${wxWidgets_FIND_COMPONENTS}")
  533. EXECUTE_PROCESS(
  534. COMMAND
  535. sh "${wxWidgets_CONFIG_EXECUTABLE}" --libs ${wxWidgets_FIND_COMPONENTS}
  536. OUTPUT_VARIABLE wxWidgets_LIBRARIES
  537. RESULT_VARIABLE RET
  538. )
  539. IF(RET EQUAL 0)
  540. STRING(STRIP "${wxWidgets_LIBRARIES}" wxWidgets_LIBRARIES)
  541. SEPARATE_ARGUMENTS(wxWidgets_LIBRARIES)
  542. STRING(REPLACE "-framework;" "-framework "
  543. wxWidgets_LIBRARIES "${wxWidgets_LIBRARIES}")
  544. # extract linkdirs (-L) for rpath (i.e., LINK_DIRECTORIES)
  545. STRING(REGEX MATCHALL "-L[^;]+"
  546. wxWidgets_LIBRARY_DIRS "${wxWidgets_LIBRARIES}")
  547. STRING(REPLACE "-L" ""
  548. wxWidgets_LIBRARY_DIRS "${wxWidgets_LIBRARY_DIRS}")
  549. # convert space to semicolons for list
  550. # SEPARATE_ARGUMENTS(wxWidgets_LIBRARY_DIRS)
  551. DBG_MSG_V("wxWidgets_LIBRARIES=${wxWidgets_LIBRARIES}")
  552. DBG_MSG_V("wxWidgets_LIBRARY_DIRS=${wxWidgets_LIBRARY_DIRS}")
  553. ELSE(RET EQUAL 0)
  554. SET(wxWidgets_FOUND FALSE)
  555. DBG_MSG("${wxWidgets_CONFIG_EXECUTABLE} --libs ${wxWidgets_FIND_COMPONENTS} FAILED with RET=${RET}")
  556. ENDIF(RET EQUAL 0)
  557. ENDIF(wxWidgets_CONFIG_EXECUTABLE)
  558. #=====================================================================
  559. # Neither UNIX_STYLE_FIND, nor WIN32_STYLE_FIND
  560. #=====================================================================
  561. ELSE(UNIX_STYLE_FIND)
  562. IF(NOT wxWidgets_FIND_QUIETLY)
  563. MESSAGE(STATUS
  564. "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): \n"
  565. " Platform unknown/unsupported. It's neither WIN32 nor UNIX "
  566. "style find."
  567. )
  568. ENDIF(NOT wxWidgets_FIND_QUIETLY)
  569. ENDIF(UNIX_STYLE_FIND)
  570. ENDIF(WIN32_STYLE_FIND)
  571. # Debug output:
  572. DBG_MSG("wxWidgets_FOUND : ${wxWidgets_FOUND}")
  573. DBG_MSG("wxWidgets_INCLUDE_DIRS : ${wxWidgets_INCLUDE_DIRS}")
  574. DBG_MSG("wxWidgets_LIBRARY_DIRS : ${wxWidgets_LIBRARY_DIRS}")
  575. DBG_MSG("wxWidgets_LIBRARIES : ${wxWidgets_LIBRARIES}")
  576. DBG_MSG("wxWidgets_CXX_FLAGS : ${wxWidgets_CXX_FLAGS}")
  577. DBG_MSG("wxWidgets_USE_FILE : ${wxWidgets_USE_FILE}")
  578. #=====================================================================
  579. #=====================================================================
  580. INCLUDE(FindPackageHandleStandardArgs)
  581. FIND_PACKAGE_HANDLE_STANDARD_ARGS(wxWidgets DEFAULT_MSG wxWidgets_FOUND)