FindGTK

備註

This module works only on Unix-like systems and was intended for early GTK branch of 1.x, which is no longer maintained. Use the latest supported GTK version and FindPkgConfig module to find GTK in CMake instead of this module. For example:

find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk4>=4.14)
target_link_libraries(example PRIVATE PkgConfig::GTK)

Finds GTK, glib and GTKGLArea:

find_package(GTK [...])

GTK is a multi-platform toolkit for creating graphical user interfaces.

結果變數

該模組定義了以下變數:

GTK_FOUND

Boolean indicating whether GTK was found.

GTK_GL_FOUND

Boolean indicating whether GTK's GL features were found.

GTK_INCLUDE_DIR

包含使用 GTK 所需的標頭檔的引入目錄。

GTK_LIBRARIES

Libraries needed to link against for using GTK.

範例

Finding GTK 1.x and creating an interface imported target that encapsulates its usage requirements for linking to a project target:

find_package(GTK)

if(GTK_FOUND)
  add_library(GTK::GTK INTERFACE IMPORTED)
  set_target_properties(
    GTK::GTK
    PROPERTIES
      INTERFACE_INCLUDE_DIRECTORIES "${GTK_INCLUDE_DIR}"
      INTERFACE_LINK_LIBRARIES "${GTK_LIBRARIES}"
  )
endif()

target_link_libraries(example PRIVATE GTK::GTK)

另請參見

  • The FindGTK2 module to find GTK version 2.