FindwxWidgets.cmake 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. #[=======================================================================[.rst:
  4. FindwxWidgets
  5. -------------
  6. Find a wxWidgets (a.k.a., wxWindows) installation.
  7. This module finds if wxWidgets is installed and selects a default
  8. configuration to use. wxWidgets is a modular library. To specify the
  9. modules that you will use, you need to name them as components to the
  10. package:
  11. find_package(wxWidgets COMPONENTS core base ... OPTIONAL_COMPONENTS net ...)
  12. There are two search branches: a windows style and a unix style. For
  13. windows, the following variables are searched for and set to defaults
  14. in case of multiple choices. Change them if the defaults are not
  15. desired (i.e., these are the only variables you should change to
  16. select a configuration):
  17. ::
  18. wxWidgets_ROOT_DIR - Base wxWidgets directory
  19. (e.g., C:/wxWidgets-2.6.3).
  20. wxWidgets_LIB_DIR - Path to wxWidgets libraries
  21. (e.g., C:/wxWidgets-2.6.3/lib/vc_lib).
  22. wxWidgets_CONFIGURATION - Configuration to use
  23. (e.g., msw, mswd, mswu, mswunivud, etc.)
  24. wxWidgets_EXCLUDE_COMMON_LIBRARIES
  25. - Set to TRUE to exclude linking of
  26. commonly required libs (e.g., png tiff
  27. jpeg zlib regex expat).
  28. For unix style it uses the wx-config utility. You can select between
  29. debug/release, unicode/ansi, universal/non-universal, and
  30. static/shared in the QtDialog or ccmake interfaces by turning ON/OFF
  31. the following variables:
  32. ::
  33. wxWidgets_USE_DEBUG
  34. wxWidgets_USE_UNICODE
  35. wxWidgets_USE_UNIVERSAL
  36. wxWidgets_USE_STATIC
  37. There is also a wxWidgets_CONFIG_OPTIONS variable for all other
  38. options that need to be passed to the wx-config utility. For example,
  39. to use the base toolkit found in the /usr/local path, set the variable
  40. (before calling the FIND_PACKAGE command) as such:
  41. ::
  42. set(wxWidgets_CONFIG_OPTIONS --toolkit=base --prefix=/usr)
  43. The following are set after the configuration is done for both windows
  44. 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. Sample usage:
  63. ::
  64. # Note that for MinGW users the order of libs is important!
  65. find_package(wxWidgets COMPONENTS gl core base OPTIONAL_COMPONENTS net)
  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()
  71. If wxWidgets is required (i.e., not an optional part):
  72. ::
  73. find_package(wxWidgets REQUIRED gl core base OPTIONAL_COMPONENTS net)
  74. include(${wxWidgets_USE_FILE})
  75. # and for each of your dependent executable/library targets:
  76. target_link_libraries(<YourTarget> ${wxWidgets_LIBRARIES})
  77. #]=======================================================================]
  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()
  132. macro(DBG_MSG_V _MSG)
  133. # message(STATUS
  134. # "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): ${_MSG}")
  135. endmacro()
  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. # DEPRECATED: This is a patch to support the DEPRECATED use of
  143. # wxWidgets_USE_LIBS.
  144. #
  145. # If wxWidgets_USE_LIBS is set:
  146. # - if using <components>, then override wxWidgets_USE_LIBS
  147. # - else set wxWidgets_FIND_COMPONENTS to wxWidgets_USE_LIBS
  148. if(wxWidgets_USE_LIBS AND NOT wxWidgets_FIND_COMPONENTS)
  149. set(wxWidgets_FIND_COMPONENTS ${wxWidgets_USE_LIBS})
  150. endif()
  151. DBG_MSG("wxWidgets_FIND_COMPONENTS : ${wxWidgets_FIND_COMPONENTS}")
  152. # Add the convenience use file if available.
  153. #
  154. # Get dir of this file which may reside in:
  155. # - CMAKE_MAKE_ROOT/Modules on CMake installation
  156. # - CMAKE_MODULE_PATH if user prefers his own specialized version
  157. set(wxWidgets_USE_FILE "")
  158. get_filename_component(
  159. wxWidgets_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
  160. # Prefer an existing customized version, but the user might override
  161. # the FindwxWidgets module and not the UsewxWidgets one.
  162. if(EXISTS "${wxWidgets_CURRENT_LIST_DIR}/UsewxWidgets.cmake")
  163. set(wxWidgets_USE_FILE
  164. "${wxWidgets_CURRENT_LIST_DIR}/UsewxWidgets.cmake")
  165. else()
  166. set(wxWidgets_USE_FILE UsewxWidgets)
  167. endif()
  168. #=====================================================================
  169. # Determine whether unix or win32 paths should be used
  170. #=====================================================================
  171. if(WIN32 AND NOT CYGWIN AND NOT MSYS AND NOT CMAKE_CROSSCOMPILING)
  172. set(wxWidgets_FIND_STYLE "win32")
  173. else()
  174. set(wxWidgets_FIND_STYLE "unix")
  175. endif()
  176. #=====================================================================
  177. # WIN32_FIND_STYLE
  178. #=====================================================================
  179. if(wxWidgets_FIND_STYLE STREQUAL "win32")
  180. # Useful common wx libs needed by almost all components.
  181. set(wxWidgets_COMMON_LIBRARIES png tiff jpeg zlib regex expat)
  182. # DEPRECATED: Use find_package(wxWidgets COMPONENTS mono) instead.
  183. if(NOT wxWidgets_FIND_COMPONENTS)
  184. if(wxWidgets_USE_MONOLITHIC)
  185. set(wxWidgets_FIND_COMPONENTS mono)
  186. else()
  187. set(wxWidgets_FIND_COMPONENTS core base) # this is default
  188. endif()
  189. endif()
  190. # Add the common (usually required libs) unless
  191. # wxWidgets_EXCLUDE_COMMON_LIBRARIES has been set.
  192. if(NOT wxWidgets_EXCLUDE_COMMON_LIBRARIES)
  193. list(APPEND wxWidgets_FIND_COMPONENTS
  194. ${wxWidgets_COMMON_LIBRARIES})
  195. endif()
  196. #-------------------------------------------------------------------
  197. # WIN32: Helper MACROS
  198. #-------------------------------------------------------------------
  199. #
  200. # Get filename components for a configuration. For example,
  201. # if _CONFIGURATION = mswunivud, then _PF="msw", _UNV=univ, _UCD=u _DBG=d
  202. # if _CONFIGURATION = mswu, then _PF="msw", _UNV="", _UCD=u _DBG=""
  203. #
  204. macro(WX_GET_NAME_COMPONENTS _CONFIGURATION _PF _UNV _UCD _DBG)
  205. DBG_MSG_V(${_CONFIGURATION})
  206. string(REGEX MATCH "univ" ${_UNV} "${_CONFIGURATION}")
  207. string(REGEX REPLACE "[msw|qt].*(u)[d]*$" "u" ${_UCD} "${_CONFIGURATION}")
  208. if(${_UCD} STREQUAL ${_CONFIGURATION})
  209. set(${_UCD} "")
  210. endif()
  211. string(REGEX MATCH "d$" ${_DBG} "${_CONFIGURATION}")
  212. string(REGEX MATCH "^[msw|qt]*" ${_PF} "${_CONFIGURATION}")
  213. endmacro()
  214. #
  215. # Find libraries associated to a configuration.
  216. #
  217. macro(WX_FIND_LIBS _PF _UNV _UCD _DBG)
  218. DBG_MSG_V("m_unv = ${_UNV}")
  219. DBG_MSG_V("m_ucd = ${_UCD}")
  220. DBG_MSG_V("m_dbg = ${_DBG}")
  221. # FIXME: What if both regex libs are available. regex should be
  222. # found outside the loop and only wx${LIB}${_UCD}${_DBG}.
  223. # Find wxWidgets common libraries.
  224. foreach(LIB ${wxWidgets_COMMON_LIBRARIES} scintilla)
  225. find_library(WX_${LIB}${_DBG}
  226. NAMES
  227. wx${LIB}${_UCD}${_DBG} # for regex
  228. wx${LIB}${_DBG}
  229. PATHS ${WX_LIB_DIR}
  230. NO_DEFAULT_PATH
  231. )
  232. mark_as_advanced(WX_${LIB}${_DBG})
  233. endforeach()
  234. # Find wxWidgets multilib base libraries.
  235. find_library(WX_base${_DBG}
  236. NAMES
  237. wxbase31${_UCD}${_DBG}
  238. wxbase30${_UCD}${_DBG}
  239. wxbase29${_UCD}${_DBG}
  240. wxbase28${_UCD}${_DBG}
  241. wxbase27${_UCD}${_DBG}
  242. wxbase26${_UCD}${_DBG}
  243. wxbase25${_UCD}${_DBG}
  244. PATHS ${WX_LIB_DIR}
  245. NO_DEFAULT_PATH
  246. )
  247. mark_as_advanced(WX_base${_DBG})
  248. foreach(LIB net odbc xml)
  249. find_library(WX_${LIB}${_DBG}
  250. NAMES
  251. wxbase31${_UCD}${_DBG}_${LIB}
  252. wxbase30${_UCD}${_DBG}_${LIB}
  253. wxbase29${_UCD}${_DBG}_${LIB}
  254. wxbase28${_UCD}${_DBG}_${LIB}
  255. wxbase27${_UCD}${_DBG}_${LIB}
  256. wxbase26${_UCD}${_DBG}_${LIB}
  257. wxbase25${_UCD}${_DBG}_${LIB}
  258. PATHS ${WX_LIB_DIR}
  259. NO_DEFAULT_PATH
  260. )
  261. mark_as_advanced(WX_${LIB}${_DBG})
  262. endforeach()
  263. # Find wxWidgets monolithic library.
  264. find_library(WX_mono${_DBG}
  265. NAMES
  266. wx${_PF}${_UNV}31${_UCD}${_DBG}
  267. wx${_PF}${_UNV}30${_UCD}${_DBG}
  268. wx${_PF}${_UNV}29${_UCD}${_DBG}
  269. wx${_PF}${_UNV}28${_UCD}${_DBG}
  270. wx${_PF}${_UNV}27${_UCD}${_DBG}
  271. wx${_PF}${_UNV}26${_UCD}${_DBG}
  272. wx${_PF}${_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. stc ribbon propgrid webview)
  280. find_library(WX_${LIB}${_DBG}
  281. NAMES
  282. wx${_PF}${_UNV}31${_UCD}${_DBG}_${LIB}
  283. wx${_PF}${_UNV}30${_UCD}${_DBG}_${LIB}
  284. wx${_PF}${_UNV}29${_UCD}${_DBG}_${LIB}
  285. wx${_PF}${_UNV}28${_UCD}${_DBG}_${LIB}
  286. wx${_PF}${_UNV}27${_UCD}${_DBG}_${LIB}
  287. wx${_PF}${_UNV}26${_UCD}${_DBG}_${LIB}
  288. wx${_PF}${_UNV}25${_UCD}${_DBG}_${LIB}
  289. PATHS ${WX_LIB_DIR}
  290. NO_DEFAULT_PATH
  291. )
  292. mark_as_advanced(WX_${LIB}${_DBG})
  293. endforeach()
  294. endmacro()
  295. #
  296. # Clear all library paths, so that FIND_LIBRARY refinds them.
  297. #
  298. # Clear a lib, reset its found flag, and mark as advanced.
  299. macro(WX_CLEAR_LIB _LIB)
  300. set(${_LIB} "${_LIB}-NOTFOUND" CACHE FILEPATH "Cleared." FORCE)
  301. set(${_LIB}_FOUND FALSE)
  302. mark_as_advanced(${_LIB})
  303. endmacro()
  304. # Clear all debug or release library paths (arguments are "d" or "").
  305. macro(WX_CLEAR_ALL_LIBS _DBG)
  306. # Clear wxWidgets common libraries.
  307. foreach(LIB ${wxWidgets_COMMON_LIBRARIES} scintilla)
  308. WX_CLEAR_LIB(WX_${LIB}${_DBG})
  309. endforeach()
  310. # Clear wxWidgets multilib base libraries.
  311. WX_CLEAR_LIB(WX_base${_DBG})
  312. foreach(LIB net odbc xml)
  313. WX_CLEAR_LIB(WX_${LIB}${_DBG})
  314. endforeach()
  315. # Clear wxWidgets monolithic library.
  316. WX_CLEAR_LIB(WX_mono${_DBG})
  317. # Clear wxWidgets multilib libraries.
  318. foreach(LIB core adv aui html media xrc dbgrid gl qa richtext
  319. webview stc ribbon propgrid)
  320. WX_CLEAR_LIB(WX_${LIB}${_DBG})
  321. endforeach()
  322. endmacro()
  323. # Clear all wxWidgets debug libraries.
  324. macro(WX_CLEAR_ALL_DBG_LIBS)
  325. WX_CLEAR_ALL_LIBS("d")
  326. endmacro()
  327. # Clear all wxWidgets release libraries.
  328. macro(WX_CLEAR_ALL_REL_LIBS)
  329. WX_CLEAR_ALL_LIBS("")
  330. endmacro()
  331. #
  332. # Set the wxWidgets_LIBRARIES variable.
  333. # Also, Sets output variable wxWidgets_FOUND to FALSE if it fails.
  334. #
  335. macro(WX_SET_LIBRARIES _LIBS _DBG)
  336. DBG_MSG_V("Looking for ${${_LIBS}}")
  337. if(WX_USE_REL_AND_DBG)
  338. foreach(LIB ${${_LIBS}})
  339. DBG_MSG_V("Searching for ${LIB} and ${LIB}d")
  340. DBG_MSG_V("WX_${LIB} : ${WX_${LIB}}")
  341. DBG_MSG_V("WX_${LIB}d : ${WX_${LIB}d}")
  342. if(WX_${LIB} AND WX_${LIB}d)
  343. DBG_MSG_V("Found ${LIB} and ${LIB}d")
  344. list(APPEND wxWidgets_LIBRARIES
  345. debug ${WX_${LIB}d} optimized ${WX_${LIB}}
  346. )
  347. set(wxWidgets_${LIB}_FOUND TRUE)
  348. elseif(NOT wxWidgets_FIND_REQUIRED_${LIB})
  349. DBG_MSG_V("- ignored optional missing WX_${LIB}=${WX_${LIB}} or WX_${LIB}d=${WX_${LIB}d}")
  350. else()
  351. DBG_MSG_V("- not found due to missing WX_${LIB}=${WX_${LIB}} or WX_${LIB}d=${WX_${LIB}d}")
  352. set(wxWidgets_FOUND FALSE)
  353. endif()
  354. endforeach()
  355. else()
  356. foreach(LIB ${${_LIBS}})
  357. DBG_MSG_V("Searching for ${LIB}${_DBG}")
  358. DBG_MSG_V("WX_${LIB}${_DBG} : ${WX_${LIB}${_DBG}}")
  359. if(WX_${LIB}${_DBG})
  360. DBG_MSG_V("Found ${LIB}${_DBG}")
  361. list(APPEND wxWidgets_LIBRARIES ${WX_${LIB}${_DBG}})
  362. set(wxWidgets_${LIB}_FOUND TRUE)
  363. elseif(NOT wxWidgets_FIND_REQUIRED_${LIB})
  364. DBG_MSG_V("- ignored optional missing WX_${LIB}${_DBG}=${WX_${LIB}${_DBG}}")
  365. else()
  366. DBG_MSG_V("- not found due to missing WX_${LIB}${_DBG}=${WX_${LIB}${_DBG}}")
  367. set(wxWidgets_FOUND FALSE)
  368. endif()
  369. endforeach()
  370. endif()
  371. DBG_MSG_V("OpenGL")
  372. list(FIND ${_LIBS} gl WX_USE_GL)
  373. if(NOT WX_USE_GL EQUAL -1)
  374. DBG_MSG_V("- is required.")
  375. list(APPEND wxWidgets_LIBRARIES opengl32 glu32)
  376. endif()
  377. list(APPEND wxWidgets_LIBRARIES winmm comctl32 uuid oleacc uxtheme rpcrt4 shlwapi version wsock32)
  378. endmacro()
  379. #-------------------------------------------------------------------
  380. # WIN32: Start actual work.
  381. #-------------------------------------------------------------------
  382. # Look for an installation tree.
  383. find_path(wxWidgets_ROOT_DIR
  384. NAMES include/wx/wx.h
  385. PATHS
  386. ENV wxWidgets_ROOT_DIR
  387. ENV WXWIN
  388. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\wxWidgets_is1;Inno Setup: App Path]" # WX 2.6.x
  389. C:/
  390. D:/
  391. ENV ProgramFiles
  392. PATH_SUFFIXES
  393. wxWidgets-3.1.0
  394. wxWidgets-3.0.2
  395. wxWidgets-3.0.1
  396. wxWidgets-3.0.0
  397. wxWidgets-2.9.5
  398. wxWidgets-2.9.4
  399. wxWidgets-2.9.3
  400. wxWidgets-2.9.2
  401. wxWidgets-2.9.1
  402. wxWidgets-2.9.0
  403. wxWidgets-2.8.9
  404. wxWidgets-2.8.8
  405. wxWidgets-2.8.7
  406. wxWidgets-2.8.6
  407. wxWidgets-2.8.5
  408. wxWidgets-2.8.4
  409. wxWidgets-2.8.3
  410. wxWidgets-2.8.2
  411. wxWidgets-2.8.1
  412. wxWidgets-2.8.0
  413. wxWidgets-2.7.4
  414. wxWidgets-2.7.3
  415. wxWidgets-2.7.2
  416. wxWidgets-2.7.1
  417. wxWidgets-2.7.0
  418. wxWidgets-2.7.0-1
  419. wxWidgets-2.6.4
  420. wxWidgets-2.6.3
  421. wxWidgets-2.6.2
  422. wxWidgets-2.6.1
  423. wxWidgets-2.5.4
  424. wxWidgets-2.5.3
  425. wxWidgets-2.5.2
  426. wxWidgets-2.5.1
  427. wxWidgets
  428. DOC "wxWidgets base/installation directory"
  429. )
  430. # If wxWidgets_ROOT_DIR changed, clear lib dir.
  431. if(NOT WX_ROOT_DIR STREQUAL wxWidgets_ROOT_DIR)
  432. set(WX_ROOT_DIR ${wxWidgets_ROOT_DIR}
  433. CACHE INTERNAL "wxWidgets_ROOT_DIR")
  434. set(wxWidgets_LIB_DIR "wxWidgets_LIB_DIR-NOTFOUND"
  435. CACHE PATH "Cleared." FORCE)
  436. endif()
  437. if(WX_ROOT_DIR)
  438. # Select one default tree inside the already determined wx tree.
  439. # Prefer static/shared order usually consistent with build
  440. # settings.
  441. set(_WX_TOOL "")
  442. set(_WX_TOOLVER "")
  443. set(_WX_ARCH "")
  444. if(MINGW)
  445. set(_WX_TOOL gcc)
  446. elseif(MSVC)
  447. set(_WX_TOOL vc)
  448. set(_WX_TOOLVER ${MSVC_TOOLSET_VERSION})
  449. # support for a lib/vc14x_x64_dll/ path from wxW 3.1.3 distribution
  450. string(REGEX REPLACE ".$" "x" _WX_TOOLVERx ${_WX_TOOLVER})
  451. if(CMAKE_SIZEOF_VOID_P EQUAL 8)
  452. set(_WX_ARCH _x64)
  453. endif()
  454. endif()
  455. if(BUILD_SHARED_LIBS)
  456. find_path(wxWidgets_LIB_DIR
  457. NAMES
  458. qtu/wx/setup.h
  459. qtud/wx/setup.h
  460. msw/wx/setup.h
  461. mswd/wx/setup.h
  462. mswu/wx/setup.h
  463. mswud/wx/setup.h
  464. mswuniv/wx/setup.h
  465. mswunivd/wx/setup.h
  466. mswunivu/wx/setup.h
  467. mswunivud/wx/setup.h
  468. PATHS
  469. ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVER}_xp${_WX_ARCH}_dll # prefer shared
  470. ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVER}${_WX_ARCH}_dll # prefer shared
  471. ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVERx}_xp${_WX_ARCH}_dll # prefer shared
  472. ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVERx}${_WX_ARCH}_dll # prefer shared
  473. ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_ARCH}_dll # prefer shared
  474. ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVER}_xp${_WX_ARCH}_lib
  475. ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVER}${_WX_ARCH}_lib
  476. ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVERx}_xp${_WX_ARCH}_lib
  477. ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVERx}${_WX_ARCH}_lib
  478. ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_ARCH}_lib
  479. DOC "Path to wxWidgets libraries"
  480. NO_DEFAULT_PATH
  481. )
  482. else()
  483. find_path(wxWidgets_LIB_DIR
  484. NAMES
  485. qtu/wx/setup.h
  486. qtud/wx/setup.h
  487. msw/wx/setup.h
  488. mswd/wx/setup.h
  489. mswu/wx/setup.h
  490. mswud/wx/setup.h
  491. mswuniv/wx/setup.h
  492. mswunivd/wx/setup.h
  493. mswunivu/wx/setup.h
  494. mswunivud/wx/setup.h
  495. PATHS
  496. ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVER}_xp${_WX_ARCH}_lib # prefer static
  497. ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVER}${_WX_ARCH}_lib # prefer static
  498. ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVERx}_xp${_WX_ARCH}_lib # prefer static
  499. ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVERx}${_WX_ARCH}_lib # prefer static
  500. ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_ARCH}_lib # prefer static
  501. ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVER}_xp${_WX_ARCH}_dll
  502. ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVER}${_WX_ARCH}_dll
  503. ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVERx}_xp${_WX_ARCH}_dll
  504. ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVERx}${_WX_ARCH}_dll
  505. ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_ARCH}_dll
  506. DOC "Path to wxWidgets libraries"
  507. NO_DEFAULT_PATH
  508. )
  509. endif()
  510. unset(_WX_TOOL)
  511. unset(_WX_TOOLVER)
  512. unset(_WX_ARCH)
  513. # If wxWidgets_LIB_DIR changed, clear all libraries.
  514. if(NOT WX_LIB_DIR STREQUAL wxWidgets_LIB_DIR)
  515. set(WX_LIB_DIR ${wxWidgets_LIB_DIR} CACHE INTERNAL "wxWidgets_LIB_DIR")
  516. WX_CLEAR_ALL_DBG_LIBS()
  517. WX_CLEAR_ALL_REL_LIBS()
  518. endif()
  519. if(WX_LIB_DIR)
  520. # If building shared libs, define WXUSINGDLL to use dllimport.
  521. if(WX_LIB_DIR MATCHES "[dD][lL][lL]")
  522. set(wxWidgets_DEFINITIONS WXUSINGDLL)
  523. DBG_MSG_V("detected SHARED/DLL tree WX_LIB_DIR=${WX_LIB_DIR}")
  524. endif()
  525. # Search for available configuration types.
  526. foreach(CFG mswunivud mswunivd mswud mswd mswunivu mswuniv mswu msw qt qtd qtu qtud)
  527. set(WX_${CFG}_FOUND FALSE)
  528. if(EXISTS ${WX_LIB_DIR}/${CFG})
  529. list(APPEND WX_CONFIGURATION_LIST ${CFG})
  530. set(WX_${CFG}_FOUND TRUE)
  531. set(WX_CONFIGURATION ${CFG})
  532. endif()
  533. endforeach()
  534. DBG_MSG_V("WX_CONFIGURATION_LIST=${WX_CONFIGURATION_LIST}")
  535. if(WX_CONFIGURATION)
  536. set(wxWidgets_FOUND TRUE)
  537. # If the selected configuration wasn't found force the default
  538. # one. Otherwise, use it but still force a refresh for
  539. # updating the doc string with the current list of available
  540. # configurations.
  541. if(NOT WX_${wxWidgets_CONFIGURATION}_FOUND)
  542. set(wxWidgets_CONFIGURATION ${WX_CONFIGURATION} CACHE STRING
  543. "Set wxWidgets configuration (${WX_CONFIGURATION_LIST})" FORCE)
  544. else()
  545. set(wxWidgets_CONFIGURATION ${wxWidgets_CONFIGURATION} CACHE STRING
  546. "Set wxWidgets configuration (${WX_CONFIGURATION_LIST})" FORCE)
  547. endif()
  548. # If release config selected, and both release/debug exist.
  549. if(WX_${wxWidgets_CONFIGURATION}d_FOUND)
  550. option(wxWidgets_USE_REL_AND_DBG
  551. "Use release and debug configurations?" TRUE)
  552. set(WX_USE_REL_AND_DBG ${wxWidgets_USE_REL_AND_DBG})
  553. else()
  554. # If the option exists (already in cache), force it false.
  555. if(wxWidgets_USE_REL_AND_DBG)
  556. set(wxWidgets_USE_REL_AND_DBG FALSE CACHE BOOL
  557. "No ${wxWidgets_CONFIGURATION}d found." FORCE)
  558. endif()
  559. set(WX_USE_REL_AND_DBG FALSE)
  560. endif()
  561. # Get configuration parameters from the name.
  562. WX_GET_NAME_COMPONENTS(${wxWidgets_CONFIGURATION} PF UNV UCD DBG)
  563. # Set wxWidgets lib setup include directory.
  564. if(EXISTS ${WX_LIB_DIR}/${wxWidgets_CONFIGURATION}/wx/setup.h)
  565. set(wxWidgets_INCLUDE_DIRS
  566. ${WX_LIB_DIR}/${wxWidgets_CONFIGURATION})
  567. else()
  568. DBG_MSG("wxWidgets_FOUND FALSE because ${WX_LIB_DIR}/${wxWidgets_CONFIGURATION}/wx/setup.h does not exists.")
  569. set(wxWidgets_FOUND FALSE)
  570. endif()
  571. # Set wxWidgets main include directory.
  572. if(EXISTS ${WX_ROOT_DIR}/include/wx/wx.h)
  573. list(APPEND wxWidgets_INCLUDE_DIRS ${WX_ROOT_DIR}/include)
  574. else()
  575. DBG_MSG("wxWidgets_FOUND FALSE because WX_ROOT_DIR=${WX_ROOT_DIR} has no ${WX_ROOT_DIR}/include/wx/wx.h")
  576. set(wxWidgets_FOUND FALSE)
  577. endif()
  578. # Find wxWidgets libraries.
  579. WX_FIND_LIBS("${PF}" "${UNV}" "${UCD}" "${DBG}")
  580. if(WX_USE_REL_AND_DBG)
  581. WX_FIND_LIBS("${PF}" "${UNV}" "${UCD}" "d")
  582. endif()
  583. # Settings for requested libs (i.e., include dir, libraries, etc.).
  584. WX_SET_LIBRARIES(wxWidgets_FIND_COMPONENTS "${DBG}")
  585. # Add necessary definitions for unicode builds
  586. if("${UCD}" STREQUAL "u")
  587. list(APPEND wxWidgets_DEFINITIONS UNICODE _UNICODE)
  588. endif()
  589. # Add necessary definitions for debug builds
  590. set(wxWidgets_DEFINITIONS_DEBUG _DEBUG __WXDEBUG__)
  591. endif()
  592. endif()
  593. endif()
  594. #=====================================================================
  595. # UNIX_FIND_STYLE
  596. #=====================================================================
  597. else()
  598. if(wxWidgets_FIND_STYLE STREQUAL "unix")
  599. #-----------------------------------------------------------------
  600. # UNIX: Helper MACROS
  601. #-----------------------------------------------------------------
  602. #
  603. # Set the default values based on "wx-config --selected-config".
  604. #
  605. macro(WX_CONFIG_SELECT_GET_DEFAULT)
  606. execute_process(
  607. COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}"
  608. ${wxWidgets_CONFIG_OPTIONS} --selected-config
  609. OUTPUT_VARIABLE _wx_selected_config
  610. RESULT_VARIABLE _wx_result
  611. ERROR_QUIET
  612. )
  613. if(_wx_result EQUAL 0)
  614. foreach(_opt_name debug static unicode universal)
  615. string(TOUPPER ${_opt_name} _upper_opt_name)
  616. if(_wx_selected_config MATCHES "${_opt_name}")
  617. set(wxWidgets_DEFAULT_${_upper_opt_name} ON)
  618. else()
  619. set(wxWidgets_DEFAULT_${_upper_opt_name} OFF)
  620. endif()
  621. endforeach()
  622. else()
  623. foreach(_upper_opt_name DEBUG STATIC UNICODE UNIVERSAL)
  624. set(wxWidgets_DEFAULT_${_upper_opt_name} OFF)
  625. endforeach()
  626. endif()
  627. endmacro()
  628. #
  629. # Query a boolean configuration option to determine if the system
  630. # has both builds available. If so, provide the selection option
  631. # to the user.
  632. #
  633. macro(WX_CONFIG_SELECT_QUERY_BOOL _OPT_NAME _OPT_HELP)
  634. execute_process(
  635. COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}"
  636. ${wxWidgets_CONFIG_OPTIONS} --${_OPT_NAME}=yes
  637. RESULT_VARIABLE _wx_result_yes
  638. OUTPUT_QUIET
  639. ERROR_QUIET
  640. )
  641. execute_process(
  642. COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}"
  643. ${wxWidgets_CONFIG_OPTIONS} --${_OPT_NAME}=no
  644. RESULT_VARIABLE _wx_result_no
  645. OUTPUT_QUIET
  646. ERROR_QUIET
  647. )
  648. string(TOUPPER ${_OPT_NAME} _UPPER_OPT_NAME)
  649. if(_wx_result_yes EQUAL 0 AND _wx_result_no EQUAL 0)
  650. option(wxWidgets_USE_${_UPPER_OPT_NAME}
  651. ${_OPT_HELP} ${wxWidgets_DEFAULT_${_UPPER_OPT_NAME}})
  652. else()
  653. # If option exists (already in cache), force to available one.
  654. if(DEFINED wxWidgets_USE_${_UPPER_OPT_NAME})
  655. if(_wx_result_yes EQUAL 0)
  656. set(wxWidgets_USE_${_UPPER_OPT_NAME} ON CACHE BOOL ${_OPT_HELP} FORCE)
  657. else()
  658. set(wxWidgets_USE_${_UPPER_OPT_NAME} OFF CACHE BOOL ${_OPT_HELP} FORCE)
  659. endif()
  660. endif()
  661. endif()
  662. endmacro()
  663. #
  664. # Set wxWidgets_SELECT_OPTIONS to wx-config options for selecting
  665. # among multiple builds.
  666. #
  667. macro(WX_CONFIG_SELECT_SET_OPTIONS)
  668. set(wxWidgets_SELECT_OPTIONS ${wxWidgets_CONFIG_OPTIONS})
  669. foreach(_opt_name debug static unicode universal)
  670. string(TOUPPER ${_opt_name} _upper_opt_name)
  671. if(DEFINED wxWidgets_USE_${_upper_opt_name})
  672. if(wxWidgets_USE_${_upper_opt_name})
  673. list(APPEND wxWidgets_SELECT_OPTIONS --${_opt_name}=yes)
  674. else()
  675. list(APPEND wxWidgets_SELECT_OPTIONS --${_opt_name}=no)
  676. endif()
  677. endif()
  678. endforeach()
  679. endmacro()
  680. #-----------------------------------------------------------------
  681. # UNIX: Start actual work.
  682. #-----------------------------------------------------------------
  683. # Support cross-compiling, only search in the target platform.
  684. find_program(wxWidgets_CONFIG_EXECUTABLE
  685. NAMES $ENV{WX_CONFIG} wx-config wx-config-3.1 wx-config-3.0 wx-config-2.9 wx-config-2.8
  686. DOC "Location of wxWidgets library configuration provider binary (wx-config)."
  687. ONLY_CMAKE_FIND_ROOT_PATH
  688. )
  689. if(wxWidgets_CONFIG_EXECUTABLE)
  690. set(wxWidgets_FOUND TRUE)
  691. # get defaults based on "wx-config --selected-config"
  692. WX_CONFIG_SELECT_GET_DEFAULT()
  693. # for each option: if both builds are available, provide option
  694. WX_CONFIG_SELECT_QUERY_BOOL(debug "Use debug build?")
  695. WX_CONFIG_SELECT_QUERY_BOOL(unicode "Use unicode build?")
  696. WX_CONFIG_SELECT_QUERY_BOOL(universal "Use universal build?")
  697. WX_CONFIG_SELECT_QUERY_BOOL(static "Link libraries statically?")
  698. # process selection to set wxWidgets_SELECT_OPTIONS
  699. WX_CONFIG_SELECT_SET_OPTIONS()
  700. DBG_MSG("wxWidgets_SELECT_OPTIONS=${wxWidgets_SELECT_OPTIONS}")
  701. # run the wx-config program to get cxxflags
  702. execute_process(
  703. COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}"
  704. ${wxWidgets_SELECT_OPTIONS} --cxxflags
  705. OUTPUT_VARIABLE wxWidgets_CXX_FLAGS
  706. RESULT_VARIABLE RET
  707. ERROR_QUIET
  708. )
  709. if(RET EQUAL 0)
  710. string(STRIP "${wxWidgets_CXX_FLAGS}" wxWidgets_CXX_FLAGS)
  711. separate_arguments(wxWidgets_CXX_FLAGS_LIST NATIVE_COMMAND "${wxWidgets_CXX_FLAGS}")
  712. DBG_MSG_V("wxWidgets_CXX_FLAGS=${wxWidgets_CXX_FLAGS}")
  713. # parse definitions and include dirs from cxxflags
  714. # drop the -D and -I prefixes
  715. set(wxWidgets_CXX_FLAGS)
  716. foreach(arg IN LISTS wxWidgets_CXX_FLAGS_LIST)
  717. if("${arg}" MATCHES "^-I(.*)$")
  718. # include directory
  719. list(APPEND wxWidgets_INCLUDE_DIRS "${CMAKE_MATCH_1}")
  720. elseif("${arg}" MATCHES "^-D(.*)$")
  721. # compile definition
  722. list(APPEND wxWidgets_DEFINITIONS "${CMAKE_MATCH_1}")
  723. else()
  724. list(APPEND wxWidgets_CXX_FLAGS "${arg}")
  725. endif()
  726. endforeach()
  727. DBG_MSG_V("wxWidgets_DEFINITIONS=${wxWidgets_DEFINITIONS}")
  728. DBG_MSG_V("wxWidgets_INCLUDE_DIRS=${wxWidgets_INCLUDE_DIRS}")
  729. DBG_MSG_V("wxWidgets_CXX_FLAGS=${wxWidgets_CXX_FLAGS}")
  730. else()
  731. set(wxWidgets_FOUND FALSE)
  732. DBG_MSG_V(
  733. "${wxWidgets_CONFIG_EXECUTABLE} --cxxflags FAILED with RET=${RET}")
  734. endif()
  735. # run the wx-config program to get the libs
  736. # - NOTE: wx-config doesn't verify that the libs requested exist
  737. # it just produces the names. Maybe a TRY_COMPILE would
  738. # be useful here...
  739. unset(_cmp_req)
  740. unset(_cmp_opt)
  741. foreach(_cmp IN LISTS wxWidgets_FIND_COMPONENTS)
  742. if(wxWidgets_FIND_REQUIRED_${_cmp})
  743. list(APPEND _cmp_req "${_cmp}")
  744. else()
  745. list(APPEND _cmp_opt "${_cmp}")
  746. endif()
  747. endforeach()
  748. DBG_MSG_V("wxWidgets required components : ${_cmp_req}")
  749. DBG_MSG_V("wxWidgets optional components : ${_cmp_opt}")
  750. if(DEFINED _cmp_opt)
  751. string(REPLACE ";" "," _cmp_opt "--optional-libs ${_cmp_opt}")
  752. endif()
  753. string(REPLACE ";" "," _cmp_req "${_cmp_req}")
  754. execute_process(
  755. COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}"
  756. ${wxWidgets_SELECT_OPTIONS} --libs ${_cmp_req} ${_cmp_opt}
  757. OUTPUT_VARIABLE wxWidgets_LIBRARIES
  758. RESULT_VARIABLE RET
  759. ERROR_QUIET
  760. )
  761. if(RET EQUAL 0)
  762. string(STRIP "${wxWidgets_LIBRARIES}" wxWidgets_LIBRARIES)
  763. separate_arguments(wxWidgets_LIBRARIES)
  764. string(REPLACE "-framework;" "-framework "
  765. wxWidgets_LIBRARIES "${wxWidgets_LIBRARIES}")
  766. string(REPLACE "-weak_framework;" "-weak_framework "
  767. wxWidgets_LIBRARIES "${wxWidgets_LIBRARIES}")
  768. string(REPLACE "-arch;" "-arch "
  769. wxWidgets_LIBRARIES "${wxWidgets_LIBRARIES}")
  770. string(REPLACE "-isysroot;" "-isysroot "
  771. wxWidgets_LIBRARIES "${wxWidgets_LIBRARIES}")
  772. # extract linkdirs (-L) for rpath (i.e., LINK_DIRECTORIES)
  773. string(REGEX MATCHALL "-L[^;]+"
  774. wxWidgets_LIBRARY_DIRS "${wxWidgets_LIBRARIES}")
  775. string(REGEX REPLACE "-L([^;]+)" "\\1"
  776. wxWidgets_LIBRARY_DIRS "${wxWidgets_LIBRARY_DIRS}")
  777. DBG_MSG_V("wxWidgets_LIBRARIES=${wxWidgets_LIBRARIES}")
  778. DBG_MSG_V("wxWidgets_LIBRARY_DIRS=${wxWidgets_LIBRARY_DIRS}")
  779. else()
  780. set(wxWidgets_FOUND FALSE)
  781. DBG_MSG("${wxWidgets_CONFIG_EXECUTABLE} --libs ${_cmp_req} ${_cmp_opt} FAILED with RET=${RET}")
  782. endif()
  783. unset(_cmp_req)
  784. unset(_cmp_opt)
  785. endif()
  786. # When using wx-config in MSYS, the include paths are UNIX style paths which may or may
  787. # not work correctly depending on you MSYS/MinGW configuration. CMake expects native
  788. # paths internally.
  789. if(wxWidgets_FOUND AND MSYS)
  790. find_program(_cygpath_exe cygpath ONLY_CMAKE_FIND_ROOT_PATH)
  791. DBG_MSG_V("_cygpath_exe: ${_cygpath_exe}")
  792. if(_cygpath_exe)
  793. set(_tmp_path "")
  794. foreach(_path ${wxWidgets_INCLUDE_DIRS})
  795. execute_process(
  796. COMMAND cygpath -w ${_path}
  797. OUTPUT_VARIABLE _native_path
  798. RESULT_VARIABLE _retv
  799. OUTPUT_STRIP_TRAILING_WHITESPACE
  800. ERROR_QUIET
  801. )
  802. if(_retv EQUAL 0)
  803. file(TO_CMAKE_PATH ${_native_path} _native_path)
  804. DBG_MSG_V("Path ${_path} converted to ${_native_path}")
  805. string(APPEND _tmp_path " ${_native_path}")
  806. endif()
  807. endforeach()
  808. DBG_MSG("Setting wxWidgets_INCLUDE_DIRS = ${_tmp_path}")
  809. set(wxWidgets_INCLUDE_DIRS ${_tmp_path})
  810. separate_arguments(wxWidgets_INCLUDE_DIRS)
  811. list(REMOVE_ITEM wxWidgets_INCLUDE_DIRS "")
  812. set(_tmp_path "")
  813. foreach(_path ${wxWidgets_LIBRARY_DIRS})
  814. execute_process(
  815. COMMAND cygpath -w ${_path}
  816. OUTPUT_VARIABLE _native_path
  817. RESULT_VARIABLE _retv
  818. OUTPUT_STRIP_TRAILING_WHITESPACE
  819. ERROR_QUIET
  820. )
  821. if(_retv EQUAL 0)
  822. file(TO_CMAKE_PATH ${_native_path} _native_path)
  823. DBG_MSG_V("Path ${_path} converted to ${_native_path}")
  824. string(APPEND _tmp_path " ${_native_path}")
  825. endif()
  826. endforeach()
  827. DBG_MSG("Setting wxWidgets_LIBRARY_DIRS = ${_tmp_path}")
  828. set(wxWidgets_LIBRARY_DIRS ${_tmp_path})
  829. separate_arguments(wxWidgets_LIBRARY_DIRS)
  830. list(REMOVE_ITEM wxWidgets_LIBRARY_DIRS "")
  831. endif()
  832. unset(_cygpath_exe CACHE)
  833. endif()
  834. #=====================================================================
  835. # Neither UNIX_FIND_STYLE, nor WIN32_FIND_STYLE
  836. #=====================================================================
  837. else()
  838. if(NOT wxWidgets_FIND_QUIETLY)
  839. message(STATUS
  840. "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): \n"
  841. " Platform unknown/unsupported. It's neither WIN32 nor UNIX "
  842. "find style."
  843. )
  844. endif()
  845. endif()
  846. endif()
  847. # Check that all libraries are present, as wx-config does not check it
  848. set(_wx_lib_missing "")
  849. foreach(_wx_lib_ ${wxWidgets_LIBRARIES})
  850. if("${_wx_lib_}" MATCHES "^-l(.*)")
  851. set(_wx_lib_name "${CMAKE_MATCH_1}")
  852. unset(_wx_lib_found CACHE)
  853. find_library(_wx_lib_found NAMES ${_wx_lib_name} HINTS ${wxWidgets_LIBRARY_DIRS})
  854. if(_wx_lib_found STREQUAL _wx_lib_found-NOTFOUND)
  855. list(APPEND _wx_lib_missing ${_wx_lib_name})
  856. endif()
  857. unset(_wx_lib_found CACHE)
  858. endif()
  859. endforeach()
  860. if (_wx_lib_missing)
  861. string(REPLACE ";" " " _wx_lib_missing "${_wx_lib_missing}")
  862. DBG_MSG_V("wxWidgets not found due to following missing libraries: ${_wx_lib_missing}")
  863. set(wxWidgets_FOUND FALSE)
  864. unset(wxWidgets_LIBRARIES)
  865. endif()
  866. unset(_wx_lib_missing)
  867. # Check if a specific version was requested by find_package().
  868. if(wxWidgets_FOUND)
  869. unset(_wx_filename)
  870. find_file(_wx_filename wx/version.h PATHS ${wxWidgets_INCLUDE_DIRS} NO_DEFAULT_PATH)
  871. dbg_msg("_wx_filename: ${_wx_filename}")
  872. if(NOT _wx_filename)
  873. message(FATAL_ERROR "wxWidgets wx/version.h file not found in ${wxWidgets_INCLUDE_DIRS}.")
  874. endif()
  875. file(READ "${_wx_filename}" _wx_version_h)
  876. unset(_wx_filename CACHE)
  877. string(REGEX REPLACE "^(.*\n)?#define +wxMAJOR_VERSION +([0-9]+).*"
  878. "\\2" wxWidgets_VERSION_MAJOR "${_wx_version_h}" )
  879. string(REGEX REPLACE "^(.*\n)?#define +wxMINOR_VERSION +([0-9]+).*"
  880. "\\2" wxWidgets_VERSION_MINOR "${_wx_version_h}" )
  881. string(REGEX REPLACE "^(.*\n)?#define +wxRELEASE_NUMBER +([0-9]+).*"
  882. "\\2" wxWidgets_VERSION_PATCH "${_wx_version_h}" )
  883. set(wxWidgets_VERSION_STRING
  884. "${wxWidgets_VERSION_MAJOR}.${wxWidgets_VERSION_MINOR}.${wxWidgets_VERSION_PATCH}" )
  885. dbg_msg("wxWidgets_VERSION_STRING: ${wxWidgets_VERSION_STRING}")
  886. endif()
  887. # Debug output:
  888. DBG_MSG("wxWidgets_FOUND : ${wxWidgets_FOUND}")
  889. DBG_MSG("wxWidgets_INCLUDE_DIRS : ${wxWidgets_INCLUDE_DIRS}")
  890. DBG_MSG("wxWidgets_LIBRARY_DIRS : ${wxWidgets_LIBRARY_DIRS}")
  891. DBG_MSG("wxWidgets_LIBRARIES : ${wxWidgets_LIBRARIES}")
  892. DBG_MSG("wxWidgets_CXX_FLAGS : ${wxWidgets_CXX_FLAGS}")
  893. DBG_MSG("wxWidgets_USE_FILE : ${wxWidgets_USE_FILE}")
  894. #=====================================================================
  895. #=====================================================================
  896. include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
  897. # FIXME: set wxWidgets_<comp>_FOUND for wx-config branch
  898. # and use HANDLE_COMPONENTS on Unix too
  899. if(wxWidgets_FIND_STYLE STREQUAL "win32")
  900. set(wxWidgets_HANDLE_COMPONENTS "HANDLE_COMPONENTS")
  901. endif()
  902. find_package_handle_standard_args(wxWidgets
  903. REQUIRED_VARS wxWidgets_LIBRARIES wxWidgets_INCLUDE_DIRS
  904. VERSION_VAR wxWidgets_VERSION_STRING
  905. ${wxWidgets_HANDLE_COMPONENTS}
  906. )
  907. unset(wxWidgets_HANDLE_COMPONENTS)
  908. #=====================================================================
  909. # Macros for use in wxWidgets apps.
  910. # - This module will not fail to find wxWidgets based on the code
  911. # below. Hence, it's required to check for validity of:
  912. #
  913. # wxWidgets_wxrc_EXECUTABLE
  914. #=====================================================================
  915. # Resource file compiler.
  916. find_program(wxWidgets_wxrc_EXECUTABLE
  917. NAMES $ENV{WXRC_CMD} wxrc
  918. PATHS ${wxWidgets_ROOT_DIR}/utils/wxrc/vc_msw
  919. DOC "Location of wxWidgets resource file compiler binary (wxrc)"
  920. )
  921. #
  922. # WX_SPLIT_ARGUMENTS_ON(<keyword> <left> <right> <arg1> <arg2> ...)
  923. #
  924. # Sets <left> and <right> to contain arguments to the left and right,
  925. # respectively, of <keyword>.
  926. #
  927. # Example usage:
  928. # function(WXWIDGETS_ADD_RESOURCES outfiles)
  929. # WX_SPLIT_ARGUMENTS_ON(OPTIONS wxrc_files wxrc_options ${ARGN})
  930. # ...
  931. # endfunction()
  932. #
  933. # WXWIDGETS_ADD_RESOURCES(sources ${xrc_files} OPTIONS -e -o file.C)
  934. #
  935. # NOTE: This is a generic piece of code that should be renamed to
  936. # SPLIT_ARGUMENTS_ON and put in a file serving the same purpose as
  937. # FindPackageStandardArgs.cmake. At the time of this writing
  938. # FindQt4.cmake has a QT4_EXTRACT_OPTIONS, which I basically copied
  939. # here a bit more generalized. So, there are already two find modules
  940. # using this approach.
  941. #
  942. function(WX_SPLIT_ARGUMENTS_ON _keyword _leftvar _rightvar)
  943. # FIXME: Document that the input variables will be cleared.
  944. #list(APPEND ${_leftvar} "")
  945. #list(APPEND ${_rightvar} "")
  946. set(${_leftvar} "")
  947. set(${_rightvar} "")
  948. set(_doing_right FALSE)
  949. foreach(element ${ARGN})
  950. if("${element}" STREQUAL "${_keyword}")
  951. set(_doing_right TRUE)
  952. else()
  953. if(_doing_right)
  954. list(APPEND ${_rightvar} "${element}")
  955. else()
  956. list(APPEND ${_leftvar} "${element}")
  957. endif()
  958. endif()
  959. endforeach()
  960. set(${_leftvar} ${${_leftvar}} PARENT_SCOPE)
  961. set(${_rightvar} ${${_rightvar}} PARENT_SCOPE)
  962. endfunction()
  963. #
  964. # WX_GET_DEPENDENCIES_FROM_XML(
  965. # <depends>
  966. # <match_pattern>
  967. # <clean_pattern>
  968. # <xml_contents>
  969. # <depends_path>
  970. # )
  971. #
  972. # FIXME: Add documentation here...
  973. #
  974. function(WX_GET_DEPENDENCIES_FROM_XML
  975. _depends
  976. _match_patt
  977. _clean_patt
  978. _xml_contents
  979. _depends_path
  980. )
  981. string(REGEX MATCHALL
  982. ${_match_patt}
  983. dep_file_list
  984. "${${_xml_contents}}"
  985. )
  986. foreach(dep_file ${dep_file_list})
  987. string(REGEX REPLACE ${_clean_patt} "" dep_file "${dep_file}")
  988. # make the file have an absolute path
  989. if(NOT IS_ABSOLUTE "${dep_file}")
  990. set(dep_file "${${_depends_path}}/${dep_file}")
  991. endif()
  992. # append file to dependency list
  993. list(APPEND ${_depends} "${dep_file}")
  994. endforeach()
  995. set(${_depends} ${${_depends}} PARENT_SCOPE)
  996. endfunction()
  997. #
  998. # WXWIDGETS_ADD_RESOURCES(<sources> <xrc_files>
  999. # OPTIONS <options> [NO_CPP_CODE])
  1000. #
  1001. # Adds a custom command for resource file compilation of the
  1002. # <xrc_files> and appends the output files to <sources>.
  1003. #
  1004. # Example usages:
  1005. # WXWIDGETS_ADD_RESOURCES(sources xrc/main_frame.xrc)
  1006. # WXWIDGETS_ADD_RESOURCES(sources ${xrc_files} OPTIONS -e -o altname.cxx)
  1007. #
  1008. function(WXWIDGETS_ADD_RESOURCES _outfiles)
  1009. WX_SPLIT_ARGUMENTS_ON(OPTIONS rc_file_list rc_options ${ARGN})
  1010. # Parse files for dependencies.
  1011. set(rc_file_list_abs "")
  1012. set(rc_depends "")
  1013. foreach(rc_file ${rc_file_list})
  1014. get_filename_component(depends_path ${rc_file} PATH)
  1015. get_filename_component(rc_file_abs ${rc_file} ABSOLUTE)
  1016. list(APPEND rc_file_list_abs "${rc_file_abs}")
  1017. # All files have absolute paths or paths relative to the location
  1018. # of the rc file.
  1019. file(READ "${rc_file_abs}" rc_file_contents)
  1020. # get bitmap/bitmap2 files
  1021. WX_GET_DEPENDENCIES_FROM_XML(
  1022. rc_depends
  1023. "<bitmap[^<]+"
  1024. "^<bitmap[^>]*>"
  1025. rc_file_contents
  1026. depends_path
  1027. )
  1028. # get url files
  1029. WX_GET_DEPENDENCIES_FROM_XML(
  1030. rc_depends
  1031. "<url[^<]+"
  1032. "^<url[^>]*>"
  1033. rc_file_contents
  1034. depends_path
  1035. )
  1036. # get wxIcon files
  1037. WX_GET_DEPENDENCIES_FROM_XML(
  1038. rc_depends
  1039. "<object[^>]*class=\"wxIcon\"[^<]+"
  1040. "^<object[^>]*>"
  1041. rc_file_contents
  1042. depends_path
  1043. )
  1044. endforeach()
  1045. #
  1046. # Parse options.
  1047. #
  1048. # If NO_CPP_CODE option specified, then produce .xrs file rather
  1049. # than a .cpp file (i.e., don't add the default --cpp-code option).
  1050. list(FIND rc_options NO_CPP_CODE index)
  1051. if(index EQUAL -1)
  1052. list(APPEND rc_options --cpp-code)
  1053. # wxrc's default output filename for cpp code.
  1054. set(outfile resource.cpp)
  1055. else()
  1056. list(REMOVE_AT rc_options ${index})
  1057. # wxrc's default output filename for xrs file.
  1058. set(outfile resource.xrs)
  1059. endif()
  1060. # Get output name for use in ADD_CUSTOM_COMMAND.
  1061. # - short option scanning
  1062. list(FIND rc_options -o index)
  1063. if(NOT index EQUAL -1)
  1064. math(EXPR filename_index "${index} + 1")
  1065. list(GET rc_options ${filename_index} outfile)
  1066. #list(REMOVE_AT rc_options ${index} ${filename_index})
  1067. endif()
  1068. # - long option scanning
  1069. string(REGEX MATCH "--output=[^;]*" outfile_opt "${rc_options}")
  1070. if(outfile_opt)
  1071. string(REPLACE "--output=" "" outfile "${outfile_opt}")
  1072. endif()
  1073. #string(REGEX REPLACE "--output=[^;]*;?" "" rc_options "${rc_options}")
  1074. #string(REGEX REPLACE ";$" "" rc_options "${rc_options}")
  1075. if(NOT IS_ABSOLUTE "${outfile}")
  1076. set(outfile "${CMAKE_CURRENT_BINARY_DIR}/${outfile}")
  1077. endif()
  1078. add_custom_command(
  1079. OUTPUT "${outfile}"
  1080. COMMAND ${wxWidgets_wxrc_EXECUTABLE} ${rc_options} ${rc_file_list_abs}
  1081. DEPENDS ${rc_file_list_abs} ${rc_depends}
  1082. )
  1083. # Add generated header to output file list.
  1084. list(FIND rc_options -e short_index)
  1085. list(FIND rc_options --extra-cpp-code long_index)
  1086. if(NOT short_index EQUAL -1 OR NOT long_index EQUAL -1)
  1087. get_filename_component(outfile_ext ${outfile} EXT)
  1088. string(REPLACE "${outfile_ext}" ".h" outfile_header "${outfile}")
  1089. list(APPEND ${_outfiles} "${outfile_header}")
  1090. set_source_files_properties(
  1091. "${outfile_header}" PROPERTIES GENERATED TRUE
  1092. )
  1093. endif()
  1094. # Add generated file to output file list.
  1095. list(APPEND ${_outfiles} "${outfile}")
  1096. set(${_outfiles} ${${_outfiles}} PARENT_SCOPE)
  1097. endfunction()