FindwxWidgets.cmake 37 KB

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