Merge topic 'cxx-checks-tolerate-unused-arguments'
[kiteware-cmake.git] / Modules / FindGTK2.cmake
blob41f192be22baf5e042b1d4ba30db59935681df16
1 # Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2 # file Copyright.txt or https://cmake.org/licensing for details.
4 #[=======================================================================[.rst:
5 FindGTK2
6 --------
8 Find the GTK2 widget libraries and several of its other optional components
9 like ``gtkmm``, ``glade``, and ``glademm``.
11 Specify one or more of the following components as you call this find
12 module.  See example below.
14 * ``gtk``
15 * ``gtkmm``
16 * ``glade``
17 * ``glademm``
19 Imported Targets
20 ^^^^^^^^^^^^^^^^
22 This module defines the following :prop_tgt:`IMPORTED` targets (subject to
23 component selection):
25 ``GTK2::atk``, ``GTK2::atkmm``, ``GTK2::cairo``, ``GTK2::cairomm``,
26 ``GTK2::gdk_pixbuf``, ``GTK2::gdk``, ``GTK2::gdkmm``, ``GTK2::gio``,
27 ``GTK2::giomm``, ``GTK2::glade``, ``GTK2::glademm``, ``GTK2::glib``,
28 ``GTK2::glibmm``, ``GTK2::gmodule``, ``GTK2::gobject``, ``GTK2::gthread``,
29 ``GTK2::gtk``, ``GTK2::gtkmm``, ``GTK2::harfbuzz``, ``GTK2::pango``,
30 ``GTK2::pangocairo``, ``GTK2::pangoft2``, ``GTK2::pangomm``,
31 ``GTK2::pangoxft``, ``GTK2::sigc``.
33 .. versionadded:: 3.16.7
34   Added the ``GTK2::harfbuzz`` target.
36 Result Variables
37 ^^^^^^^^^^^^^^^^
39 The following variables will be defined for your use
41 ``GTK2_FOUND``
42   Were all of your specified components found?
43 ``GTK2_INCLUDE_DIRS``
44   All include directories
45 ``GTK2_LIBRARIES``
46   All libraries
47 ``GTK2_TARGETS``
48   .. versionadded:: 3.5
49     All imported targets
50 ``GTK2_DEFINITIONS``
51   Additional compiler flags
52 ``GTK2_VERSION``
53   The version of GTK2 found (x.y.z)
54 ``GTK2_MAJOR_VERSION``
55   The major version of GTK2
56 ``GTK2_MINOR_VERSION``
57   The minor version of GTK2
58 ``GTK2_PATCH_VERSION``
59   The patch version of GTK2
61 .. versionadded:: 3.5
62   When ``GTK2_USE_IMPORTED_TARGETS`` is set to ``TRUE``, ``GTK2_LIBRARIES``
63   will list imported targets instead of library paths.
65 Input Variables
66 ^^^^^^^^^^^^^^^
68 Optional variables you can define prior to calling this module:
70 ``GTK2_DEBUG``
71   Enables verbose debugging of the module
72 ``GTK2_ADDITIONAL_SUFFIXES``
73   Allows defining additional directories to search for include files
75 Example Usage
76 ^^^^^^^^^^^^^
78 Call :command:`find_package` once.  Here are some examples to pick from:
80 Require GTK 2.6 or later:
82 .. code-block:: cmake
84   find_package(GTK2 2.6 REQUIRED gtk)
86 Require GTK 2.10 or later and Glade:
88 .. code-block:: cmake
90   find_package(GTK2 2.10 REQUIRED gtk glade)
92 Search for GTK/GTKMM 2.8 or later:
94 .. code-block:: cmake
96   find_package(GTK2 2.8 COMPONENTS gtk gtkmm)
98 Use the results:
100 .. code-block:: cmake
102   if(GTK2_FOUND)
103     include_directories(${GTK2_INCLUDE_DIRS})
104     add_executable(mygui mygui.cc)
105     target_link_libraries(mygui ${GTK2_LIBRARIES})
106   endif()
107 #]=======================================================================]
109 # Version 1.6 (CMake 3.0)
110 #   * Create targets for each library
111 #   * Do not link libfreetype
112 # Version 1.5 (CMake 2.8.12)
113 #   * 14236: Detect gthread library
114 #            Detect pangocairo on windows
115 #            Detect pangocairo with gtk module instead of with gtkmm
116 #   * 14259: Use vc100 libraries with VS 11
117 #   * 14260: Export a GTK2_DEFINITIONS variable to set /vd2 when appropriate
118 #            (i.e. MSVC)
119 #   * Use the optimized/debug syntax for _LIBRARY and _LIBRARIES variables when
120 #     appropriate. A new set of _RELEASE variables was also added.
121 #   * Remove GTK2_SKIP_MARK_AS_ADVANCED option, as now the variables are
122 #     marked as advanced by SelectLibraryConfigurations
123 #   * Detect gmodule, pangoft2 and pangoxft libraries
124 # Version 1.4 (10/4/2012) (CMake 2.8.10)
125 #   * 12596: Missing paths for FindGTK2 on NetBSD
126 #   * 12049: Fixed detection of GTK include files in the lib folder on
127 #            multiarch systems.
128 # Version 1.3 (11/9/2010) (CMake 2.8.4)
129 #   * 11429: Add support for detecting GTK2 built with Visual Studio 10.
130 #            Thanks to Vincent Levesque for the patch.
131 # Version 1.2 (8/30/2010) (CMake 2.8.3)
132 #   * Merge patch for detecting gdk-pixbuf library (split off
133 #     from core GTK in 2.21).  Thanks to Vincent Untz for the patch
134 #     and Ricardo Cruz for the heads up.
135 # Version 1.1 (8/19/2010) (CMake 2.8.3)
136 #   * Add support for detecting GTK2 under macports (thanks to Gary Kramlich)
137 # Version 1.0 (8/12/2010) (CMake 2.8.3)
138 #   * Add support for detecting new pangommconfig.h header file
139 #     (Thanks to Sune Vuorela & the Debian Project for the patch)
140 #   * Add support for detecting fontconfig.h header
141 #   * Call find_package(Freetype) since it's required
142 #   * Add support for allowing users to add additional library directories
143 #     via the GTK2_ADDITIONAL_SUFFIXES variable (kind of a future-kludge in
144 #     case the GTK developers change versions on any of the directories in the
145 #     future).
146 # Version 0.8 (1/4/2010)
147 #   * Get module working under MacOSX fink by adding /sw/include, /sw/lib
148 #     to PATHS and the gobject library
149 # Version 0.7 (3/22/09)
150 #   * Checked into CMake CVS
151 #   * Added versioning support
152 #   * Module now defaults to searching for GTK if COMPONENTS not specified.
153 #   * Added HKCU prior to HKLM registry key and GTKMM specific environment
154 #      variable as per mailing list discussion.
155 #   * Added lib64 to include search path and a few other search paths where GTK
156 #      may be installed on Unix systems.
157 #   * Switched to lowercase CMake commands
158 #   * Prefaced internal variables with _GTK2 to prevent collision
159 #   * Changed internal macros to functions
160 #   * Enhanced documentation
161 # Version 0.6 (1/8/08)
162 #   Added GTK2_SKIP_MARK_AS_ADVANCED option
163 # Version 0.5 (12/19/08)
164 #   Second release to cmake mailing list
166 #=============================================================
167 # _GTK2_GET_VERSION
168 # Internal function to parse the version number in gtkversion.h
169 #   _OUT_major = Major version number
170 #   _OUT_minor = Minor version number
171 #   _OUT_micro = Micro version number
172 #   _gtkversion_hdr = Header file to parse
173 #=============================================================
175 include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
177 function(_GTK2_GET_VERSION _OUT_major _OUT_minor _OUT_micro _gtkversion_hdr)
178     cmake_policy(PUSH)
179     cmake_policy(SET CMP0159 NEW) # file(STRINGS) with REGEX updates CMAKE_MATCH_<n>
180     file(STRINGS ${_gtkversion_hdr} _contents REGEX "#define GTK_M[A-Z]+_VERSION[ \t]+")
181     cmake_policy(POP)
182     if(_contents)
183         string(REGEX REPLACE ".*#define GTK_MAJOR_VERSION[ \t]+\\(([0-9]+)\\).*" "\\1" ${_OUT_major} "${_contents}")
184         string(REGEX REPLACE ".*#define GTK_MINOR_VERSION[ \t]+\\(([0-9]+)\\).*" "\\1" ${_OUT_minor} "${_contents}")
185         string(REGEX REPLACE ".*#define GTK_MICRO_VERSION[ \t]+\\(([0-9]+)\\).*" "\\1" ${_OUT_micro} "${_contents}")
187         if(NOT ${_OUT_major} MATCHES "[0-9]+")
188             message(FATAL_ERROR "Version parsing failed for GTK2_MAJOR_VERSION!")
189         endif()
190         if(NOT ${_OUT_minor} MATCHES "[0-9]+")
191             message(FATAL_ERROR "Version parsing failed for GTK2_MINOR_VERSION!")
192         endif()
193         if(NOT ${_OUT_micro} MATCHES "[0-9]+")
194             message(FATAL_ERROR "Version parsing failed for GTK2_MICRO_VERSION!")
195         endif()
197         set(${_OUT_major} ${${_OUT_major}} PARENT_SCOPE)
198         set(${_OUT_minor} ${${_OUT_minor}} PARENT_SCOPE)
199         set(${_OUT_micro} ${${_OUT_micro}} PARENT_SCOPE)
200     else()
201         message(FATAL_ERROR "Include file ${_gtkversion_hdr} does not exist")
202     endif()
203 endfunction()
206 #=============================================================
207 # _GTK2_SIGCXX_GET_VERSION
208 # Internal function to parse the version number in
209 # sigc++config.h
210 #   _OUT_major = Major version number
211 #   _OUT_minor = Minor version number
212 #   _OUT_micro = Micro version number
213 #   _sigcxxversion_hdr = Header file to parse
214 #=============================================================
216 function(_GTK2_SIGCXX_GET_VERSION _OUT_major _OUT_minor _OUT_micro _sigcxxversion_hdr)
217     cmake_policy(PUSH)
218     cmake_policy(SET CMP0159 NEW) # file(STRINGS) with REGEX updates CMAKE_MATCH_<n>
219     file(STRINGS ${_sigcxxversion_hdr} _contents REGEX "#define SIGCXX_M[A-Z]+_VERSION[ \t]+")
220     cmake_policy(POP)
221     if(_contents)
222         string(REGEX REPLACE ".*#define SIGCXX_MAJOR_VERSION[ \t]+([0-9]+).*" "\\1" ${_OUT_major} "${_contents}")
223         string(REGEX REPLACE ".*#define SIGCXX_MINOR_VERSION[ \t]+([0-9]+).*" "\\1" ${_OUT_minor} "${_contents}")
224         string(REGEX REPLACE ".*#define SIGCXX_MICRO_VERSION[ \t]+([0-9]+).*" "\\1" ${_OUT_micro} "${_contents}")
226         if(NOT ${_OUT_major} MATCHES "[0-9]+")
227             message(FATAL_ERROR "Version parsing failed for SIGCXX_MAJOR_VERSION!")
228         endif()
229         if(NOT ${_OUT_minor} MATCHES "[0-9]+")
230             message(FATAL_ERROR "Version parsing failed for SIGCXX_MINOR_VERSION!")
231         endif()
232         if(NOT ${_OUT_micro} MATCHES "[0-9]+")
233             message(FATAL_ERROR "Version parsing failed for SIGCXX_MICRO_VERSION!")
234         endif()
236         set(${_OUT_major} ${${_OUT_major}} PARENT_SCOPE)
237         set(${_OUT_minor} ${${_OUT_minor}} PARENT_SCOPE)
238         set(${_OUT_micro} ${${_OUT_micro}} PARENT_SCOPE)
239     else()
240         # The header does not have the version macros; assume it is ``0.0.0``.
241         set(${_OUT_major} 0)
242         set(${_OUT_minor} 0)
243         set(${_OUT_micro} 0)
244     endif()
245 endfunction()
248 #=============================================================
249 # _GTK2_FIND_INCLUDE_DIR
250 # Internal function to find the GTK include directories
251 #   _var = variable to set (_INCLUDE_DIR is appended)
252 #   _hdr = header file to look for
253 #=============================================================
254 function(_GTK2_FIND_INCLUDE_DIR _var _hdr)
256     if(GTK2_DEBUG)
257         message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
258                        "_GTK2_FIND_INCLUDE_DIR( ${_var} ${_hdr} )")
259     endif()
261     set(_gtk_packages
262         # If these ever change, things will break.
263         ${GTK2_ADDITIONAL_SUFFIXES}
264         glibmm-2.4
265         glib-2.0
266         atk-1.0
267         atkmm-1.6
268         cairo
269         cairomm-1.0
270         gdk-pixbuf-2.0
271         gdkmm-2.4
272         giomm-2.4
273         gtk-2.0
274         gtkmm-2.4
275         libglade-2.0
276         libglademm-2.4
277         harfbuzz
278         pango-1.0
279         pangomm-1.4
280         sigc++-2.0
281     )
283     #
284     # NOTE: The following suffixes cause searching for header files in both of
285     # these directories:
286     #         /usr/include/<pkg>
287     #         /usr/lib/<pkg>/include
288     #
290     set(_suffixes)
291     foreach(_d ${_gtk_packages})
292         list(APPEND _suffixes ${_d})
293         list(APPEND _suffixes ${_d}/include) # for /usr/lib/gtk-2.0/include
294     endforeach()
296     if(GTK2_DEBUG)
297         message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}]     "
298                        "include suffixes = ${_suffixes}")
299     endif()
301     if(CMAKE_LIBRARY_ARCHITECTURE)
302       set(_gtk2_arch_dir /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE})
303       if(GTK2_DEBUG)
304         message(STATUS "Adding ${_gtk2_arch_dir} to search path for multiarch support")
305       endif()
306     endif()
307     find_path(GTK2_${_var}_INCLUDE_DIR ${_hdr}
308         PATHS
309             ${_gtk2_arch_dir}
310             /usr/local/libx32
311             /usr/local/lib64
312             /usr/local/lib
313             /usr/libx32
314             /usr/lib64
315             /usr/lib
316             /opt/gnome/include
317             /opt/gnome/lib
318             /opt/openwin/include
319             /usr/openwin/lib
320             /sw/lib
321             /opt/local/lib
322             /opt/homebrew/lib
323             /usr/pkg/lib
324             /usr/pkg/include/glib
325             $ENV{GTKMM_BASEPATH}/include
326             $ENV{GTKMM_BASEPATH}/lib
327             [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]/include
328             [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]/lib
329             [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]/include
330             [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]/lib
331         PATH_SUFFIXES
332             ${_suffixes}
333     )
334     mark_as_advanced(GTK2_${_var}_INCLUDE_DIR)
336     if(GTK2_${_var}_INCLUDE_DIR)
337         set(GTK2_INCLUDE_DIRS ${GTK2_INCLUDE_DIRS} ${GTK2_${_var}_INCLUDE_DIR} PARENT_SCOPE)
338     endif()
340 endfunction()
342 #=============================================================
343 # _GTK2_FIND_LIBRARY
344 # Internal function to find libraries packaged with GTK2
345 #   _var = library variable to create (_LIBRARY is appended)
346 #=============================================================
347 function(_GTK2_FIND_LIBRARY _var _lib _expand_vc _append_version)
349     if(GTK2_DEBUG)
350         message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
351                        "_GTK2_FIND_LIBRARY( ${_var} ${_lib} ${_expand_vc} ${_append_version} )")
352     endif()
354     # Not GTK versions per se but the versions encoded into Windows
355     # import libraries (GtkMM 2.14.1 has a gtkmm-vc80-2_4.lib for example)
356     # Also the MSVC libraries use _ for . (this is handled below)
357     set(_versions 2.20 2.18 2.16 2.14 2.12
358                   2.10  2.8  2.6  2.4  2.2 2.0
359                   1.20 1.18 1.16 1.14 1.12
360                   1.10  1.8  1.6  1.4  1.2 1.0)
362     set(_library)
363     set(_library_d)
365     set(_library ${_lib})
367     if(_expand_vc AND MSVC)
368         # Add vc80/vc90/vc100 midfixes
369         if(MSVC_TOOLSET_VERSION LESS 110)
370             set(_library   ${_library}-vc${MSVC_TOOLSET_VERSION})
371         else()
372             # Up to gtkmm-win 2.22.0-2 there are no vc110 libraries but vc100 can be used
373             set(_library ${_library}-vc100)
374         endif()
375         set(_library_d ${_library}-d)
376     endif()
378     if(GTK2_DEBUG)
379         message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}]     "
380                        "After midfix addition = ${_library} and ${_library_d}")
381     endif()
383     set(_lib_list)
384     set(_libd_list)
385     if(_append_version)
386         foreach(_ver ${_versions})
387             list(APPEND _lib_list  "${_library}-${_ver}")
388             list(APPEND _libd_list "${_library_d}-${_ver}")
389         endforeach()
390     else()
391         set(_lib_list ${_library})
392         set(_libd_list ${_library_d})
393     endif()
395     if(GTK2_DEBUG)
396         message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}]     "
397                        "library list = ${_lib_list} and library debug list = ${_libd_list}")
398     endif()
400     # For some silly reason the MSVC libraries use _ instead of .
401     # in the version fields
402     if(_expand_vc AND MSVC)
403         set(_no_dots_lib_list)
404         set(_no_dots_libd_list)
405         foreach(_l ${_lib_list})
406             string(REPLACE "." "_" _no_dots_library ${_l})
407             list(APPEND _no_dots_lib_list ${_no_dots_library})
408         endforeach()
409         # And for debug
410         set(_no_dots_libsd_list)
411         foreach(_l ${_libd_list})
412             string(REPLACE "." "_" _no_dots_libraryd ${_l})
413             list(APPEND _no_dots_libd_list ${_no_dots_libraryd})
414         endforeach()
416         # Copy list back to original names
417         set(_lib_list ${_no_dots_lib_list})
418         set(_libd_list ${_no_dots_libd_list})
419     endif()
421     if(GTK2_DEBUG)
422         message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}]     "
423                        "While searching for GTK2_${_var}_LIBRARY, our proposed library list is ${_lib_list}")
424     endif()
426     find_library(GTK2_${_var}_LIBRARY_RELEASE
427         NAMES ${_lib_list}
428         PATHS
429             /opt/gnome/lib
430             /usr/openwin/lib
431             $ENV{GTKMM_BASEPATH}/lib
432             [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]/lib
433             [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]/lib
434         )
436     if(_expand_vc AND MSVC)
437         if(GTK2_DEBUG)
438             message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}]     "
439                            "While searching for GTK2_${_var}_LIBRARY_DEBUG our proposed library list is ${_libd_list}")
440         endif()
442         find_library(GTK2_${_var}_LIBRARY_DEBUG
443             NAMES ${_libd_list}
444             PATHS
445             $ENV{GTKMM_BASEPATH}/lib
446             [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]/lib
447             [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]/lib
448         )
449     endif()
451     select_library_configurations(GTK2_${_var})
453     set(GTK2_${_var}_LIBRARY ${GTK2_${_var}_LIBRARY} PARENT_SCOPE)
454     set(GTK2_${_var}_FOUND ${GTK2_${_var}_FOUND} PARENT_SCOPE)
456     if(GTK2_${_var}_FOUND)
457         set(GTK2_LIBRARIES ${GTK2_LIBRARIES} ${GTK2_${_var}_LIBRARY})
458         set(GTK2_LIBRARIES ${GTK2_LIBRARIES} PARENT_SCOPE)
459     endif()
461     if(GTK2_DEBUG)
462         message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}]     "
463                        "GTK2_${_var}_LIBRARY_RELEASE = \"${GTK2_${_var}_LIBRARY_RELEASE}\"")
464         message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}]     "
465                        "GTK2_${_var}_LIBRARY_DEBUG   = \"${GTK2_${_var}_LIBRARY_DEBUG}\"")
466         message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}]     "
467                        "GTK2_${_var}_LIBRARY         = \"${GTK2_${_var}_LIBRARY}\"")
468         message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}]     "
469                        "GTK2_${_var}_FOUND           = \"${GTK2_${_var}_FOUND}\"")
470     endif()
472 endfunction()
475 function(_GTK2_ADD_TARGET_DEPENDS_INTERNAL _var _property)
476     if(GTK2_DEBUG)
477         message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
478                        "_GTK2_ADD_TARGET_DEPENDS_INTERNAL( ${_var} ${_property} )")
479     endif()
481     string(TOLOWER "${_var}" _basename)
483     if (TARGET GTK2::${_basename})
484         foreach(_depend ${ARGN})
485             set(_valid_depends)
486             if (TARGET GTK2::${_depend})
487                 list(APPEND _valid_depends GTK2::${_depend})
488             endif()
489             if (_valid_depends)
490                 set_property(TARGET GTK2::${_basename} APPEND PROPERTY ${_property} "${_valid_depends}")
491             endif()
492             set(_valid_depends)
493         endforeach()
494     endif()
495 endfunction()
497 function(_GTK2_ADD_TARGET_DEPENDS _var)
498     if(GTK2_DEBUG)
499         message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
500                        "_GTK2_ADD_TARGET_DEPENDS( ${_var} )")
501     endif()
503     string(TOLOWER "${_var}" _basename)
505     if(TARGET GTK2::${_basename})
506         get_target_property(_configs GTK2::${_basename} IMPORTED_CONFIGURATIONS)
507         _GTK2_ADD_TARGET_DEPENDS_INTERNAL(${_var} INTERFACE_LINK_LIBRARIES ${ARGN})
508         foreach(_config ${_configs})
509             _GTK2_ADD_TARGET_DEPENDS_INTERNAL(${_var} IMPORTED_LINK_INTERFACE_LIBRARIES_${_config} ${ARGN})
510         endforeach()
511     endif()
512 endfunction()
514 function(_GTK2_ADD_TARGET_INCLUDE_DIRS _var)
515     if(GTK2_DEBUG)
516         message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
517                        "_GTK2_ADD_TARGET_INCLUDE_DIRS( ${_var} )")
518     endif()
520     string(TOLOWER "${_var}" _basename)
522     if(TARGET GTK2::${_basename})
523         foreach(_include ${ARGN})
524             set_property(TARGET GTK2::${_basename} APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${_include}")
525         endforeach()
526     endif()
527 endfunction()
529 #=============================================================
530 # _GTK2_ADD_TARGET
531 # Internal function to create targets for GTK2
532 #   _var = target to create
533 #=============================================================
534 function(_GTK2_ADD_TARGET _var)
535     if(GTK2_DEBUG)
536         message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
537                        "_GTK2_ADD_TARGET( ${_var} )")
538     endif()
540     string(TOLOWER "${_var}" _basename)
542     cmake_parse_arguments(_${_var} "" "" "GTK2_DEPENDS;GTK2_OPTIONAL_DEPENDS;OPTIONAL_INCLUDES" ${ARGN})
544     if(GTK2_${_var}_FOUND)
545         if(NOT TARGET GTK2::${_basename})
546             # Do not create the target if dependencies are missing
547             foreach(_dep ${_${_var}_GTK2_DEPENDS})
548                 if(NOT TARGET GTK2::${_dep})
549                     return()
550                 endif()
551             endforeach()
553             add_library(GTK2::${_basename} UNKNOWN IMPORTED)
555             if(GTK2_${_var}_LIBRARY_RELEASE)
556                 set_property(TARGET GTK2::${_basename} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
557                 set_property(TARGET GTK2::${_basename}        PROPERTY IMPORTED_LOCATION_RELEASE "${GTK2_${_var}_LIBRARY_RELEASE}" )
558             endif()
560             if(GTK2_${_var}_LIBRARY_DEBUG)
561                 set_property(TARGET GTK2::${_basename} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
562                 set_property(TARGET GTK2::${_basename}        PROPERTY IMPORTED_LOCATION_DEBUG "${GTK2_${_var}_LIBRARY_DEBUG}" )
563             endif()
565             if(GTK2_${_var}_INCLUDE_DIR)
566                 set_property(TARGET GTK2::${_basename} APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${GTK2_${_var}_INCLUDE_DIR}")
567             endif()
569             if(GTK2_${_var}CONFIG_INCLUDE_DIR AND NOT "x${GTK2_${_var}CONFIG_INCLUDE_DIR}" STREQUAL "x${GTK2_${_var}_INCLUDE_DIR}")
570                 set_property(TARGET GTK2::${_basename} APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${GTK2_${_var}CONFIG_INCLUDE_DIR}")
571             endif()
573             if(GTK2_DEFINITIONS)
574                 set_property(TARGET GTK2::${_basename} PROPERTY INTERFACE_COMPILE_DEFINITIONS "${GTK2_DEFINITIONS}")
575             endif()
577             if(_${_var}_GTK2_DEPENDS)
578                 _GTK2_ADD_TARGET_DEPENDS(${_var} ${_${_var}_GTK2_DEPENDS} ${_${_var}_GTK2_OPTIONAL_DEPENDS})
579             endif()
581             if(_${_var}_OPTIONAL_INCLUDES)
582                 foreach(_D ${_${_var}_OPTIONAL_INCLUDES})
583                     if(_D)
584                         _GTK2_ADD_TARGET_INCLUDE_DIRS(${_var} ${_D})
585                     endif()
586                 endforeach()
587             endif()
588         endif()
590         set(GTK2_TARGETS ${GTK2_TARGETS} GTK2::${_basename})
591         set(GTK2_TARGETS ${GTK2_TARGETS} PARENT_SCOPE)
593         if(GTK2_USE_IMPORTED_TARGETS)
594             set(GTK2_${_var}_LIBRARY GTK2::${_basename} PARENT_SCOPE)
595         endif()
597     endif()
598 endfunction()
602 #=============================================================
605 # main()
608 set(GTK2_FOUND)
609 set(GTK2_INCLUDE_DIRS)
610 set(GTK2_LIBRARIES)
611 set(GTK2_TARGETS)
612 set(GTK2_DEFINITIONS)
614 if(NOT GTK2_FIND_COMPONENTS)
615     # Assume they only want GTK
616     set(GTK2_FIND_COMPONENTS gtk)
617 endif()
620 # If specified, enforce version number
622 if(GTK2_FIND_VERSION)
623     set(GTK2_FAILED_VERSION_CHECK true)
624     if(GTK2_DEBUG)
625         message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
626                        "Searching for version ${GTK2_FIND_VERSION}")
627     endif()
628     _GTK2_FIND_INCLUDE_DIR(GTK gtk/gtk.h)
629     if(GTK2_GTK_INCLUDE_DIR)
630         _GTK2_GET_VERSION(GTK2_MAJOR_VERSION
631                           GTK2_MINOR_VERSION
632                           GTK2_PATCH_VERSION
633                           ${GTK2_GTK_INCLUDE_DIR}/gtk/gtkversion.h)
634         set(GTK2_VERSION
635             ${GTK2_MAJOR_VERSION}.${GTK2_MINOR_VERSION}.${GTK2_PATCH_VERSION})
636         if(GTK2_FIND_VERSION_EXACT)
637             if(GTK2_VERSION VERSION_EQUAL GTK2_FIND_VERSION)
638                 set(GTK2_FAILED_VERSION_CHECK false)
639             endif()
640         else()
641             if(GTK2_VERSION VERSION_EQUAL   GTK2_FIND_VERSION OR
642                GTK2_VERSION VERSION_GREATER GTK2_FIND_VERSION)
643                 set(GTK2_FAILED_VERSION_CHECK false)
644             endif()
645         endif()
646     else()
647         # If we can't find the GTK include dir, we can't do version checking
648         if(GTK2_FIND_REQUIRED AND NOT GTK2_FIND_QUIETLY)
649             message(FATAL_ERROR "Could not find GTK2 include directory")
650         endif()
651         return()
652     endif()
654     if(GTK2_FAILED_VERSION_CHECK)
655         if(GTK2_FIND_REQUIRED AND NOT GTK2_FIND_QUIETLY)
656             if(GTK2_FIND_VERSION_EXACT)
657                 message(FATAL_ERROR "GTK2 version check failed.  Version ${GTK2_VERSION} was found, version ${GTK2_FIND_VERSION} is needed exactly.")
658             else()
659                 message(FATAL_ERROR "GTK2 version check failed.  Version ${GTK2_VERSION} was found, at least version ${GTK2_FIND_VERSION} is required")
660             endif()
661         endif()
663         # If the version check fails, exit out of the module here
664         return()
665     endif()
666 endif()
669 # On MSVC, according to https://wiki.gnome.org/gtkmm/MSWindows, the /vd2 flag needs to be
670 # passed to the compiler in order to use gtkmm
672 if(MSVC)
673     foreach(_GTK2_component ${GTK2_FIND_COMPONENTS})
674         if(_GTK2_component STREQUAL "gtkmm")
675             set(GTK2_DEFINITIONS "/vd2")
676         elseif(_GTK2_component STREQUAL "glademm")
677             set(GTK2_DEFINITIONS "/vd2")
678         endif()
679     endforeach()
680 endif()
683 # Find all components
686 find_package(Freetype QUIET)
687 if(FREETYPE_INCLUDE_DIR_ft2build AND FREETYPE_INCLUDE_DIR_freetype2)
688     list(APPEND GTK2_INCLUDE_DIRS ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2})
689 endif()
691 foreach(_GTK2_component ${GTK2_FIND_COMPONENTS})
692     if(_GTK2_component STREQUAL "gtk")
693         # Left for compatibility with previous versions.
694         _GTK2_FIND_INCLUDE_DIR(FONTCONFIG fontconfig/fontconfig.h)
695         _GTK2_FIND_INCLUDE_DIR(X11 X11/Xlib.h)
697         _GTK2_FIND_INCLUDE_DIR(GLIB glib.h)
698         _GTK2_FIND_INCLUDE_DIR(GLIBCONFIG glibconfig.h)
699         _GTK2_FIND_LIBRARY    (GLIB glib false true)
700         _GTK2_ADD_TARGET      (GLIB)
702         _GTK2_FIND_INCLUDE_DIR(GOBJECT glib-object.h)
703         _GTK2_FIND_LIBRARY    (GOBJECT gobject false true)
704         _GTK2_ADD_TARGET      (GOBJECT GTK2_DEPENDS glib)
706         _GTK2_FIND_INCLUDE_DIR(ATK atk/atk.h)
707         _GTK2_FIND_LIBRARY    (ATK atk false true)
708         _GTK2_ADD_TARGET      (ATK GTK2_DEPENDS gobject glib)
710         _GTK2_FIND_LIBRARY    (GIO gio false true)
711         _GTK2_ADD_TARGET      (GIO GTK2_DEPENDS gobject glib)
713         _GTK2_FIND_LIBRARY    (GTHREAD gthread false true)
714         _GTK2_ADD_TARGET      (GTHREAD GTK2_DEPENDS glib)
716         _GTK2_FIND_LIBRARY    (GMODULE gmodule false true)
717         _GTK2_ADD_TARGET      (GMODULE GTK2_DEPENDS glib)
719         _GTK2_FIND_INCLUDE_DIR(GDK_PIXBUF gdk-pixbuf/gdk-pixbuf.h)
720         _GTK2_FIND_LIBRARY    (GDK_PIXBUF gdk_pixbuf false true)
721         _GTK2_ADD_TARGET      (GDK_PIXBUF GTK2_DEPENDS gobject glib)
723         _GTK2_FIND_INCLUDE_DIR(CAIRO cairo.h)
724         _GTK2_FIND_LIBRARY    (CAIRO cairo false false)
725         _GTK2_ADD_TARGET      (CAIRO)
727         _GTK2_FIND_INCLUDE_DIR(HARFBUZZ hb.h)
728         _GTK2_FIND_LIBRARY    (HARFBUZZ harfbuzz false false)
729         _GTK2_ADD_TARGET      (HARFBUZZ)
731         _GTK2_FIND_INCLUDE_DIR(PANGO pango/pango.h)
732         _GTK2_FIND_LIBRARY    (PANGO pango false true)
733         _GTK2_ADD_TARGET      (PANGO GTK2_DEPENDS gobject glib
734                                      GTK2_OPTIONAL_DEPENDS harfbuzz)
736         _GTK2_FIND_LIBRARY    (PANGOCAIRO pangocairo false true)
737         _GTK2_ADD_TARGET      (PANGOCAIRO GTK2_DEPENDS pango cairo gobject glib)
739         _GTK2_FIND_LIBRARY    (PANGOFT2 pangoft2 false true)
740         _GTK2_ADD_TARGET      (PANGOFT2 GTK2_DEPENDS pango gobject glib
741                                         OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}
742                                                           ${GTK2_FONTCONFIG_INCLUDE_DIR}
743                                                           ${GTK2_X11_INCLUDE_DIR})
745         _GTK2_FIND_LIBRARY    (PANGOXFT pangoxft false true)
746         _GTK2_ADD_TARGET      (PANGOXFT GTK2_DEPENDS pangoft2 pango gobject glib
747                                         OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}
748                                                           ${GTK2_FONTCONFIG_INCLUDE_DIR}
749                                                           ${GTK2_X11_INCLUDE_DIR})
751         _GTK2_FIND_INCLUDE_DIR(GDK gdk/gdk.h)
752         _GTK2_FIND_INCLUDE_DIR(GDKCONFIG gdkconfig.h)
753         if(UNIX)
754             if(APPLE)
755                 _GTK2_FIND_LIBRARY    (GDK gdk-quartz false true)
756             endif()
757             _GTK2_FIND_LIBRARY    (GDK gdk-x11 false true)
758         else()
759             _GTK2_FIND_LIBRARY    (GDK gdk-win32 false true)
760         endif()
761         _GTK2_ADD_TARGET (GDK GTK2_DEPENDS pango gdk_pixbuf gobject glib
762                               GTK2_OPTIONAL_DEPENDS pangocairo cairo)
764         _GTK2_FIND_INCLUDE_DIR(GTK gtk/gtk.h)
765         if(UNIX)
766             if(APPLE)
767                 _GTK2_FIND_LIBRARY    (GTK gtk-quartz false true)
768             endif()
769             _GTK2_FIND_LIBRARY    (GTK gtk-x11 false true)
770         else()
771             _GTK2_FIND_LIBRARY    (GTK gtk-win32 false true)
772         endif()
773         _GTK2_ADD_TARGET (GTK GTK2_DEPENDS gdk atk pangoft2 pango gdk_pixbuf gthread gobject glib
774                               GTK2_OPTIONAL_DEPENDS gio pangocairo cairo)
776     elseif(_GTK2_component STREQUAL "gtkmm")
778         _GTK2_FIND_INCLUDE_DIR(SIGC++ sigc++/sigc++.h)
779         _GTK2_FIND_INCLUDE_DIR(SIGC++CONFIG sigc++config.h)
780         _GTK2_FIND_LIBRARY    (SIGC++ sigc true true)
781         _GTK2_ADD_TARGET      (SIGC++)
782         # Since sigc++ 2.5.1 c++11 support is required
783         if(GTK2_SIGC++CONFIG_INCLUDE_DIR)
784             _GTK2_SIGCXX_GET_VERSION(GTK2_SIGC++_VERSION_MAJOR
785                                      GTK2_SIGC++_VERSION_MINOR
786                                      GTK2_SIGC++_VERSION_MICRO
787                                      ${GTK2_SIGC++CONFIG_INCLUDE_DIR}/sigc++config.h)
788             if(NOT ${GTK2_SIGC++_VERSION_MAJOR}.${GTK2_SIGC++_VERSION_MINOR}.${GTK2_SIGC++_VERSION_MICRO} VERSION_LESS 2.5.1)
789                 # These are the features needed by clients in order to include the
790                 # project headers:
791                 set_property(TARGET GTK2::sigc++
792                              PROPERTY INTERFACE_COMPILE_FEATURES cxx_alias_templates
793                                                                  cxx_auto_type
794                                                                  cxx_decltype
795                                                                  cxx_deleted_functions
796                                                                  cxx_noexcept
797                                                                  cxx_nullptr
798                                                                  cxx_right_angle_brackets
799                                                                  cxx_rvalue_references
800                                                                  cxx_variadic_templates)
801             endif()
802         endif()
804         _GTK2_FIND_INCLUDE_DIR(GLIBMM glibmm.h)
805         _GTK2_FIND_INCLUDE_DIR(GLIBMMCONFIG glibmmconfig.h)
806         _GTK2_FIND_LIBRARY    (GLIBMM glibmm true true)
807         _GTK2_ADD_TARGET      (GLIBMM GTK2_DEPENDS gobject sigc++ glib)
809         _GTK2_FIND_INCLUDE_DIR(GIOMM giomm.h)
810         _GTK2_FIND_INCLUDE_DIR(GIOMMCONFIG giommconfig.h)
811         _GTK2_FIND_LIBRARY    (GIOMM giomm true true)
812         _GTK2_ADD_TARGET      (GIOMM GTK2_DEPENDS gio glibmm gobject sigc++ glib)
814         _GTK2_FIND_INCLUDE_DIR(ATKMM atkmm.h)
815         _GTK2_FIND_INCLUDE_DIR(ATKMMCONFIG atkmmconfig.h)
816         _GTK2_FIND_LIBRARY    (ATKMM atkmm true true)
817         _GTK2_ADD_TARGET      (ATKMM GTK2_DEPENDS atk glibmm gobject sigc++ glib)
819         _GTK2_FIND_INCLUDE_DIR(CAIROMM cairomm/cairomm.h)
820         _GTK2_FIND_INCLUDE_DIR(CAIROMMCONFIG cairommconfig.h)
821         _GTK2_FIND_LIBRARY    (CAIROMM cairomm true true)
822         _GTK2_ADD_TARGET      (CAIROMM GTK2_DEPENDS cairo sigc++
823                                        OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}
824                                                          ${GTK2_FONTCONFIG_INCLUDE_DIR}
825                                                          ${GTK2_X11_INCLUDE_DIR})
827         _GTK2_FIND_INCLUDE_DIR(PANGOMM pangomm.h)
828         _GTK2_FIND_INCLUDE_DIR(PANGOMMCONFIG pangommconfig.h)
829         _GTK2_FIND_LIBRARY    (PANGOMM pangomm true true)
830         _GTK2_ADD_TARGET      (PANGOMM GTK2_DEPENDS glibmm sigc++ pango gobject glib
831                                        GTK2_OPTIONAL_DEPENDS cairomm pangocairo cairo
832                                        OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}
833                                                          ${GTK2_FONTCONFIG_INCLUDE_DIR}
834                                                          ${GTK2_X11_INCLUDE_DIR})
836         _GTK2_FIND_INCLUDE_DIR(GDKMM gdkmm.h)
837         _GTK2_FIND_INCLUDE_DIR(GDKMMCONFIG gdkmmconfig.h)
838         _GTK2_FIND_LIBRARY    (GDKMM gdkmm true true)
839         _GTK2_ADD_TARGET      (GDKMM GTK2_DEPENDS pangomm gtk glibmm sigc++ gdk atk pangoft2 gdk_pixbuf pango gobject glib
840                                      GTK2_OPTIONAL_DEPENDS giomm cairomm gio pangocairo cairo
841                                      OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}
842                                                        ${GTK2_FONTCONFIG_INCLUDE_DIR}
843                                                        ${GTK2_X11_INCLUDE_DIR})
845         _GTK2_FIND_INCLUDE_DIR(GTKMM gtkmm.h)
846         _GTK2_FIND_INCLUDE_DIR(GTKMMCONFIG gtkmmconfig.h)
847         _GTK2_FIND_LIBRARY    (GTKMM gtkmm true true)
848         _GTK2_ADD_TARGET      (GTKMM GTK2_DEPENDS atkmm gdkmm pangomm gtk glibmm sigc++ gdk atk pangoft2 gdk_pixbuf pango gthread gobject glib
849                                      GTK2_OPTIONAL_DEPENDS giomm cairomm gio pangocairo cairo
850                                      OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}
851                                                        ${GTK2_FONTCONFIG_INCLUDE_DIR}
852                                                        ${GTK2_X11_INCLUDE_DIR})
854     elseif(_GTK2_component STREQUAL "glade")
856         _GTK2_FIND_INCLUDE_DIR(GLADE glade/glade.h)
857         _GTK2_FIND_LIBRARY    (GLADE glade false true)
858         _GTK2_ADD_TARGET      (GLADE GTK2_DEPENDS gtk gdk atk gio pangoft2 gdk_pixbuf pango gobject glib
859                                      GTK2_OPTIONAL_DEPENDS pangocairo cairo
860                                      OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}
861                                                        ${GTK2_FONTCONFIG_INCLUDE_DIR}
862                                                        ${GTK2_X11_INCLUDE_DIR})
864     elseif(_GTK2_component STREQUAL "glademm")
866         _GTK2_FIND_INCLUDE_DIR(GLADEMM libglademm.h)
867         _GTK2_FIND_INCLUDE_DIR(GLADEMMCONFIG libglademmconfig.h)
868         _GTK2_FIND_LIBRARY    (GLADEMM glademm true true)
869         _GTK2_ADD_TARGET      (GLADEMM GTK2_DEPENDS gtkmm glade atkmm gdkmm giomm pangomm glibmm sigc++ gtk gdk atk pangoft2 gdk_pixbuf pango gthread gobject glib
870                                        GTK2_OPTIONAL_DEPENDS giomm cairomm gio pangocairo cairo
871                                        OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}
872                                                          ${GTK2_FONTCONFIG_INCLUDE_DIR}
873                                                          ${GTK2_X11_INCLUDE_DIR})
875     else()
876         message(FATAL_ERROR "Unknown GTK2 component ${_component}")
877     endif()
878 endforeach()
881 # Solve for the GTK2 version if we haven't already
883 if(NOT GTK2_FIND_VERSION AND GTK2_GTK_INCLUDE_DIR)
884     _GTK2_GET_VERSION(GTK2_MAJOR_VERSION
885                       GTK2_MINOR_VERSION
886                       GTK2_PATCH_VERSION
887                       ${GTK2_GTK_INCLUDE_DIR}/gtk/gtkversion.h)
888     set(GTK2_VERSION ${GTK2_MAJOR_VERSION}.${GTK2_MINOR_VERSION}.${GTK2_PATCH_VERSION})
889 endif()
892 # Try to enforce components
895 set(_GTK2_did_we_find_everything true)  # This gets set to GTK2_FOUND
897 include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
899 foreach(_GTK2_component ${GTK2_FIND_COMPONENTS})
900     string(TOUPPER ${_GTK2_component} _COMPONENT_UPPER)
902     set(GTK2_${_COMPONENT_UPPER}_FIND_QUIETLY ${GTK2_FIND_QUIETLY})
904     set(FPHSA_NAME_MISMATCHED 1)
905     if(_GTK2_component STREQUAL "gtk")
906         FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK2_${_COMPONENT_UPPER} "Some or all of the gtk libraries were not found."
907             GTK2_GTK_LIBRARY
908             GTK2_GTK_INCLUDE_DIR
910             GTK2_GDK_INCLUDE_DIR
911             GTK2_GDKCONFIG_INCLUDE_DIR
912             GTK2_GDK_LIBRARY
914             GTK2_GLIB_INCLUDE_DIR
915             GTK2_GLIBCONFIG_INCLUDE_DIR
916             GTK2_GLIB_LIBRARY
917         )
918     elseif(_GTK2_component STREQUAL "gtkmm")
919         FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK2_${_COMPONENT_UPPER} "Some or all of the gtkmm libraries were not found."
920             GTK2_GTKMM_LIBRARY
921             GTK2_GTKMM_INCLUDE_DIR
922             GTK2_GTKMMCONFIG_INCLUDE_DIR
924             GTK2_GDKMM_INCLUDE_DIR
925             GTK2_GDKMMCONFIG_INCLUDE_DIR
926             GTK2_GDKMM_LIBRARY
928             GTK2_GLIBMM_INCLUDE_DIR
929             GTK2_GLIBMMCONFIG_INCLUDE_DIR
930             GTK2_GLIBMM_LIBRARY
932             FREETYPE_INCLUDE_DIR_ft2build
933             FREETYPE_INCLUDE_DIR_freetype2
934         )
935     elseif(_GTK2_component STREQUAL "glade")
936         FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK2_${_COMPONENT_UPPER} "The glade library was not found."
937             GTK2_GLADE_LIBRARY
938             GTK2_GLADE_INCLUDE_DIR
939         )
940     elseif(_GTK2_component STREQUAL "glademm")
941         FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK2_${_COMPONENT_UPPER} "The glademm library was not found."
942             GTK2_GLADEMM_LIBRARY
943             GTK2_GLADEMM_INCLUDE_DIR
944             GTK2_GLADEMMCONFIG_INCLUDE_DIR
945         )
946     endif()
947     unset(FPHSA_NAME_MISMATCHED)
949     if(NOT GTK2_${_COMPONENT_UPPER}_FOUND)
950         set(_GTK2_did_we_find_everything false)
951     endif()
952 endforeach()
954 if(GTK2_USE_IMPORTED_TARGETS)
955     set(GTK2_LIBRARIES ${GTK2_TARGETS})
956 endif()
959 if(_GTK2_did_we_find_everything AND NOT GTK2_VERSION_CHECK_FAILED)
960     set(GTK2_FOUND true)
961 else()
962     # Unset our variables.
963     set(GTK2_FOUND false)
964     set(GTK2_VERSION)
965     set(GTK2_VERSION_MAJOR)
966     set(GTK2_VERSION_MINOR)
967     set(GTK2_VERSION_PATCH)
968     set(GTK2_INCLUDE_DIRS)
969     set(GTK2_LIBRARIES)
970     set(GTK2_TARGETS)
971     set(GTK2_DEFINITIONS)
972 endif()
974 if(GTK2_INCLUDE_DIRS)
975   list(REMOVE_DUPLICATES GTK2_INCLUDE_DIRS)
976 endif()