FindwxWidgets.cmake 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020
  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. wxWidgets is a modular library. To specify the
  4. # modules that you will use, you need to name them as components to
  5. # the package:
  6. #
  7. # FIND_PACKAGE(wxWidgets COMPONENTS base core ...)
  8. #
  9. # There are two search branches: a windows style and a unix style. For
  10. # windows, the following variables are searched for and set to
  11. # defaults in case of multiple choices. Change them if the defaults
  12. # are not desired (i.e., these are the only variables you should
  13. # change to select a configuration):
  14. #
  15. # wxWidgets_ROOT_DIR - Base wxWidgets directory
  16. # (e.g., C:/wxWidgets-2.6.3).
  17. # wxWidgets_LIB_DIR - Path to wxWidgets libraries
  18. # (e.g., C:/wxWidgets-2.6.3/lib/vc_lib).
  19. # wxWidgets_CONFIGURATION - Configuration to use
  20. # (e.g., msw, mswd, mswu, mswunivud, etc.)
  21. #
  22. # For unix style it uses the wx-config utility. You can select between
  23. # debug/release, unicode/ansi, universal/non-universal, and
  24. # static/shared in the QtDialog or ccmake interfaces by turning ON/OFF
  25. # the following variables:
  26. #
  27. # wxWidgets_USE_DEBUG
  28. # wxWidgets_USE_UNICODE
  29. # wxWidgets_USE_UNIVERSAL
  30. # wxWidgets_USE_STATIC
  31. #
  32. # The following are set after the configuration is done for both
  33. # windows and unix style:
  34. #
  35. # wxWidgets_FOUND - Set to TRUE if wxWidgets was found.
  36. # wxWidgets_INCLUDE_DIRS - Include directories for WIN32
  37. # i.e., where to find "wx/wx.h" and
  38. # "wx/setup.h"; possibly empty for unices.
  39. # wxWidgets_LIBRARIES - Path to the wxWidgets libraries.
  40. # wxWidgets_LIBRARY_DIRS - compile time link dirs, useful for
  41. # rpath on UNIX. Typically an empty string
  42. # in WIN32 environment.
  43. # wxWidgets_DEFINITIONS - Contains defines required to compile/link
  44. # against WX, e.g. WXUSINGDLL
  45. # wxWidgets_DEFINITIONS_DEBUG- Contains defines required to compile/link
  46. # against WX debug builds, e.g. __WXDEBUG__
  47. # wxWidgets_CXX_FLAGS - Include dirs and compiler flags for
  48. # unices, empty on WIN32. Essentially
  49. # "`wx-config --cxxflags`".
  50. # wxWidgets_USE_FILE - Convenience include file.
  51. #
  52. # Sample usage:
  53. # FIND_PACKAGE(wxWidgets COMPONENTS base core gl net)
  54. # IF(wxWidgets_FOUND)
  55. # INCLUDE(${wxWidgets_USE_FILE})
  56. # # and for each of your dependant executable/library targets:
  57. # TARGET_LINK_LIBRARIES(<YourTarget> ${wxWidgets_LIBRARIES})
  58. # ENDIF(wxWidgets_FOUND)
  59. #
  60. # If wxWidgets is required (i.e., not an optional part):
  61. # FIND_PACKAGE(wxWidgets REQUIRED base core gl net)
  62. # INCLUDE(${wxWidgets_USE_FILE})
  63. # # and for each of your dependant executable/library targets:
  64. # TARGET_LINK_LIBRARIES(<YourTarget> ${wxWidgets_LIBRARIES})
  65. #=============================================================================
  66. # Copyright 2004-2009 Kitware, Inc.
  67. # Copyright 2007-2009 Miguel A. Figueroa-Villanueva <miguelf at ieee dot org>
  68. #
  69. # Distributed under the OSI-approved BSD License (the "License");
  70. # see accompanying file Copyright.txt for details.
  71. #
  72. # This software is distributed WITHOUT ANY WARRANTY; without even the
  73. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  74. # See the License for more information.
  75. #=============================================================================
  76. # (To distributed this file outside of CMake, substitute the full
  77. # License text for the above reference.)
  78. #
  79. # FIXME: check this and provide a correct sample usage...
  80. # Remember to connect back to the upper text.
  81. # Sample usage with monolithic wx build:
  82. #
  83. # FIND_PACKAGE(wxWidgets COMPONENTS mono)
  84. # ...
  85. # NOTES
  86. #
  87. # This module has been tested on the WIN32 platform with wxWidgets
  88. # 2.6.2, 2.6.3, and 2.5.3. However, it has been designed to
  89. # easily extend support to all possible builds, e.g., static/shared,
  90. # debug/release, unicode, universal, multilib/monolithic, etc..
  91. #
  92. # If you want to use the module and your build type is not supported
  93. # out-of-the-box, please contact me to exchange information on how
  94. # your system is setup and I'll try to add support for it.
  95. #
  96. # AUTHOR
  97. #
  98. # Miguel A. Figueroa-Villanueva (miguelf at ieee dot org).
  99. # Jan Woetzel (jw at mip.informatik.uni-kiel.de).
  100. #
  101. # Based on previous works of:
  102. # Jan Woetzel (FindwxWindows.cmake),
  103. # Jorgen Bodde and Jerry Fath (FindwxWin.cmake).
  104. # TODO/ideas
  105. #
  106. # (1) Option/Setting to use all available wx libs
  107. # In contrast to expert developer who lists the
  108. # minimal set of required libs in wxWidgets_USE_LIBS
  109. # there is the newbie user:
  110. # - who just wants to link against WX with more 'magic'
  111. # - doesn't know the internal structure of WX or how it was built,
  112. # in particular if it is monolithic or not
  113. # - want to link against all available WX libs
  114. # Basically, the intent here is to mimic what wx-config would do by
  115. # default (i.e., `wx-config --libs`).
  116. #
  117. # Possible solution:
  118. # Add a reserved keyword "std" that initializes to what wx-config
  119. # would default to. If the user has not set the wxWidgets_USE_LIBS,
  120. # default to "std" instead of "base core" as it is now. To implement
  121. # "std" will basically boil down to a FOR_EACH lib-FOUND, but maybe
  122. # checking whether a minimal set was found.
  123. # FIXME: This and all the DBG_MSG calls should be removed after the
  124. # module stabilizes.
  125. #
  126. # Helper macro to control the debugging output globally. There are
  127. # two versions for controlling how verbose your output should be.
  128. MACRO(DBG_MSG _MSG)
  129. # MESSAGE(STATUS
  130. # "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): ${_MSG}")
  131. ENDMACRO(DBG_MSG)
  132. MACRO(DBG_MSG_V _MSG)
  133. # MESSAGE(STATUS
  134. # "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): ${_MSG}")
  135. ENDMACRO(DBG_MSG_V)
  136. # Clear return values in case the module is loaded more than once.
  137. SET(wxWidgets_FOUND FALSE)
  138. SET(wxWidgets_INCLUDE_DIRS "")
  139. SET(wxWidgets_LIBRARIES "")
  140. SET(wxWidgets_LIBRARY_DIRS "")
  141. SET(wxWidgets_CXX_FLAGS "")
  142. # Using SYSTEM with INCLUDE_DIRECTORIES in conjunction with wxWidgets on
  143. # the Mac produces compiler errors. Set wxWidgets_INCLUDE_DIRS_NO_SYSTEM
  144. # to prevent UsewxWidgets.cmake from using SYSTEM.
  145. #
  146. # See cmake mailing list discussions for more info:
  147. # http://www.cmake.org/pipermail/cmake/2008-April/021115.html
  148. # http://www.cmake.org/pipermail/cmake/2008-April/021146.html
  149. #
  150. IF(APPLE)
  151. SET(wxWidgets_INCLUDE_DIRS_NO_SYSTEM 1)
  152. ENDIF(APPLE)
  153. # DEPRECATED: This is a patch to support the DEPRECATED use of
  154. # wxWidgets_USE_LIBS.
  155. #
  156. # If wxWidgets_USE_LIBS is set:
  157. # - if using <components>, then override wxWidgets_USE_LIBS
  158. # - else set wxWidgets_FIND_COMPONENTS to wxWidgets_USE_LIBS
  159. IF(wxWidgets_USE_LIBS AND NOT wxWidgets_FIND_COMPONENTS)
  160. SET(wxWidgets_FIND_COMPONENTS ${wxWidgets_USE_LIBS})
  161. ENDIF(wxWidgets_USE_LIBS AND NOT wxWidgets_FIND_COMPONENTS)
  162. DBG_MSG("wxWidgets_FIND_COMPONENTS : ${wxWidgets_FIND_COMPONENTS}")
  163. # Add the convenience use file if available.
  164. #
  165. # Get dir of this file which may reside in:
  166. # - CMAKE_MAKE_ROOT/Modules on CMake installation
  167. # - CMAKE_MODULE_PATH if user prefers his own specialized version
  168. SET(wxWidgets_USE_FILE "")
  169. GET_FILENAME_COMPONENT(
  170. wxWidgets_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
  171. # Prefer an existing customized version, but the user might override
  172. # the FindwxWidgets module and not the UsewxWidgets one.
  173. IF(EXISTS "${wxWidgets_CURRENT_LIST_DIR}/UsewxWidgets.cmake")
  174. SET(wxWidgets_USE_FILE
  175. "${wxWidgets_CURRENT_LIST_DIR}/UsewxWidgets.cmake")
  176. ELSE(EXISTS "${wxWidgets_CURRENT_LIST_DIR}/UsewxWidgets.cmake")
  177. SET(wxWidgets_USE_FILE UsewxWidgets.cmake)
  178. ENDIF(EXISTS "${wxWidgets_CURRENT_LIST_DIR}/UsewxWidgets.cmake")
  179. #=====================================================================
  180. #=====================================================================
  181. IF(WIN32 AND NOT CYGWIN AND NOT MSYS)
  182. SET(wxWidgets_FIND_STYLE "win32")
  183. ELSE(WIN32 AND NOT CYGWIN AND NOT MSYS)
  184. IF(UNIX OR MSYS)
  185. SET(wxWidgets_FIND_STYLE "unix")
  186. ENDIF(UNIX OR MSYS)
  187. ENDIF(WIN32 AND NOT CYGWIN AND NOT MSYS)
  188. #=====================================================================
  189. # WIN32_FIND_STYLE
  190. #=====================================================================
  191. IF(wxWidgets_FIND_STYLE STREQUAL "win32")
  192. # Useful common wx libs needed by almost all components.
  193. SET(wxWidgets_COMMON_LIBRARIES png tiff jpeg zlib regex expat)
  194. # DEPRECATED: Use FIND_PACKAGE(wxWidgets COMPONENTS mono) instead.
  195. IF(NOT wxWidgets_FIND_COMPONENTS)
  196. IF(wxWidgets_USE_MONOLITHIC)
  197. SET(wxWidgets_FIND_COMPONENTS mono)
  198. ELSE(wxWidgets_USE_MONOLITHIC)
  199. SET(wxWidgets_FIND_COMPONENTS base core) # this is default
  200. ENDIF(wxWidgets_USE_MONOLITHIC)
  201. ENDIF(NOT wxWidgets_FIND_COMPONENTS)
  202. # Always add the common required libs.
  203. LIST(APPEND wxWidgets_FIND_COMPONENTS ${wxWidgets_COMMON_LIBRARIES})
  204. #-------------------------------------------------------------------
  205. # WIN32: Helper MACROS
  206. #-------------------------------------------------------------------
  207. #
  208. # Get filename components for a configuration. For example,
  209. # if _CONFIGURATION = mswunivud, then _UNV=univ, _UCD=u _DBG=d
  210. # if _CONFIGURATION = mswu, then _UNV="", _UCD=u _DBG=""
  211. #
  212. MACRO(WX_GET_NAME_COMPONENTS _CONFIGURATION _UNV _UCD _DBG)
  213. STRING(REGEX MATCH "univ" ${_UNV} "${_CONFIGURATION}")
  214. STRING(REGEX REPLACE "msw.*(u)[d]*$" "u" ${_UCD} "${_CONFIGURATION}")
  215. IF(${_UCD} STREQUAL ${_CONFIGURATION})
  216. SET(${_UCD} "")
  217. ENDIF(${_UCD} STREQUAL ${_CONFIGURATION})
  218. STRING(REGEX MATCH "d$" ${_DBG} "${_CONFIGURATION}")
  219. ENDMACRO(WX_GET_NAME_COMPONENTS)
  220. #
  221. # Find libraries associated to a configuration.
  222. #
  223. MACRO(WX_FIND_LIBS _UNV _UCD _DBG)
  224. DBG_MSG_V("m_unv = ${_UNV}")
  225. DBG_MSG_V("m_ucd = ${_UCD}")
  226. DBG_MSG_V("m_dbg = ${_DBG}")
  227. # FIXME: What if both regex libs are available. regex should be
  228. # found outside the loop and only wx${LIB}${_UCD}${_DBG}.
  229. # Find wxWidgets common libraries.
  230. FOREACH(LIB ${wxWidgets_COMMON_LIBRARIES})
  231. FIND_LIBRARY(WX_${LIB}${_DBG}
  232. NAMES
  233. wx${LIB}${_UCD}${_DBG} # for regex
  234. wx${LIB}${_DBG}
  235. PATHS ${WX_LIB_DIR}
  236. NO_DEFAULT_PATH
  237. )
  238. MARK_AS_ADVANCED(WX_${LIB}${_DBG})
  239. ENDFOREACH(LIB)
  240. # Find wxWidgets multilib base libraries.
  241. FIND_LIBRARY(WX_base${_DBG}
  242. NAMES
  243. wxbase29${_UCD}${_DBG}
  244. wxbase28${_UCD}${_DBG}
  245. wxbase27${_UCD}${_DBG}
  246. wxbase26${_UCD}${_DBG}
  247. wxbase25${_UCD}${_DBG}
  248. PATHS ${WX_LIB_DIR}
  249. NO_DEFAULT_PATH
  250. )
  251. MARK_AS_ADVANCED(WX_base${_DBG})
  252. FOREACH(LIB net odbc xml)
  253. FIND_LIBRARY(WX_${LIB}${_DBG}
  254. NAMES
  255. wxbase29${_UCD}${_DBG}_${LIB}
  256. wxbase28${_UCD}${_DBG}_${LIB}
  257. wxbase27${_UCD}${_DBG}_${LIB}
  258. wxbase26${_UCD}${_DBG}_${LIB}
  259. wxbase25${_UCD}${_DBG}_${LIB}
  260. PATHS ${WX_LIB_DIR}
  261. NO_DEFAULT_PATH
  262. )
  263. MARK_AS_ADVANCED(WX_${LIB}${_DBG})
  264. ENDFOREACH(LIB)
  265. # Find wxWidgets monolithic library.
  266. FIND_LIBRARY(WX_mono${_DBG}
  267. NAMES
  268. wxmsw${_UNV}29${_UCD}${_DBG}
  269. wxmsw${_UNV}28${_UCD}${_DBG}
  270. wxmsw${_UNV}27${_UCD}${_DBG}
  271. wxmsw${_UNV}26${_UCD}${_DBG}
  272. wxmsw${_UNV}25${_UCD}${_DBG}
  273. PATHS ${WX_LIB_DIR}
  274. NO_DEFAULT_PATH
  275. )
  276. MARK_AS_ADVANCED(WX_mono${_DBG})
  277. # Find wxWidgets multilib libraries.
  278. FOREACH(LIB core adv aui html media xrc dbgrid gl qa richtext)
  279. FIND_LIBRARY(WX_${LIB}${_DBG}
  280. NAMES
  281. wxmsw${_UNV}29${_UCD}${_DBG}_${LIB}
  282. wxmsw${_UNV}28${_UCD}${_DBG}_${LIB}
  283. wxmsw${_UNV}27${_UCD}${_DBG}_${LIB}
  284. wxmsw${_UNV}26${_UCD}${_DBG}_${LIB}
  285. wxmsw${_UNV}25${_UCD}${_DBG}_${LIB}
  286. PATHS ${WX_LIB_DIR}
  287. NO_DEFAULT_PATH
  288. )
  289. MARK_AS_ADVANCED(WX_${LIB}${_DBG})
  290. ENDFOREACH(LIB)
  291. ENDMACRO(WX_FIND_LIBS)
  292. #
  293. # Clear all library paths, so that FIND_LIBRARY refinds them.
  294. #
  295. # Clear a lib, reset its found flag, and mark as advanced.
  296. MACRO(WX_CLEAR_LIB _LIB)
  297. SET(${_LIB} "${_LIB}-NOTFOUND" CACHE FILEPATH "Cleared." FORCE)
  298. SET(${_LIB}_FOUND FALSE)
  299. MARK_AS_ADVANCED(${_LIB})
  300. ENDMACRO(WX_CLEAR_LIB)
  301. # Clear all debug or release library paths (arguments are "d" or "").
  302. MACRO(WX_CLEAR_ALL_LIBS _DBG)
  303. # Clear wxWidgets common libraries.
  304. FOREACH(LIB ${wxWidgets_COMMON_LIBRARIES})
  305. WX_CLEAR_LIB(WX_${LIB}${_DBG})
  306. ENDFOREACH(LIB)
  307. # Clear wxWidgets multilib base libraries.
  308. WX_CLEAR_LIB(WX_base${_DBG})
  309. FOREACH(LIB net odbc xml)
  310. WX_CLEAR_LIB(WX_${LIB}${_DBG})
  311. ENDFOREACH(LIB)
  312. # Clear wxWidgets monolithic library.
  313. WX_CLEAR_LIB(WX_mono${_DBG})
  314. # Clear wxWidgets multilib libraries.
  315. FOREACH(LIB core adv aui html media xrc dbgrid gl qa richtext)
  316. WX_CLEAR_LIB(WX_${LIB}${_DBG})
  317. ENDFOREACH(LIB)
  318. ENDMACRO(WX_CLEAR_ALL_LIBS)
  319. # Clear all wxWidgets debug libraries.
  320. MACRO(WX_CLEAR_ALL_DBG_LIBS)
  321. WX_CLEAR_ALL_LIBS("d")
  322. ENDMACRO(WX_CLEAR_ALL_DBG_LIBS)
  323. # Clear all wxWidgets release libraries.
  324. MACRO(WX_CLEAR_ALL_REL_LIBS)
  325. WX_CLEAR_ALL_LIBS("")
  326. ENDMACRO(WX_CLEAR_ALL_REL_LIBS)
  327. #
  328. # Set the wxWidgets_LIBRARIES variable.
  329. # Also, Sets output variable wxWidgets_FOUND to FALSE if it fails.
  330. #
  331. MACRO(WX_SET_LIBRARIES _LIBS _DBG)
  332. DBG_MSG_V("Looking for ${${_LIBS}}")
  333. IF(WX_USE_REL_AND_DBG)
  334. FOREACH(LIB ${${_LIBS}})
  335. DBG_MSG_V("Searching for ${LIB} and ${LIB}d")
  336. DBG_MSG_V("WX_${LIB} : ${WX_${LIB}}")
  337. DBG_MSG_V("WX_${LIB}d : ${WX_${LIB}d}")
  338. IF(WX_${LIB} AND WX_${LIB}d)
  339. DBG_MSG_V("Found ${LIB} and ${LIB}d")
  340. LIST(APPEND wxWidgets_LIBRARIES
  341. debug ${WX_${LIB}d} optimized ${WX_${LIB}}
  342. )
  343. ELSE(WX_${LIB} AND WX_${LIB}d)
  344. DBG_MSG_V("- not found due to missing WX_${LIB}=${WX_${LIB}} or WX_${LIB}d=${WX_${LIB}d}")
  345. SET(wxWidgets_FOUND FALSE)
  346. ENDIF(WX_${LIB} AND WX_${LIB}d)
  347. ENDFOREACH(LIB)
  348. ELSE(WX_USE_REL_AND_DBG)
  349. FOREACH(LIB ${${_LIBS}})
  350. DBG_MSG_V("Searching for ${LIB}${_DBG}")
  351. DBG_MSG_V("WX_${LIB}${_DBG} : ${WX_${LIB}${_DBG}}")
  352. IF(WX_${LIB}${_DBG})
  353. DBG_MSG_V("Found ${LIB}${_DBG}")
  354. LIST(APPEND wxWidgets_LIBRARIES ${WX_${LIB}${_DBG}})
  355. ELSE(WX_${LIB}${_DBG})
  356. DBG_MSG_V(
  357. "- not found due to missing WX_${LIB}${_DBG}=${WX_${LIB}${_DBG}}")
  358. SET(wxWidgets_FOUND FALSE)
  359. ENDIF(WX_${LIB}${_DBG})
  360. ENDFOREACH(LIB)
  361. ENDIF(WX_USE_REL_AND_DBG)
  362. DBG_MSG_V("OpenGL")
  363. LIST(FIND ${_LIBS} gl WX_USE_GL)
  364. IF(NOT WX_USE_GL EQUAL -1)
  365. DBG_MSG_V("- is required.")
  366. LIST(APPEND wxWidgets_LIBRARIES opengl32 glu32)
  367. ENDIF(NOT WX_USE_GL EQUAL -1)
  368. LIST(APPEND wxWidgets_LIBRARIES winmm comctl32 rpcrt4 wsock32)
  369. ENDMACRO(WX_SET_LIBRARIES)
  370. #-------------------------------------------------------------------
  371. # WIN32: Start actual work.
  372. #-------------------------------------------------------------------
  373. # Look for an installation tree.
  374. FIND_PATH(wxWidgets_ROOT_DIR
  375. NAMES include/wx/wx.h
  376. PATHS
  377. $ENV{wxWidgets_ROOT_DIR}
  378. $ENV{WXWIN}
  379. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\wxWidgets_is1;Inno Setup: App Path]" # WX 2.6.x
  380. C:/
  381. D:/
  382. $ENV{ProgramFiles}
  383. PATH_SUFFIXES
  384. wxWidgets-2.9.4
  385. wxWidgets-2.9.3
  386. wxWidgets-2.9.2
  387. wxWidgets-2.9.1
  388. wxWidgets-2.9.0
  389. wxWidgets-2.8.9
  390. wxWidgets-2.8.8
  391. wxWidgets-2.8.7
  392. wxWidgets-2.8.6
  393. wxWidgets-2.8.5
  394. wxWidgets-2.8.4
  395. wxWidgets-2.8.3
  396. wxWidgets-2.8.2
  397. wxWidgets-2.8.1
  398. wxWidgets-2.8.0
  399. wxWidgets-2.7.4
  400. wxWidgets-2.7.3
  401. wxWidgets-2.7.2
  402. wxWidgets-2.7.1
  403. wxWidgets-2.7.0
  404. wxWidgets-2.7.0-1
  405. wxWidgets-2.6.4
  406. wxWidgets-2.6.3
  407. wxWidgets-2.6.2
  408. wxWidgets-2.6.1
  409. wxWidgets-2.5.4
  410. wxWidgets-2.5.3
  411. wxWidgets-2.5.2
  412. wxWidgets-2.5.1
  413. wxWidgets
  414. DOC "wxWidgets base/installation directory?"
  415. )
  416. # If wxWidgets_ROOT_DIR changed, clear lib dir.
  417. IF(NOT WX_ROOT_DIR STREQUAL wxWidgets_ROOT_DIR)
  418. SET(WX_ROOT_DIR ${wxWidgets_ROOT_DIR}
  419. CACHE INTERNAL "wxWidgets_ROOT_DIR")
  420. SET(wxWidgets_LIB_DIR "wxWidgets_LIB_DIR-NOTFOUND"
  421. CACHE PATH "Cleared." FORCE)
  422. ENDIF(NOT WX_ROOT_DIR STREQUAL wxWidgets_ROOT_DIR)
  423. IF(WX_ROOT_DIR)
  424. # Select one default tree inside the already determined wx tree.
  425. # Prefer static/shared order usually consistent with build
  426. # settings.
  427. IF(MINGW)
  428. SET(WX_LIB_DIR_PREFIX gcc)
  429. ELSE(MINGW)
  430. SET(WX_LIB_DIR_PREFIX vc)
  431. ENDIF(MINGW)
  432. IF(BUILD_SHARED_LIBS)
  433. FIND_PATH(wxWidgets_LIB_DIR
  434. NAMES
  435. msw/wx/setup.h
  436. mswd/wx/setup.h
  437. mswu/wx/setup.h
  438. mswud/wx/setup.h
  439. mswuniv/wx/setup.h
  440. mswunivd/wx/setup.h
  441. mswunivu/wx/setup.h
  442. mswunivud/wx/setup.h
  443. PATHS
  444. ${WX_ROOT_DIR}/lib/${WX_LIB_DIR_PREFIX}_dll # prefer shared
  445. ${WX_ROOT_DIR}/lib/${WX_LIB_DIR_PREFIX}_lib
  446. DOC "Path to wxWidgets libraries?"
  447. NO_DEFAULT_PATH
  448. )
  449. ELSE(BUILD_SHARED_LIBS)
  450. FIND_PATH(wxWidgets_LIB_DIR
  451. NAMES
  452. msw/wx/setup.h
  453. mswd/wx/setup.h
  454. mswu/wx/setup.h
  455. mswud/wx/setup.h
  456. mswuniv/wx/setup.h
  457. mswunivd/wx/setup.h
  458. mswunivu/wx/setup.h
  459. mswunivud/wx/setup.h
  460. PATHS
  461. ${WX_ROOT_DIR}/lib/${WX_LIB_DIR_PREFIX}_lib # prefer static
  462. ${WX_ROOT_DIR}/lib/${WX_LIB_DIR_PREFIX}_dll
  463. DOC "Path to wxWidgets libraries?"
  464. NO_DEFAULT_PATH
  465. )
  466. ENDIF(BUILD_SHARED_LIBS)
  467. # If wxWidgets_LIB_DIR changed, clear all libraries.
  468. IF(NOT WX_LIB_DIR STREQUAL wxWidgets_LIB_DIR)
  469. SET(WX_LIB_DIR ${wxWidgets_LIB_DIR} CACHE INTERNAL "wxWidgets_LIB_DIR")
  470. WX_CLEAR_ALL_DBG_LIBS()
  471. WX_CLEAR_ALL_REL_LIBS()
  472. ENDIF(NOT WX_LIB_DIR STREQUAL wxWidgets_LIB_DIR)
  473. IF(WX_LIB_DIR)
  474. # If building shared libs, define WXUSINGDLL to use dllimport.
  475. IF(WX_LIB_DIR MATCHES ".*[dD][lL][lL].*")
  476. SET(wxWidgets_DEFINITIONS WXUSINGDLL)
  477. DBG_MSG_V("detected SHARED/DLL tree WX_LIB_DIR=${WX_LIB_DIR}")
  478. ENDIF(WX_LIB_DIR MATCHES ".*[dD][lL][lL].*")
  479. # Search for available configuration types.
  480. FOREACH(CFG mswunivud mswunivd mswud mswd mswunivu mswuniv mswu msw)
  481. SET(WX_${CFG}_FOUND FALSE)
  482. IF(EXISTS ${WX_LIB_DIR}/${CFG})
  483. LIST(APPEND WX_CONFIGURATION_LIST ${CFG})
  484. SET(WX_${CFG}_FOUND TRUE)
  485. SET(WX_CONFIGURATION ${CFG})
  486. ENDIF(EXISTS ${WX_LIB_DIR}/${CFG})
  487. ENDFOREACH(CFG)
  488. DBG_MSG_V("WX_CONFIGURATION_LIST=${WX_CONFIGURATION_LIST}")
  489. IF(WX_CONFIGURATION)
  490. SET(wxWidgets_FOUND TRUE)
  491. # If the selected configuration wasn't found force the default
  492. # one. Otherwise, use it but still force a refresh for
  493. # updating the doc string with the current list of available
  494. # configurations.
  495. IF(NOT WX_${wxWidgets_CONFIGURATION}_FOUND)
  496. SET(wxWidgets_CONFIGURATION ${WX_CONFIGURATION} CACHE STRING
  497. "Set wxWidgets configuration (${WX_CONFIGURATION_LIST})" FORCE)
  498. ELSE(NOT WX_${wxWidgets_CONFIGURATION}_FOUND)
  499. SET(wxWidgets_CONFIGURATION ${wxWidgets_CONFIGURATION} CACHE STRING
  500. "Set wxWidgets configuration (${WX_CONFIGURATION_LIST})" FORCE)
  501. ENDIF(NOT WX_${wxWidgets_CONFIGURATION}_FOUND)
  502. # If release config selected, and both release/debug exist.
  503. IF(WX_${wxWidgets_CONFIGURATION}d_FOUND)
  504. OPTION(wxWidgets_USE_REL_AND_DBG
  505. "Use release and debug configurations?" TRUE)
  506. SET(WX_USE_REL_AND_DBG ${wxWidgets_USE_REL_AND_DBG})
  507. ELSE(WX_${wxWidgets_CONFIGURATION}d_FOUND)
  508. # If the option exists (already in cache), force it false.
  509. IF(wxWidgets_USE_REL_AND_DBG)
  510. SET(wxWidgets_USE_REL_AND_DBG FALSE CACHE BOOL
  511. "No ${wxWidgets_CONFIGURATION}d found." FORCE)
  512. ENDIF(wxWidgets_USE_REL_AND_DBG)
  513. SET(WX_USE_REL_AND_DBG FALSE)
  514. ENDIF(WX_${wxWidgets_CONFIGURATION}d_FOUND)
  515. # Get configuration parameters from the name.
  516. WX_GET_NAME_COMPONENTS(${wxWidgets_CONFIGURATION} UNV UCD DBG)
  517. # Set wxWidgets main include directory.
  518. IF(EXISTS ${WX_ROOT_DIR}/include/wx/wx.h)
  519. SET(wxWidgets_INCLUDE_DIRS ${WX_ROOT_DIR}/include)
  520. ELSE(EXISTS ${WX_ROOT_DIR}/include/wx/wx.h)
  521. DBG_MSG("wxWidgets_FOUND FALSE because WX_ROOT_DIR=${WX_ROOT_DIR} has no ${WX_ROOT_DIR}/include/wx/wx.h")
  522. SET(wxWidgets_FOUND FALSE)
  523. ENDIF(EXISTS ${WX_ROOT_DIR}/include/wx/wx.h)
  524. # Set wxWidgets lib setup include directory.
  525. IF(EXISTS ${WX_LIB_DIR}/${wxWidgets_CONFIGURATION}/wx/setup.h)
  526. LIST(APPEND wxWidgets_INCLUDE_DIRS
  527. ${WX_LIB_DIR}/${wxWidgets_CONFIGURATION})
  528. ELSE(EXISTS ${WX_LIB_DIR}/${wxWidgets_CONFIGURATION}/wx/setup.h)
  529. DBG_MSG("WXWIDGET_FOUND FALSE because ${WX_LIB_DIR}/${wxWidgets_CONFIGURATION}/wx/setup.h does not exists.")
  530. SET(wxWidgets_FOUND FALSE)
  531. ENDIF(EXISTS ${WX_LIB_DIR}/${wxWidgets_CONFIGURATION}/wx/setup.h)
  532. # Find wxWidgets libraries.
  533. WX_FIND_LIBS("${UNV}" "${UCD}" "${DBG}")
  534. IF(WX_USE_REL_AND_DBG)
  535. WX_FIND_LIBS("${UNV}" "${UCD}" "d")
  536. ENDIF(WX_USE_REL_AND_DBG)
  537. # Settings for requested libs (i.e., include dir, libraries, etc.).
  538. WX_SET_LIBRARIES(wxWidgets_FIND_COMPONENTS "${DBG}")
  539. # Add necessary definitions for unicode builds
  540. IF("${UCD}" STREQUAL "u")
  541. LIST(APPEND wxWidgets_DEFINITIONS UNICODE _UNICODE)
  542. ENDIF("${UCD}" STREQUAL "u")
  543. # Add necessary definitions for debug builds
  544. SET(wxWidgets_DEFINITIONS_DEBUG _DEBUG __WXDEBUG__)
  545. ENDIF(WX_CONFIGURATION)
  546. ENDIF(WX_LIB_DIR)
  547. ENDIF(WX_ROOT_DIR)
  548. #=====================================================================
  549. # UNIX_FIND_STYLE
  550. #=====================================================================
  551. ELSE(wxWidgets_FIND_STYLE STREQUAL "win32")
  552. IF(wxWidgets_FIND_STYLE STREQUAL "unix")
  553. #-----------------------------------------------------------------
  554. # UNIX: Helper MACROS
  555. #-----------------------------------------------------------------
  556. #
  557. # Set the default values based on "wx-config --selected-config".
  558. #
  559. MACRO(WX_CONFIG_SELECT_GET_DEFAULT)
  560. EXECUTE_PROCESS(
  561. COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}" --selected-config
  562. OUTPUT_VARIABLE _wx_selected_config
  563. RESULT_VARIABLE _wx_result
  564. ERROR_QUIET
  565. )
  566. IF(_wx_result EQUAL 0)
  567. FOREACH(_opt_name debug static unicode universal)
  568. STRING(TOUPPER ${_opt_name} _upper_opt_name)
  569. IF(_wx_selected_config MATCHES ".*${_opt_name}.*")
  570. SET(wxWidgets_DEFAULT_${_upper_opt_name} ON)
  571. ELSE(_wx_selected_config MATCHES ".*${_opt_name}.*")
  572. SET(wxWidgets_DEFAULT_${_upper_opt_name} OFF)
  573. ENDIF(_wx_selected_config MATCHES ".*${_opt_name}.*")
  574. ENDFOREACH(_opt_name)
  575. ELSE(_wx_result EQUAL 0)
  576. FOREACH(_upper_opt_name DEBUG STATIC UNICODE UNIVERSAL)
  577. SET(wxWidgets_DEFAULT_${_upper_opt_name} OFF)
  578. ENDFOREACH(_upper_opt_name)
  579. ENDIF(_wx_result EQUAL 0)
  580. ENDMACRO(WX_CONFIG_SELECT_GET_DEFAULT)
  581. #
  582. # Query a boolean configuration option to determine if the system
  583. # has both builds available. If so, provide the selection option
  584. # to the user.
  585. #
  586. MACRO(WX_CONFIG_SELECT_QUERY_BOOL _OPT_NAME _OPT_HELP)
  587. EXECUTE_PROCESS(
  588. COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}" --${_OPT_NAME}=yes
  589. RESULT_VARIABLE _wx_result_yes
  590. OUTPUT_QUIET
  591. ERROR_QUIET
  592. )
  593. EXECUTE_PROCESS(
  594. COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}" --${_OPT_NAME}=no
  595. RESULT_VARIABLE _wx_result_no
  596. OUTPUT_QUIET
  597. ERROR_QUIET
  598. )
  599. STRING(TOUPPER ${_OPT_NAME} _UPPER_OPT_NAME)
  600. IF(_wx_result_yes EQUAL 0 AND _wx_result_no EQUAL 0)
  601. OPTION(wxWidgets_USE_${_UPPER_OPT_NAME}
  602. ${_OPT_HELP} ${wxWidgets_DEFAULT_${_UPPER_OPT_NAME}})
  603. ELSE(_wx_result_yes EQUAL 0 AND _wx_result_no EQUAL 0)
  604. # If option exists (already in cache), force to available one.
  605. IF(DEFINED wxWidgets_USE_${_UPPER_OPT_NAME})
  606. IF(_wx_result_yes EQUAL 0)
  607. SET(wxWidgets_USE_${_UPPER_OPT_NAME} ON CACHE BOOL ${_OPT_HELP} FORCE)
  608. ELSE(_wx_result_yes EQUAL 0)
  609. SET(wxWidgets_USE_${_UPPER_OPT_NAME} OFF CACHE BOOL ${_OPT_HELP} FORCE)
  610. ENDIF(_wx_result_yes EQUAL 0)
  611. ENDIF(DEFINED wxWidgets_USE_${_UPPER_OPT_NAME})
  612. ENDIF(_wx_result_yes EQUAL 0 AND _wx_result_no EQUAL 0)
  613. ENDMACRO(WX_CONFIG_SELECT_QUERY_BOOL)
  614. #
  615. # Set wxWidgets_SELECT_OPTIONS to wx-config options for selecting
  616. # among multiple builds.
  617. #
  618. MACRO(WX_CONFIG_SELECT_SET_OPTIONS)
  619. SET(wxWidgets_SELECT_OPTIONS "")
  620. FOREACH(_opt_name debug static unicode universal)
  621. STRING(TOUPPER ${_opt_name} _upper_opt_name)
  622. IF(DEFINED wxWidgets_USE_${_upper_opt_name})
  623. IF(wxWidgets_USE_${_upper_opt_name})
  624. LIST(APPEND wxWidgets_SELECT_OPTIONS --${_opt_name}=yes)
  625. ELSE(wxWidgets_USE_${_upper_opt_name})
  626. LIST(APPEND wxWidgets_SELECT_OPTIONS --${_opt_name}=no)
  627. ENDIF(wxWidgets_USE_${_upper_opt_name})
  628. ENDIF(DEFINED wxWidgets_USE_${_upper_opt_name})
  629. ENDFOREACH(_opt_name)
  630. ENDMACRO(WX_CONFIG_SELECT_SET_OPTIONS)
  631. #-----------------------------------------------------------------
  632. # UNIX: Start actual work.
  633. #-----------------------------------------------------------------
  634. # Support cross-compiling, only search in the target platform.
  635. FIND_PROGRAM(wxWidgets_CONFIG_EXECUTABLE wx-config
  636. ONLY_CMAKE_FIND_ROOT_PATH
  637. )
  638. IF(wxWidgets_CONFIG_EXECUTABLE)
  639. SET(wxWidgets_FOUND TRUE)
  640. # get defaults based on "wx-config --selected-config"
  641. WX_CONFIG_SELECT_GET_DEFAULT()
  642. # for each option: if both builds are available, provide option
  643. WX_CONFIG_SELECT_QUERY_BOOL(debug "Use debug build?")
  644. WX_CONFIG_SELECT_QUERY_BOOL(unicode "Use unicode build?")
  645. WX_CONFIG_SELECT_QUERY_BOOL(universal "Use universal build?")
  646. WX_CONFIG_SELECT_QUERY_BOOL(static "Link libraries statically?")
  647. # process selection to set wxWidgets_SELECT_OPTIONS
  648. WX_CONFIG_SELECT_SET_OPTIONS()
  649. DBG_MSG("wxWidgets_SELECT_OPTIONS=${wxWidgets_SELECT_OPTIONS}")
  650. # run the wx-config program to get cxxflags
  651. EXECUTE_PROCESS(
  652. COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}"
  653. ${wxWidgets_SELECT_OPTIONS} --cxxflags
  654. OUTPUT_VARIABLE wxWidgets_CXX_FLAGS
  655. RESULT_VARIABLE RET
  656. ERROR_QUIET
  657. )
  658. IF(RET EQUAL 0)
  659. STRING(STRIP "${wxWidgets_CXX_FLAGS}" wxWidgets_CXX_FLAGS)
  660. SEPARATE_ARGUMENTS(wxWidgets_CXX_FLAGS)
  661. DBG_MSG_V("wxWidgets_CXX_FLAGS=${wxWidgets_CXX_FLAGS}")
  662. # parse definitions from cxxflags; drop -D* from CXXFLAGS and the -D prefix
  663. STRING(REGEX MATCHALL "-D[^;]+"
  664. wxWidgets_DEFINITIONS "${wxWidgets_CXX_FLAGS}")
  665. STRING(REGEX REPLACE "-D[^;]+;" ""
  666. wxWidgets_CXX_FLAGS "${wxWidgets_CXX_FLAGS}")
  667. STRING(REPLACE "-D" ""
  668. wxWidgets_DEFINITIONS "${wxWidgets_DEFINITIONS}")
  669. # parse include dirs from cxxflags; drop -I prefix
  670. STRING(REGEX MATCHALL "-I[^;]+"
  671. wxWidgets_INCLUDE_DIRS "${wxWidgets_CXX_FLAGS}")
  672. STRING(REGEX REPLACE "-I[^;]+;" ""
  673. wxWidgets_CXX_FLAGS "${wxWidgets_CXX_FLAGS}")
  674. STRING(REPLACE "-I" ""
  675. wxWidgets_INCLUDE_DIRS "${wxWidgets_INCLUDE_DIRS}")
  676. DBG_MSG_V("wxWidgets_DEFINITIONS=${wxWidgets_DEFINITIONS}")
  677. DBG_MSG_V("wxWidgets_INCLUDE_DIRS=${wxWidgets_INCLUDE_DIRS}")
  678. DBG_MSG_V("wxWidgets_CXX_FLAGS=${wxWidgets_CXX_FLAGS}")
  679. ELSE(RET EQUAL 0)
  680. SET(wxWidgets_FOUND FALSE)
  681. DBG_MSG_V(
  682. "${wxWidgets_CONFIG_EXECUTABLE} --cxxflags FAILED with RET=${RET}")
  683. ENDIF(RET EQUAL 0)
  684. # run the wx-config program to get the libs
  685. # - NOTE: wx-config doesn't verify that the libs requested exist
  686. # it just produces the names. Maybe a TRY_COMPILE would
  687. # be useful here...
  688. STRING(REPLACE ";" ","
  689. wxWidgets_FIND_COMPONENTS "${wxWidgets_FIND_COMPONENTS}")
  690. EXECUTE_PROCESS(
  691. COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}"
  692. ${wxWidgets_SELECT_OPTIONS} --libs ${wxWidgets_FIND_COMPONENTS}
  693. OUTPUT_VARIABLE wxWidgets_LIBRARIES
  694. RESULT_VARIABLE RET
  695. ERROR_QUIET
  696. )
  697. IF(RET EQUAL 0)
  698. STRING(STRIP "${wxWidgets_LIBRARIES}" wxWidgets_LIBRARIES)
  699. SEPARATE_ARGUMENTS(wxWidgets_LIBRARIES)
  700. STRING(REPLACE "-framework;" "-framework "
  701. wxWidgets_LIBRARIES "${wxWidgets_LIBRARIES}")
  702. STRING(REPLACE "-arch;" "-arch "
  703. wxWidgets_LIBRARIES "${wxWidgets_LIBRARIES}")
  704. STRING(REPLACE "-isysroot;" "-isysroot "
  705. wxWidgets_LIBRARIES "${wxWidgets_LIBRARIES}")
  706. # extract linkdirs (-L) for rpath (i.e., LINK_DIRECTORIES)
  707. STRING(REGEX MATCHALL "-L[^;]+"
  708. wxWidgets_LIBRARY_DIRS "${wxWidgets_LIBRARIES}")
  709. STRING(REPLACE "-L" ""
  710. wxWidgets_LIBRARY_DIRS "${wxWidgets_LIBRARY_DIRS}")
  711. DBG_MSG_V("wxWidgets_LIBRARIES=${wxWidgets_LIBRARIES}")
  712. DBG_MSG_V("wxWidgets_LIBRARY_DIRS=${wxWidgets_LIBRARY_DIRS}")
  713. ELSE(RET EQUAL 0)
  714. SET(wxWidgets_FOUND FALSE)
  715. DBG_MSG("${wxWidgets_CONFIG_EXECUTABLE} --libs ${wxWidgets_FIND_COMPONENTS} FAILED with RET=${RET}")
  716. ENDIF(RET EQUAL 0)
  717. ENDIF(wxWidgets_CONFIG_EXECUTABLE)
  718. #=====================================================================
  719. # Neither UNIX_FIND_STYLE, nor WIN32_FIND_STYLE
  720. #=====================================================================
  721. ELSE(wxWidgets_FIND_STYLE STREQUAL "unix")
  722. IF(NOT wxWidgets_FIND_QUIETLY)
  723. MESSAGE(STATUS
  724. "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): \n"
  725. " Platform unknown/unsupported. It's neither WIN32 nor UNIX "
  726. "find style."
  727. )
  728. ENDIF(NOT wxWidgets_FIND_QUIETLY)
  729. ENDIF(wxWidgets_FIND_STYLE STREQUAL "unix")
  730. ENDIF(wxWidgets_FIND_STYLE STREQUAL "win32")
  731. # Debug output:
  732. DBG_MSG("wxWidgets_FOUND : ${wxWidgets_FOUND}")
  733. DBG_MSG("wxWidgets_INCLUDE_DIRS : ${wxWidgets_INCLUDE_DIRS}")
  734. DBG_MSG("wxWidgets_LIBRARY_DIRS : ${wxWidgets_LIBRARY_DIRS}")
  735. DBG_MSG("wxWidgets_LIBRARIES : ${wxWidgets_LIBRARIES}")
  736. DBG_MSG("wxWidgets_CXX_FLAGS : ${wxWidgets_CXX_FLAGS}")
  737. DBG_MSG("wxWidgets_USE_FILE : ${wxWidgets_USE_FILE}")
  738. #=====================================================================
  739. #=====================================================================
  740. INCLUDE(FindPackageHandleStandardArgs)
  741. FIND_PACKAGE_HANDLE_STANDARD_ARGS(wxWidgets DEFAULT_MSG wxWidgets_FOUND)
  742. # Maintain consistency with all other variables.
  743. SET(wxWidgets_FOUND ${WXWIDGETS_FOUND})
  744. #=====================================================================
  745. # Macros for use in wxWidgets apps.
  746. # - This module will not fail to find wxWidgets based on the code
  747. # below. Hence, it's required to check for validity of:
  748. #
  749. # wxWidgets_wxrc_EXECUTABLE
  750. #=====================================================================
  751. # Resource file compiler.
  752. FIND_PROGRAM(wxWidgets_wxrc_EXECUTABLE wxrc
  753. ${wxWidgets_ROOT_DIR}/utils/wxrc/vc_msw
  754. )
  755. #
  756. # WX_SPLIT_ARGUMENTS_ON(<keyword> <left> <right> <arg1> <arg2> ...)
  757. #
  758. # Sets <left> and <right> to contain arguments to the left and right,
  759. # respectively, of <keyword>.
  760. #
  761. # Example usage:
  762. # FUNCTION(WXWIDGETS_ADD_RESOURCES outfiles)
  763. # WX_SPLIT_ARGUMENTS_ON(OPTIONS wxrc_files wxrc_options ${ARGN})
  764. # ...
  765. # ENDFUNCTION(WXWIDGETS_ADD_RESOURCES)
  766. #
  767. # WXWIDGETS_ADD_RESOURCES(sources ${xrc_files} OPTIONS -e -o file.C)
  768. #
  769. # NOTE: This is a generic piece of code that should be renamed to
  770. # SPLIT_ARGUMENTS_ON and put in a file serving the same purpose as
  771. # FindPackageStandardArgs.cmake. At the time of this writing
  772. # FindQt4.cmake has a QT4_EXTRACT_OPTIONS, which I basically copied
  773. # here a bit more generalized. So, there are already two find modules
  774. # using this approach.
  775. #
  776. FUNCTION(WX_SPLIT_ARGUMENTS_ON _keyword _leftvar _rightvar)
  777. # FIXME: Document that the input variables will be cleared.
  778. #LIST(APPEND ${_leftvar} "")
  779. #LIST(APPEND ${_rightvar} "")
  780. SET(${_leftvar} "")
  781. SET(${_rightvar} "")
  782. SET(_doing_right FALSE)
  783. FOREACH(element ${ARGN})
  784. IF("${element}" STREQUAL "${_keyword}")
  785. SET(_doing_right TRUE)
  786. ELSE("${element}" STREQUAL "${_keyword}")
  787. IF(_doing_right)
  788. LIST(APPEND ${_rightvar} "${element}")
  789. ELSE(_doing_right)
  790. LIST(APPEND ${_leftvar} "${element}")
  791. ENDIF(_doing_right)
  792. ENDIF("${element}" STREQUAL "${_keyword}")
  793. ENDFOREACH(element)
  794. SET(${_leftvar} ${${_leftvar}} PARENT_SCOPE)
  795. SET(${_rightvar} ${${_rightvar}} PARENT_SCOPE)
  796. ENDFUNCTION(WX_SPLIT_ARGUMENTS_ON)
  797. #
  798. # WX_GET_DEPENDENCIES_FROM_XML(
  799. # <depends>
  800. # <match_pattern>
  801. # <clean_pattern>
  802. # <xml_contents>
  803. # <depends_path>
  804. # )
  805. #
  806. # FIXME: Add documentation here...
  807. #
  808. FUNCTION(WX_GET_DEPENDENCIES_FROM_XML
  809. _depends
  810. _match_patt
  811. _clean_patt
  812. _xml_contents
  813. _depends_path
  814. )
  815. STRING(REGEX MATCHALL
  816. ${_match_patt}
  817. dep_file_list
  818. "${${_xml_contents}}"
  819. )
  820. FOREACH(dep_file ${dep_file_list})
  821. STRING(REGEX REPLACE ${_clean_patt} "" dep_file "${dep_file}")
  822. # make the file have an absolute path
  823. IF(NOT IS_ABSOLUTE "${dep_file}")
  824. SET(dep_file "${${_depends_path}}/${dep_file}")
  825. ENDIF(NOT IS_ABSOLUTE "${dep_file}")
  826. # append file to dependency list
  827. LIST(APPEND ${_depends} "${dep_file}")
  828. ENDFOREACH(dep_file)
  829. SET(${_depends} ${${_depends}} PARENT_SCOPE)
  830. ENDFUNCTION(WX_GET_DEPENDENCIES_FROM_XML)
  831. #
  832. # WXWIDGETS_ADD_RESOURCES(<sources> <xrc_files>
  833. # OPTIONS <options> [NO_CPP_CODE])
  834. #
  835. # Adds a custom command for resource file compilation of the
  836. # <xrc_files> and appends the output files to <sources>.
  837. #
  838. # Example usages:
  839. # WXWIDGETS_ADD_RESOURCES(sources xrc/main_frame.xrc)
  840. # WXWIDGETS_ADD_RESOURCES(sources ${xrc_files} OPTIONS -e -o altname.cxx)
  841. #
  842. FUNCTION(WXWIDGETS_ADD_RESOURCES _outfiles)
  843. WX_SPLIT_ARGUMENTS_ON(OPTIONS rc_file_list rc_options ${ARGN})
  844. # Parse files for dependencies.
  845. SET(rc_file_list_abs "")
  846. SET(rc_depends "")
  847. FOREACH(rc_file ${rc_file_list})
  848. GET_FILENAME_COMPONENT(depends_path ${rc_file} PATH)
  849. GET_FILENAME_COMPONENT(rc_file_abs ${rc_file} ABSOLUTE)
  850. LIST(APPEND rc_file_list_abs "${rc_file_abs}")
  851. # All files have absolute paths or paths relative to the location
  852. # of the rc file.
  853. FILE(READ "${rc_file_abs}" rc_file_contents)
  854. # get bitmap/bitmap2 files
  855. WX_GET_DEPENDENCIES_FROM_XML(
  856. rc_depends
  857. "<bitmap[^<]+"
  858. "^<bitmap[^>]*>"
  859. rc_file_contents
  860. depends_path
  861. )
  862. # get url files
  863. WX_GET_DEPENDENCIES_FROM_XML(
  864. rc_depends
  865. "<url[^<]+"
  866. "^<url[^>]*>"
  867. rc_file_contents
  868. depends_path
  869. )
  870. # get wxIcon files
  871. WX_GET_DEPENDENCIES_FROM_XML(
  872. rc_depends
  873. "<object[^>]*class=\"wxIcon\"[^<]+"
  874. "^<object[^>]*>"
  875. rc_file_contents
  876. depends_path
  877. )
  878. ENDFOREACH(rc_file)
  879. #
  880. # Parse options.
  881. #
  882. # If NO_CPP_CODE option specified, then produce .xrs file rather
  883. # than a .cpp file (i.e., don't add the default --cpp-code option).
  884. LIST(FIND rc_options NO_CPP_CODE index)
  885. IF(index EQUAL -1)
  886. LIST(APPEND rc_options --cpp-code)
  887. # wxrc's default output filename for cpp code.
  888. SET(outfile resource.cpp)
  889. ELSE(index EQUAL -1)
  890. LIST(REMOVE_AT rc_options ${index})
  891. # wxrc's default output filename for xrs file.
  892. SET(outfile resource.xrs)
  893. ENDIF(index EQUAL -1)
  894. # Get output name for use in ADD_CUSTOM_COMMAND.
  895. # - short option scanning
  896. LIST(FIND rc_options -o index)
  897. IF(NOT index EQUAL -1)
  898. MATH(EXPR filename_index "${index} + 1")
  899. LIST(GET rc_options ${filename_index} outfile)
  900. #LIST(REMOVE_AT rc_options ${index} ${filename_index})
  901. ENDIF(NOT index EQUAL -1)
  902. # - long option scanning
  903. STRING(REGEX MATCH "--output=[^;]*" outfile_opt "${rc_options}")
  904. IF(outfile_opt)
  905. STRING(REPLACE "--output=" "" outfile "${outfile_opt}")
  906. ENDIF(outfile_opt)
  907. #STRING(REGEX REPLACE "--output=[^;]*;?" "" rc_options "${rc_options}")
  908. #STRING(REGEX REPLACE ";$" "" rc_options "${rc_options}")
  909. IF(NOT IS_ABSOLUTE "${outfile}")
  910. SET(outfile "${CMAKE_CURRENT_BINARY_DIR}/${outfile}")
  911. ENDIF(NOT IS_ABSOLUTE "${outfile}")
  912. ADD_CUSTOM_COMMAND(
  913. OUTPUT "${outfile}"
  914. COMMAND ${wxWidgets_wxrc_EXECUTABLE} ${rc_options} ${rc_file_list_abs}
  915. DEPENDS ${rc_file_list_abs} ${rc_depends}
  916. )
  917. # Add generated header to output file list.
  918. LIST(FIND rc_options -e short_index)
  919. LIST(FIND rc_options --extra-cpp-code long_index)
  920. IF(NOT short_index EQUAL -1 OR NOT long_index EQUAL -1)
  921. GET_FILENAME_COMPONENT(outfile_ext ${outfile} EXT)
  922. STRING(REPLACE "${outfile_ext}" ".h" outfile_header "${outfile}")
  923. LIST(APPEND ${_outfiles} "${outfile_header}")
  924. SET_SOURCE_FILES_PROPERTIES(
  925. "${outfile_header}" PROPERTIES GENERATED TRUE
  926. )
  927. ENDIF(NOT short_index EQUAL -1 OR NOT long_index EQUAL -1)
  928. # Add generated file to output file list.
  929. LIST(APPEND ${_outfiles} "${outfile}")
  930. SET(${_outfiles} ${${_outfiles}} PARENT_SCOPE)
  931. ENDFUNCTION(WXWIDGETS_ADD_RESOURCES)