FindwxWidgets.cmake 24 KB

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