FindwxWidgets.cmake 23 KB

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