FindGTK2.cmake 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954
  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. FindGTK2
  5. --------
  6. Find the GTK2 widget libraries and several of its
  7. other optional components like ``gtkmm``, ``glade``, and ``glademm``.
  8. NOTE: If you intend to use version checking, CMake 2.6.2 or later is
  9. ::
  10. required.
  11. Specify one or more of the following components as you call this find
  12. module. See example below.
  13. ::
  14. gtk
  15. gtkmm
  16. glade
  17. glademm
  18. The following variables will be defined for your use
  19. ::
  20. GTK2_FOUND - Were all of your specified components found?
  21. GTK2_INCLUDE_DIRS - All include directories
  22. GTK2_LIBRARIES - All libraries
  23. GTK2_TARGETS - All imported targets
  24. GTK2_DEFINITIONS - Additional compiler flags
  25. ::
  26. GTK2_VERSION - The version of GTK2 found (x.y.z)
  27. GTK2_MAJOR_VERSION - The major version of GTK2
  28. GTK2_MINOR_VERSION - The minor version of GTK2
  29. GTK2_PATCH_VERSION - The patch version of GTK2
  30. Optional variables you can define prior to calling this module:
  31. ::
  32. GTK2_DEBUG - Enables verbose debugging of the module
  33. GTK2_ADDITIONAL_SUFFIXES - Allows defining additional directories to
  34. search for include files
  35. ================= Example Usage:
  36. ::
  37. Call find_package() once, here are some examples to pick from:
  38. ::
  39. Require GTK 2.6 or later
  40. find_package(GTK2 2.6 REQUIRED gtk)
  41. ::
  42. Require GTK 2.10 or later and Glade
  43. find_package(GTK2 2.10 REQUIRED gtk glade)
  44. ::
  45. Search for GTK/GTKMM 2.8 or later
  46. find_package(GTK2 2.8 COMPONENTS gtk gtkmm)
  47. ::
  48. if(GTK2_FOUND)
  49. include_directories(${GTK2_INCLUDE_DIRS})
  50. add_executable(mygui mygui.cc)
  51. target_link_libraries(mygui ${GTK2_LIBRARIES})
  52. endif()
  53. #]=======================================================================]
  54. # Version 1.6 (CMake 3.0)
  55. # * Create targets for each library
  56. # * Do not link libfreetype
  57. # Version 1.5 (CMake 2.8.12)
  58. # * 14236: Detect gthread library
  59. # Detect pangocairo on windows
  60. # Detect pangocairo with gtk module instead of with gtkmm
  61. # * 14259: Use vc100 libraries with VS 11
  62. # * 14260: Export a GTK2_DEFINITIONS variable to set /vd2 when appropriate
  63. # (i.e. MSVC)
  64. # * Use the optimized/debug syntax for _LIBRARY and _LIBRARIES variables when
  65. # appropriate. A new set of _RELEASE variables was also added.
  66. # * Remove GTK2_SKIP_MARK_AS_ADVANCED option, as now the variables are
  67. # marked as advanced by SelectLibraryConfigurations
  68. # * Detect gmodule, pangoft2 and pangoxft libraries
  69. # Version 1.4 (10/4/2012) (CMake 2.8.10)
  70. # * 12596: Missing paths for FindGTK2 on NetBSD
  71. # * 12049: Fixed detection of GTK include files in the lib folder on
  72. # multiarch systems.
  73. # Version 1.3 (11/9/2010) (CMake 2.8.4)
  74. # * 11429: Add support for detecting GTK2 built with Visual Studio 10.
  75. # Thanks to Vincent Levesque for the patch.
  76. # Version 1.2 (8/30/2010) (CMake 2.8.3)
  77. # * Merge patch for detecting gdk-pixbuf library (split off
  78. # from core GTK in 2.21). Thanks to Vincent Untz for the patch
  79. # and Ricardo Cruz for the heads up.
  80. # Version 1.1 (8/19/2010) (CMake 2.8.3)
  81. # * Add support for detecting GTK2 under macports (thanks to Gary Kramlich)
  82. # Version 1.0 (8/12/2010) (CMake 2.8.3)
  83. # * Add support for detecting new pangommconfig.h header file
  84. # (Thanks to Sune Vuorela & the Debian Project for the patch)
  85. # * Add support for detecting fontconfig.h header
  86. # * Call find_package(Freetype) since it's required
  87. # * Add support for allowing users to add additional library directories
  88. # via the GTK2_ADDITIONAL_SUFFIXES variable (kind of a future-kludge in
  89. # case the GTK developers change versions on any of the directories in the
  90. # future).
  91. # Version 0.8 (1/4/2010)
  92. # * Get module working under MacOSX fink by adding /sw/include, /sw/lib
  93. # to PATHS and the gobject library
  94. # Version 0.7 (3/22/09)
  95. # * Checked into CMake CVS
  96. # * Added versioning support
  97. # * Module now defaults to searching for GTK if COMPONENTS not specified.
  98. # * Added HKCU prior to HKLM registry key and GTKMM specific environment
  99. # variable as per mailing list discussion.
  100. # * Added lib64 to include search path and a few other search paths where GTK
  101. # may be installed on Unix systems.
  102. # * Switched to lowercase CMake commands
  103. # * Prefaced internal variables with _GTK2 to prevent collision
  104. # * Changed internal macros to functions
  105. # * Enhanced documentation
  106. # Version 0.6 (1/8/08)
  107. # Added GTK2_SKIP_MARK_AS_ADVANCED option
  108. # Version 0.5 (12/19/08)
  109. # Second release to cmake mailing list
  110. #=============================================================
  111. # _GTK2_GET_VERSION
  112. # Internal function to parse the version number in gtkversion.h
  113. # _OUT_major = Major version number
  114. # _OUT_minor = Minor version number
  115. # _OUT_micro = Micro version number
  116. # _gtkversion_hdr = Header file to parse
  117. #=============================================================
  118. include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
  119. function(_GTK2_GET_VERSION _OUT_major _OUT_minor _OUT_micro _gtkversion_hdr)
  120. file(STRINGS ${_gtkversion_hdr} _contents REGEX "#define GTK_M[A-Z]+_VERSION[ \t]+")
  121. if(_contents)
  122. string(REGEX REPLACE ".*#define GTK_MAJOR_VERSION[ \t]+\\(([0-9]+)\\).*" "\\1" ${_OUT_major} "${_contents}")
  123. string(REGEX REPLACE ".*#define GTK_MINOR_VERSION[ \t]+\\(([0-9]+)\\).*" "\\1" ${_OUT_minor} "${_contents}")
  124. string(REGEX REPLACE ".*#define GTK_MICRO_VERSION[ \t]+\\(([0-9]+)\\).*" "\\1" ${_OUT_micro} "${_contents}")
  125. if(NOT ${_OUT_major} MATCHES "[0-9]+")
  126. message(FATAL_ERROR "Version parsing failed for GTK2_MAJOR_VERSION!")
  127. endif()
  128. if(NOT ${_OUT_minor} MATCHES "[0-9]+")
  129. message(FATAL_ERROR "Version parsing failed for GTK2_MINOR_VERSION!")
  130. endif()
  131. if(NOT ${_OUT_micro} MATCHES "[0-9]+")
  132. message(FATAL_ERROR "Version parsing failed for GTK2_MICRO_VERSION!")
  133. endif()
  134. set(${_OUT_major} ${${_OUT_major}} PARENT_SCOPE)
  135. set(${_OUT_minor} ${${_OUT_minor}} PARENT_SCOPE)
  136. set(${_OUT_micro} ${${_OUT_micro}} PARENT_SCOPE)
  137. else()
  138. message(FATAL_ERROR "Include file ${_gtkversion_hdr} does not exist")
  139. endif()
  140. endfunction()
  141. #=============================================================
  142. # _GTK2_SIGCXX_GET_VERSION
  143. # Internal function to parse the version number in
  144. # sigc++config.h
  145. # _OUT_major = Major version number
  146. # _OUT_minor = Minor version number
  147. # _OUT_micro = Micro version number
  148. # _sigcxxversion_hdr = Header file to parse
  149. #=============================================================
  150. function(_GTK2_SIGCXX_GET_VERSION _OUT_major _OUT_minor _OUT_micro _sigcxxversion_hdr)
  151. file(STRINGS ${_sigcxxversion_hdr} _contents REGEX "#define SIGCXX_M[A-Z]+_VERSION[ \t]+")
  152. if(_contents)
  153. string(REGEX REPLACE ".*#define SIGCXX_MAJOR_VERSION[ \t]+([0-9]+).*" "\\1" ${_OUT_major} "${_contents}")
  154. string(REGEX REPLACE ".*#define SIGCXX_MINOR_VERSION[ \t]+([0-9]+).*" "\\1" ${_OUT_minor} "${_contents}")
  155. string(REGEX REPLACE ".*#define SIGCXX_MICRO_VERSION[ \t]+([0-9]+).*" "\\1" ${_OUT_micro} "${_contents}")
  156. if(NOT ${_OUT_major} MATCHES "[0-9]+")
  157. message(FATAL_ERROR "Version parsing failed for SIGCXX_MAJOR_VERSION!")
  158. endif()
  159. if(NOT ${_OUT_minor} MATCHES "[0-9]+")
  160. message(FATAL_ERROR "Version parsing failed for SIGCXX_MINOR_VERSION!")
  161. endif()
  162. if(NOT ${_OUT_micro} MATCHES "[0-9]+")
  163. message(FATAL_ERROR "Version parsing failed for SIGCXX_MICRO_VERSION!")
  164. endif()
  165. set(${_OUT_major} ${${_OUT_major}} PARENT_SCOPE)
  166. set(${_OUT_minor} ${${_OUT_minor}} PARENT_SCOPE)
  167. set(${_OUT_micro} ${${_OUT_micro}} PARENT_SCOPE)
  168. else()
  169. # The header does not have the version macros; assume it is ``0.0.0``.
  170. set(${_OUT_major} 0)
  171. set(${_OUT_minor} 0)
  172. set(${_OUT_micro} 0)
  173. endif()
  174. endfunction()
  175. #=============================================================
  176. # _GTK2_FIND_INCLUDE_DIR
  177. # Internal function to find the GTK include directories
  178. # _var = variable to set (_INCLUDE_DIR is appended)
  179. # _hdr = header file to look for
  180. #=============================================================
  181. function(_GTK2_FIND_INCLUDE_DIR _var _hdr)
  182. if(GTK2_DEBUG)
  183. message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
  184. "_GTK2_FIND_INCLUDE_DIR( ${_var} ${_hdr} )")
  185. endif()
  186. set(_gtk_packages
  187. # If these ever change, things will break.
  188. ${GTK2_ADDITIONAL_SUFFIXES}
  189. glibmm-2.4
  190. glib-2.0
  191. atk-1.0
  192. atkmm-1.6
  193. cairo
  194. cairomm-1.0
  195. gdk-pixbuf-2.0
  196. gdkmm-2.4
  197. giomm-2.4
  198. gtk-2.0
  199. gtkmm-2.4
  200. libglade-2.0
  201. libglademm-2.4
  202. harfbuzz
  203. pango-1.0
  204. pangomm-1.4
  205. sigc++-2.0
  206. )
  207. #
  208. # NOTE: The following suffixes cause searching for header files in both of
  209. # these directories:
  210. # /usr/include/<pkg>
  211. # /usr/lib/<pkg>/include
  212. #
  213. set(_suffixes)
  214. foreach(_d ${_gtk_packages})
  215. list(APPEND _suffixes ${_d})
  216. list(APPEND _suffixes ${_d}/include) # for /usr/lib/gtk-2.0/include
  217. endforeach()
  218. if(GTK2_DEBUG)
  219. message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
  220. "include suffixes = ${_suffixes}")
  221. endif()
  222. if(CMAKE_LIBRARY_ARCHITECTURE)
  223. set(_gtk2_arch_dir /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE})
  224. if(GTK2_DEBUG)
  225. message(STATUS "Adding ${_gtk2_arch_dir} to search path for multiarch support")
  226. endif()
  227. endif()
  228. find_path(GTK2_${_var}_INCLUDE_DIR ${_hdr}
  229. PATHS
  230. ${_gtk2_arch_dir}
  231. /usr/local/libx32
  232. /usr/local/lib64
  233. /usr/local/lib
  234. /usr/libx32
  235. /usr/lib64
  236. /usr/lib
  237. /opt/gnome/include
  238. /opt/gnome/lib
  239. /opt/openwin/include
  240. /usr/openwin/lib
  241. /sw/lib
  242. /opt/local/lib
  243. /usr/pkg/lib
  244. /usr/pkg/include/glib
  245. $ENV{GTKMM_BASEPATH}/include
  246. $ENV{GTKMM_BASEPATH}/lib
  247. [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]/include
  248. [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]/lib
  249. [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]/include
  250. [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]/lib
  251. PATH_SUFFIXES
  252. ${_suffixes}
  253. )
  254. mark_as_advanced(GTK2_${_var}_INCLUDE_DIR)
  255. if(GTK2_${_var}_INCLUDE_DIR)
  256. set(GTK2_INCLUDE_DIRS ${GTK2_INCLUDE_DIRS} ${GTK2_${_var}_INCLUDE_DIR} PARENT_SCOPE)
  257. endif()
  258. endfunction()
  259. #=============================================================
  260. # _GTK2_FIND_LIBRARY
  261. # Internal function to find libraries packaged with GTK2
  262. # _var = library variable to create (_LIBRARY is appended)
  263. #=============================================================
  264. function(_GTK2_FIND_LIBRARY _var _lib _expand_vc _append_version)
  265. if(GTK2_DEBUG)
  266. message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
  267. "_GTK2_FIND_LIBRARY( ${_var} ${_lib} ${_expand_vc} ${_append_version} )")
  268. endif()
  269. # Not GTK versions per se but the versions encoded into Windows
  270. # import libraries (GtkMM 2.14.1 has a gtkmm-vc80-2_4.lib for example)
  271. # Also the MSVC libraries use _ for . (this is handled below)
  272. set(_versions 2.20 2.18 2.16 2.14 2.12
  273. 2.10 2.8 2.6 2.4 2.2 2.0
  274. 1.20 1.18 1.16 1.14 1.12
  275. 1.10 1.8 1.6 1.4 1.2 1.0)
  276. set(_library)
  277. set(_library_d)
  278. set(_library ${_lib})
  279. if(_expand_vc AND MSVC)
  280. # Add vc80/vc90/vc100 midfixes
  281. if(MSVC_TOOLSET_VERSION LESS 110)
  282. set(_library ${_library}-vc${MSVC_TOOLSET_VERSION})
  283. else()
  284. # Up to gtkmm-win 2.22.0-2 there are no vc110 libraries but vc100 can be used
  285. set(_library ${_library}-vc100)
  286. endif()
  287. set(_library_d ${_library}-d)
  288. endif()
  289. if(GTK2_DEBUG)
  290. message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
  291. "After midfix addition = ${_library} and ${_library_d}")
  292. endif()
  293. set(_lib_list)
  294. set(_libd_list)
  295. if(_append_version)
  296. foreach(_ver ${_versions})
  297. list(APPEND _lib_list "${_library}-${_ver}")
  298. list(APPEND _libd_list "${_library_d}-${_ver}")
  299. endforeach()
  300. else()
  301. set(_lib_list ${_library})
  302. set(_libd_list ${_library_d})
  303. endif()
  304. if(GTK2_DEBUG)
  305. message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
  306. "library list = ${_lib_list} and library debug list = ${_libd_list}")
  307. endif()
  308. # For some silly reason the MSVC libraries use _ instead of .
  309. # in the version fields
  310. if(_expand_vc AND MSVC)
  311. set(_no_dots_lib_list)
  312. set(_no_dots_libd_list)
  313. foreach(_l ${_lib_list})
  314. string(REPLACE "." "_" _no_dots_library ${_l})
  315. list(APPEND _no_dots_lib_list ${_no_dots_library})
  316. endforeach()
  317. # And for debug
  318. set(_no_dots_libsd_list)
  319. foreach(_l ${_libd_list})
  320. string(REPLACE "." "_" _no_dots_libraryd ${_l})
  321. list(APPEND _no_dots_libd_list ${_no_dots_libraryd})
  322. endforeach()
  323. # Copy list back to original names
  324. set(_lib_list ${_no_dots_lib_list})
  325. set(_libd_list ${_no_dots_libd_list})
  326. endif()
  327. if(GTK2_DEBUG)
  328. message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
  329. "While searching for GTK2_${_var}_LIBRARY, our proposed library list is ${_lib_list}")
  330. endif()
  331. find_library(GTK2_${_var}_LIBRARY_RELEASE
  332. NAMES ${_lib_list}
  333. PATHS
  334. /opt/gnome/lib
  335. /usr/openwin/lib
  336. $ENV{GTKMM_BASEPATH}/lib
  337. [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]/lib
  338. [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]/lib
  339. )
  340. if(_expand_vc AND MSVC)
  341. if(GTK2_DEBUG)
  342. message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
  343. "While searching for GTK2_${_var}_LIBRARY_DEBUG our proposed library list is ${_libd_list}")
  344. endif()
  345. find_library(GTK2_${_var}_LIBRARY_DEBUG
  346. NAMES ${_libd_list}
  347. PATHS
  348. $ENV{GTKMM_BASEPATH}/lib
  349. [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]/lib
  350. [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]/lib
  351. )
  352. endif()
  353. select_library_configurations(GTK2_${_var})
  354. set(GTK2_${_var}_LIBRARY ${GTK2_${_var}_LIBRARY} PARENT_SCOPE)
  355. set(GTK2_${_var}_FOUND ${GTK2_${_var}_FOUND} PARENT_SCOPE)
  356. if(GTK2_${_var}_FOUND)
  357. set(GTK2_LIBRARIES ${GTK2_LIBRARIES} ${GTK2_${_var}_LIBRARY})
  358. set(GTK2_LIBRARIES ${GTK2_LIBRARIES} PARENT_SCOPE)
  359. endif()
  360. if(GTK2_DEBUG)
  361. message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
  362. "GTK2_${_var}_LIBRARY_RELEASE = \"${GTK2_${_var}_LIBRARY_RELEASE}\"")
  363. message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
  364. "GTK2_${_var}_LIBRARY_DEBUG = \"${GTK2_${_var}_LIBRARY_DEBUG}\"")
  365. message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
  366. "GTK2_${_var}_LIBRARY = \"${GTK2_${_var}_LIBRARY}\"")
  367. message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
  368. "GTK2_${_var}_FOUND = \"${GTK2_${_var}_FOUND}\"")
  369. endif()
  370. endfunction()
  371. function(_GTK2_ADD_TARGET_DEPENDS_INTERNAL _var _property)
  372. if(GTK2_DEBUG)
  373. message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
  374. "_GTK2_ADD_TARGET_DEPENDS_INTERNAL( ${_var} ${_property} )")
  375. endif()
  376. string(TOLOWER "${_var}" _basename)
  377. if (TARGET GTK2::${_basename})
  378. foreach(_depend ${ARGN})
  379. set(_valid_depends)
  380. if (TARGET GTK2::${_depend})
  381. list(APPEND _valid_depends GTK2::${_depend})
  382. endif()
  383. if (_valid_depends)
  384. set_property(TARGET GTK2::${_basename} APPEND PROPERTY ${_property} "${_valid_depends}")
  385. endif()
  386. set(_valid_depends)
  387. endforeach()
  388. endif()
  389. endfunction()
  390. function(_GTK2_ADD_TARGET_DEPENDS _var)
  391. if(GTK2_DEBUG)
  392. message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
  393. "_GTK2_ADD_TARGET_DEPENDS( ${_var} )")
  394. endif()
  395. string(TOLOWER "${_var}" _basename)
  396. if(TARGET GTK2::${_basename})
  397. get_target_property(_configs GTK2::${_basename} IMPORTED_CONFIGURATIONS)
  398. _GTK2_ADD_TARGET_DEPENDS_INTERNAL(${_var} INTERFACE_LINK_LIBRARIES ${ARGN})
  399. foreach(_config ${_configs})
  400. _GTK2_ADD_TARGET_DEPENDS_INTERNAL(${_var} IMPORTED_LINK_INTERFACE_LIBRARIES_${_config} ${ARGN})
  401. endforeach()
  402. endif()
  403. endfunction()
  404. function(_GTK2_ADD_TARGET_INCLUDE_DIRS _var)
  405. if(GTK2_DEBUG)
  406. message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
  407. "_GTK2_ADD_TARGET_INCLUDE_DIRS( ${_var} )")
  408. endif()
  409. string(TOLOWER "${_var}" _basename)
  410. if(TARGET GTK2::${_basename})
  411. foreach(_include ${ARGN})
  412. set_property(TARGET GTK2::${_basename} APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${_include}")
  413. endforeach()
  414. endif()
  415. endfunction()
  416. #=============================================================
  417. # _GTK2_ADD_TARGET
  418. # Internal function to create targets for GTK2
  419. # _var = target to create
  420. #=============================================================
  421. function(_GTK2_ADD_TARGET _var)
  422. if(GTK2_DEBUG)
  423. message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
  424. "_GTK2_ADD_TARGET( ${_var} )")
  425. endif()
  426. string(TOLOWER "${_var}" _basename)
  427. cmake_parse_arguments(_${_var} "" "" "GTK2_DEPENDS;GTK2_OPTIONAL_DEPENDS;OPTIONAL_INCLUDES" ${ARGN})
  428. if(GTK2_${_var}_FOUND)
  429. if(NOT TARGET GTK2::${_basename})
  430. # Do not create the target if dependencies are missing
  431. foreach(_dep ${_${_var}_GTK2_DEPENDS})
  432. if(NOT TARGET GTK2::${_dep})
  433. return()
  434. endif()
  435. endforeach()
  436. add_library(GTK2::${_basename} UNKNOWN IMPORTED)
  437. if(GTK2_${_var}_LIBRARY_RELEASE)
  438. set_property(TARGET GTK2::${_basename} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
  439. set_property(TARGET GTK2::${_basename} PROPERTY IMPORTED_LOCATION_RELEASE "${GTK2_${_var}_LIBRARY_RELEASE}" )
  440. endif()
  441. if(GTK2_${_var}_LIBRARY_DEBUG)
  442. set_property(TARGET GTK2::${_basename} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
  443. set_property(TARGET GTK2::${_basename} PROPERTY IMPORTED_LOCATION_DEBUG "${GTK2_${_var}_LIBRARY_DEBUG}" )
  444. endif()
  445. if(GTK2_${_var}_INCLUDE_DIR)
  446. set_property(TARGET GTK2::${_basename} APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${GTK2_${_var}_INCLUDE_DIR}")
  447. endif()
  448. if(GTK2_${_var}CONFIG_INCLUDE_DIR AND NOT "x${GTK2_${_var}CONFIG_INCLUDE_DIR}" STREQUAL "x${GTK2_${_var}_INCLUDE_DIR}")
  449. set_property(TARGET GTK2::${_basename} APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${GTK2_${_var}CONFIG_INCLUDE_DIR}")
  450. endif()
  451. if(GTK2_DEFINITIONS)
  452. set_property(TARGET GTK2::${_basename} PROPERTY INTERFACE_COMPILE_DEFINITIONS "${GTK2_DEFINITIONS}")
  453. endif()
  454. if(_${_var}_GTK2_DEPENDS)
  455. _GTK2_ADD_TARGET_DEPENDS(${_var} ${_${_var}_GTK2_DEPENDS} ${_${_var}_GTK2_OPTIONAL_DEPENDS})
  456. endif()
  457. if(_${_var}_OPTIONAL_INCLUDES)
  458. foreach(_D ${_${_var}_OPTIONAL_INCLUDES})
  459. if(_D)
  460. _GTK2_ADD_TARGET_INCLUDE_DIRS(${_var} ${_D})
  461. endif()
  462. endforeach()
  463. endif()
  464. endif()
  465. set(GTK2_TARGETS ${GTK2_TARGETS} GTK2::${_basename})
  466. set(GTK2_TARGETS ${GTK2_TARGETS} PARENT_SCOPE)
  467. if(GTK2_USE_IMPORTED_TARGETS)
  468. set(GTK2_${_var}_LIBRARY GTK2::${_basename} PARENT_SCOPE)
  469. endif()
  470. endif()
  471. endfunction()
  472. #=============================================================
  473. #
  474. # main()
  475. #
  476. set(GTK2_FOUND)
  477. set(GTK2_INCLUDE_DIRS)
  478. set(GTK2_LIBRARIES)
  479. set(GTK2_TARGETS)
  480. set(GTK2_DEFINITIONS)
  481. if(NOT GTK2_FIND_COMPONENTS)
  482. # Assume they only want GTK
  483. set(GTK2_FIND_COMPONENTS gtk)
  484. endif()
  485. #
  486. # If specified, enforce version number
  487. #
  488. if(GTK2_FIND_VERSION)
  489. set(GTK2_FAILED_VERSION_CHECK true)
  490. if(GTK2_DEBUG)
  491. message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
  492. "Searching for version ${GTK2_FIND_VERSION}")
  493. endif()
  494. _GTK2_FIND_INCLUDE_DIR(GTK gtk/gtk.h)
  495. if(GTK2_GTK_INCLUDE_DIR)
  496. _GTK2_GET_VERSION(GTK2_MAJOR_VERSION
  497. GTK2_MINOR_VERSION
  498. GTK2_PATCH_VERSION
  499. ${GTK2_GTK_INCLUDE_DIR}/gtk/gtkversion.h)
  500. set(GTK2_VERSION
  501. ${GTK2_MAJOR_VERSION}.${GTK2_MINOR_VERSION}.${GTK2_PATCH_VERSION})
  502. if(GTK2_FIND_VERSION_EXACT)
  503. if(GTK2_VERSION VERSION_EQUAL GTK2_FIND_VERSION)
  504. set(GTK2_FAILED_VERSION_CHECK false)
  505. endif()
  506. else()
  507. if(GTK2_VERSION VERSION_EQUAL GTK2_FIND_VERSION OR
  508. GTK2_VERSION VERSION_GREATER GTK2_FIND_VERSION)
  509. set(GTK2_FAILED_VERSION_CHECK false)
  510. endif()
  511. endif()
  512. else()
  513. # If we can't find the GTK include dir, we can't do version checking
  514. if(GTK2_FIND_REQUIRED AND NOT GTK2_FIND_QUIETLY)
  515. message(FATAL_ERROR "Could not find GTK2 include directory")
  516. endif()
  517. return()
  518. endif()
  519. if(GTK2_FAILED_VERSION_CHECK)
  520. if(GTK2_FIND_REQUIRED AND NOT GTK2_FIND_QUIETLY)
  521. if(GTK2_FIND_VERSION_EXACT)
  522. message(FATAL_ERROR "GTK2 version check failed. Version ${GTK2_VERSION} was found, version ${GTK2_FIND_VERSION} is needed exactly.")
  523. else()
  524. message(FATAL_ERROR "GTK2 version check failed. Version ${GTK2_VERSION} was found, at least version ${GTK2_FIND_VERSION} is required")
  525. endif()
  526. endif()
  527. # If the version check fails, exit out of the module here
  528. return()
  529. endif()
  530. endif()
  531. #
  532. # On MSVC, according to https://wiki.gnome.org/gtkmm/MSWindows, the /vd2 flag needs to be
  533. # passed to the compiler in order to use gtkmm
  534. #
  535. if(MSVC)
  536. foreach(_GTK2_component ${GTK2_FIND_COMPONENTS})
  537. if(_GTK2_component STREQUAL "gtkmm")
  538. set(GTK2_DEFINITIONS "/vd2")
  539. elseif(_GTK2_component STREQUAL "glademm")
  540. set(GTK2_DEFINITIONS "/vd2")
  541. endif()
  542. endforeach()
  543. endif()
  544. #
  545. # Find all components
  546. #
  547. find_package(Freetype QUIET)
  548. if(FREETYPE_INCLUDE_DIR_ft2build AND FREETYPE_INCLUDE_DIR_freetype2)
  549. list(APPEND GTK2_INCLUDE_DIRS ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2})
  550. endif()
  551. foreach(_GTK2_component ${GTK2_FIND_COMPONENTS})
  552. if(_GTK2_component STREQUAL "gtk")
  553. # Left for compatibility with previous versions.
  554. _GTK2_FIND_INCLUDE_DIR(FONTCONFIG fontconfig/fontconfig.h)
  555. _GTK2_FIND_INCLUDE_DIR(X11 X11/Xlib.h)
  556. _GTK2_FIND_INCLUDE_DIR(GLIB glib.h)
  557. _GTK2_FIND_INCLUDE_DIR(GLIBCONFIG glibconfig.h)
  558. _GTK2_FIND_LIBRARY (GLIB glib false true)
  559. _GTK2_ADD_TARGET (GLIB)
  560. _GTK2_FIND_INCLUDE_DIR(GOBJECT glib-object.h)
  561. _GTK2_FIND_LIBRARY (GOBJECT gobject false true)
  562. _GTK2_ADD_TARGET (GOBJECT GTK2_DEPENDS glib)
  563. _GTK2_FIND_INCLUDE_DIR(ATK atk/atk.h)
  564. _GTK2_FIND_LIBRARY (ATK atk false true)
  565. _GTK2_ADD_TARGET (ATK GTK2_DEPENDS gobject glib)
  566. _GTK2_FIND_LIBRARY (GIO gio false true)
  567. _GTK2_ADD_TARGET (GIO GTK2_DEPENDS gobject glib)
  568. _GTK2_FIND_LIBRARY (GTHREAD gthread false true)
  569. _GTK2_ADD_TARGET (GTHREAD GTK2_DEPENDS glib)
  570. _GTK2_FIND_LIBRARY (GMODULE gmodule false true)
  571. _GTK2_ADD_TARGET (GMODULE GTK2_DEPENDS glib)
  572. _GTK2_FIND_INCLUDE_DIR(GDK_PIXBUF gdk-pixbuf/gdk-pixbuf.h)
  573. _GTK2_FIND_LIBRARY (GDK_PIXBUF gdk_pixbuf false true)
  574. _GTK2_ADD_TARGET (GDK_PIXBUF GTK2_DEPENDS gobject glib)
  575. _GTK2_FIND_INCLUDE_DIR(CAIRO cairo.h)
  576. _GTK2_FIND_LIBRARY (CAIRO cairo false false)
  577. _GTK2_ADD_TARGET (CAIRO)
  578. _GTK2_FIND_INCLUDE_DIR(PANGO pango/pango.h)
  579. _GTK2_FIND_LIBRARY (PANGO pango false true)
  580. _GTK2_ADD_TARGET (PANGO GTK2_DEPENDS gobject glib)
  581. _GTK2_FIND_INCLUDE_DIR(HARFBUZZ hb.h)
  582. _GTK2_FIND_LIBRARY (PANGOCAIRO pangocairo false true)
  583. _GTK2_ADD_TARGET (PANGOCAIRO GTK2_DEPENDS pango cairo gobject glib)
  584. _GTK2_FIND_LIBRARY (PANGOFT2 pangoft2 false true)
  585. _GTK2_ADD_TARGET (PANGOFT2 GTK2_DEPENDS pango gobject glib
  586. OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}
  587. ${GTK2_FONTCONFIG_INCLUDE_DIR}
  588. ${GTK2_X11_INCLUDE_DIR})
  589. _GTK2_FIND_LIBRARY (PANGOXFT pangoxft false true)
  590. _GTK2_ADD_TARGET (PANGOXFT GTK2_DEPENDS pangoft2 pango gobject glib
  591. OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}
  592. ${GTK2_FONTCONFIG_INCLUDE_DIR}
  593. ${GTK2_X11_INCLUDE_DIR})
  594. _GTK2_FIND_INCLUDE_DIR(GDK gdk/gdk.h)
  595. _GTK2_FIND_INCLUDE_DIR(GDKCONFIG gdkconfig.h)
  596. if(UNIX)
  597. if(APPLE)
  598. _GTK2_FIND_LIBRARY (GDK gdk-quartz false true)
  599. endif()
  600. _GTK2_FIND_LIBRARY (GDK gdk-x11 false true)
  601. else()
  602. _GTK2_FIND_LIBRARY (GDK gdk-win32 false true)
  603. endif()
  604. _GTK2_ADD_TARGET (GDK GTK2_DEPENDS pango gdk_pixbuf gobject glib
  605. GTK2_OPTIONAL_DEPENDS pangocairo cairo)
  606. _GTK2_FIND_INCLUDE_DIR(GTK gtk/gtk.h)
  607. if(UNIX)
  608. if(APPLE)
  609. _GTK2_FIND_LIBRARY (GTK gtk-quartz false true)
  610. endif()
  611. _GTK2_FIND_LIBRARY (GTK gtk-x11 false true)
  612. else()
  613. _GTK2_FIND_LIBRARY (GTK gtk-win32 false true)
  614. endif()
  615. _GTK2_ADD_TARGET (GTK GTK2_DEPENDS gdk atk pangoft2 pango gdk_pixbuf gthread gobject glib
  616. GTK2_OPTIONAL_DEPENDS gio pangocairo cairo)
  617. elseif(_GTK2_component STREQUAL "gtkmm")
  618. _GTK2_FIND_INCLUDE_DIR(SIGC++ sigc++/sigc++.h)
  619. _GTK2_FIND_INCLUDE_DIR(SIGC++CONFIG sigc++config.h)
  620. _GTK2_FIND_LIBRARY (SIGC++ sigc true true)
  621. _GTK2_ADD_TARGET (SIGC++)
  622. # Since sigc++ 2.5.1 c++11 support is required
  623. if(GTK2_SIGC++CONFIG_INCLUDE_DIR)
  624. _GTK2_SIGCXX_GET_VERSION(GTK2_SIGC++_VERSION_MAJOR
  625. GTK2_SIGC++_VERSION_MINOR
  626. GTK2_SIGC++_VERSION_MICRO
  627. ${GTK2_SIGC++CONFIG_INCLUDE_DIR}/sigc++config.h)
  628. if(NOT ${GTK2_SIGC++_VERSION_MAJOR}.${GTK2_SIGC++_VERSION_MINOR}.${GTK2_SIGC++_VERSION_MICRO} VERSION_LESS 2.5.1)
  629. # These are the features needed by clients in order to include the
  630. # project headers:
  631. set_property(TARGET GTK2::sigc++
  632. PROPERTY INTERFACE_COMPILE_FEATURES cxx_alias_templates
  633. cxx_auto_type
  634. cxx_decltype
  635. cxx_deleted_functions
  636. cxx_noexcept
  637. cxx_nullptr
  638. cxx_right_angle_brackets
  639. cxx_rvalue_references
  640. cxx_variadic_templates)
  641. endif()
  642. endif()
  643. _GTK2_FIND_INCLUDE_DIR(GLIBMM glibmm.h)
  644. _GTK2_FIND_INCLUDE_DIR(GLIBMMCONFIG glibmmconfig.h)
  645. _GTK2_FIND_LIBRARY (GLIBMM glibmm true true)
  646. _GTK2_ADD_TARGET (GLIBMM GTK2_DEPENDS gobject sigc++ glib)
  647. _GTK2_FIND_INCLUDE_DIR(GIOMM giomm.h)
  648. _GTK2_FIND_INCLUDE_DIR(GIOMMCONFIG giommconfig.h)
  649. _GTK2_FIND_LIBRARY (GIOMM giomm true true)
  650. _GTK2_ADD_TARGET (GIOMM GTK2_DEPENDS gio glibmm gobject sigc++ glib)
  651. _GTK2_FIND_INCLUDE_DIR(ATKMM atkmm.h)
  652. _GTK2_FIND_LIBRARY (ATKMM atkmm true true)
  653. _GTK2_ADD_TARGET (ATKMM GTK2_DEPENDS atk glibmm gobject sigc++ glib)
  654. _GTK2_FIND_INCLUDE_DIR(CAIROMM cairomm/cairomm.h)
  655. _GTK2_FIND_INCLUDE_DIR(CAIROMMCONFIG cairommconfig.h)
  656. _GTK2_FIND_LIBRARY (CAIROMM cairomm true true)
  657. _GTK2_ADD_TARGET (CAIROMM GTK2_DEPENDS cairo sigc++
  658. OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}
  659. ${GTK2_FONTCONFIG_INCLUDE_DIR}
  660. ${GTK2_X11_INCLUDE_DIR})
  661. _GTK2_FIND_INCLUDE_DIR(PANGOMM pangomm.h)
  662. _GTK2_FIND_INCLUDE_DIR(PANGOMMCONFIG pangommconfig.h)
  663. _GTK2_FIND_LIBRARY (PANGOMM pangomm true true)
  664. _GTK2_ADD_TARGET (PANGOMM GTK2_DEPENDS glibmm sigc++ pango gobject glib
  665. GTK2_OPTIONAL_DEPENDS cairomm pangocairo cairo
  666. OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}
  667. ${GTK2_FONTCONFIG_INCLUDE_DIR}
  668. ${GTK2_X11_INCLUDE_DIR})
  669. _GTK2_FIND_INCLUDE_DIR(GDKMM gdkmm.h)
  670. _GTK2_FIND_INCLUDE_DIR(GDKMMCONFIG gdkmmconfig.h)
  671. _GTK2_FIND_LIBRARY (GDKMM gdkmm true true)
  672. _GTK2_ADD_TARGET (GDKMM GTK2_DEPENDS pangomm gtk glibmm sigc++ gdk atk pangoft2 gdk_pixbuf pango gobject glib
  673. GTK2_OPTIONAL_DEPENDS giomm cairomm gio pangocairo cairo
  674. OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}
  675. ${GTK2_FONTCONFIG_INCLUDE_DIR}
  676. ${GTK2_X11_INCLUDE_DIR})
  677. _GTK2_FIND_INCLUDE_DIR(GTKMM gtkmm.h)
  678. _GTK2_FIND_INCLUDE_DIR(GTKMMCONFIG gtkmmconfig.h)
  679. _GTK2_FIND_LIBRARY (GTKMM gtkmm true true)
  680. _GTK2_ADD_TARGET (GTKMM GTK2_DEPENDS atkmm gdkmm pangomm gtk glibmm sigc++ gdk atk pangoft2 gdk_pixbuf pango gthread gobject glib
  681. GTK2_OPTIONAL_DEPENDS giomm cairomm gio pangocairo cairo
  682. OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}
  683. ${GTK2_FONTCONFIG_INCLUDE_DIR}
  684. ${GTK2_X11_INCLUDE_DIR})
  685. elseif(_GTK2_component STREQUAL "glade")
  686. _GTK2_FIND_INCLUDE_DIR(GLADE glade/glade.h)
  687. _GTK2_FIND_LIBRARY (GLADE glade false true)
  688. _GTK2_ADD_TARGET (GLADE GTK2_DEPENDS gtk gdk atk gio pangoft2 gdk_pixbuf pango gobject glib
  689. GTK2_OPTIONAL_DEPENDS pangocairo cairo
  690. OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}
  691. ${GTK2_FONTCONFIG_INCLUDE_DIR}
  692. ${GTK2_X11_INCLUDE_DIR})
  693. elseif(_GTK2_component STREQUAL "glademm")
  694. _GTK2_FIND_INCLUDE_DIR(GLADEMM libglademm.h)
  695. _GTK2_FIND_INCLUDE_DIR(GLADEMMCONFIG libglademmconfig.h)
  696. _GTK2_FIND_LIBRARY (GLADEMM glademm true true)
  697. _GTK2_ADD_TARGET (GLADEMM GTK2_DEPENDS gtkmm glade atkmm gdkmm giomm pangomm glibmm sigc++ gtk gdk atk pangoft2 gdk_pixbuf pango gthread gobject glib
  698. GTK2_OPTIONAL_DEPENDS giomm cairomm gio pangocairo cairo
  699. OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}
  700. ${GTK2_FONTCONFIG_INCLUDE_DIR}
  701. ${GTK2_X11_INCLUDE_DIR})
  702. else()
  703. message(FATAL_ERROR "Unknown GTK2 component ${_component}")
  704. endif()
  705. endforeach()
  706. #
  707. # Solve for the GTK2 version if we haven't already
  708. #
  709. if(NOT GTK2_FIND_VERSION AND GTK2_GTK_INCLUDE_DIR)
  710. _GTK2_GET_VERSION(GTK2_MAJOR_VERSION
  711. GTK2_MINOR_VERSION
  712. GTK2_PATCH_VERSION
  713. ${GTK2_GTK_INCLUDE_DIR}/gtk/gtkversion.h)
  714. set(GTK2_VERSION ${GTK2_MAJOR_VERSION}.${GTK2_MINOR_VERSION}.${GTK2_PATCH_VERSION})
  715. endif()
  716. #
  717. # Try to enforce components
  718. #
  719. set(_GTK2_did_we_find_everything true) # This gets set to GTK2_FOUND
  720. include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
  721. foreach(_GTK2_component ${GTK2_FIND_COMPONENTS})
  722. string(TOUPPER ${_GTK2_component} _COMPONENT_UPPER)
  723. set(GTK2_${_COMPONENT_UPPER}_FIND_QUIETLY ${GTK2_FIND_QUIETLY})
  724. if(_GTK2_component STREQUAL "gtk")
  725. FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK2_${_COMPONENT_UPPER} "Some or all of the gtk libraries were not found."
  726. GTK2_GTK_LIBRARY
  727. GTK2_GTK_INCLUDE_DIR
  728. GTK2_GDK_INCLUDE_DIR
  729. GTK2_GDKCONFIG_INCLUDE_DIR
  730. GTK2_GDK_LIBRARY
  731. GTK2_GLIB_INCLUDE_DIR
  732. GTK2_GLIBCONFIG_INCLUDE_DIR
  733. GTK2_GLIB_LIBRARY
  734. )
  735. elseif(_GTK2_component STREQUAL "gtkmm")
  736. FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK2_${_COMPONENT_UPPER} "Some or all of the gtkmm libraries were not found."
  737. GTK2_GTKMM_LIBRARY
  738. GTK2_GTKMM_INCLUDE_DIR
  739. GTK2_GTKMMCONFIG_INCLUDE_DIR
  740. GTK2_GDKMM_INCLUDE_DIR
  741. GTK2_GDKMMCONFIG_INCLUDE_DIR
  742. GTK2_GDKMM_LIBRARY
  743. GTK2_GLIBMM_INCLUDE_DIR
  744. GTK2_GLIBMMCONFIG_INCLUDE_DIR
  745. GTK2_GLIBMM_LIBRARY
  746. FREETYPE_INCLUDE_DIR_ft2build
  747. FREETYPE_INCLUDE_DIR_freetype2
  748. )
  749. elseif(_GTK2_component STREQUAL "glade")
  750. FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK2_${_COMPONENT_UPPER} "The glade library was not found."
  751. GTK2_GLADE_LIBRARY
  752. GTK2_GLADE_INCLUDE_DIR
  753. )
  754. elseif(_GTK2_component STREQUAL "glademm")
  755. FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK2_${_COMPONENT_UPPER} "The glademm library was not found."
  756. GTK2_GLADEMM_LIBRARY
  757. GTK2_GLADEMM_INCLUDE_DIR
  758. GTK2_GLADEMMCONFIG_INCLUDE_DIR
  759. )
  760. endif()
  761. if(NOT GTK2_${_COMPONENT_UPPER}_FOUND)
  762. set(_GTK2_did_we_find_everything false)
  763. endif()
  764. endforeach()
  765. if(GTK2_USE_IMPORTED_TARGETS)
  766. set(GTK2_LIBRARIES ${GTK2_TARGETS})
  767. endif()
  768. if(_GTK2_did_we_find_everything AND NOT GTK2_VERSION_CHECK_FAILED)
  769. set(GTK2_FOUND true)
  770. else()
  771. # Unset our variables.
  772. set(GTK2_FOUND false)
  773. set(GTK2_VERSION)
  774. set(GTK2_VERSION_MAJOR)
  775. set(GTK2_VERSION_MINOR)
  776. set(GTK2_VERSION_PATCH)
  777. set(GTK2_INCLUDE_DIRS)
  778. set(GTK2_LIBRARIES)
  779. set(GTK2_TARGETS)
  780. set(GTK2_DEFINITIONS)
  781. endif()
  782. if(GTK2_INCLUDE_DIRS)
  783. list(REMOVE_DUPLICATES GTK2_INCLUDE_DIRS)
  784. endif()