You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1044 lines
39 KiB

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