2021-03-17 21:29:00 +01:00
|
|
|
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
# file Copyright.txt or https://cmake.org/licensing for details.
|
2020-11-20 21:15:27 +01:00
|
|
|
|
|
|
|
#[=======================================================================[.rst:
|
|
|
|
FindCairo
|
2021-03-17 21:29:00 +01:00
|
|
|
-----------
|
|
|
|
|
|
|
|
Find Cairo 2D graphics library.
|
2020-11-20 21:15:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
Imported Targets
|
|
|
|
^^^^^^^^^^^^^^^^
|
2021-03-17 21:29:00 +01:00
|
|
|
This module defines :prop_tgt:`IMPORTED` target ``Cairo::Cairo``, if
|
|
|
|
cairo has been found.
|
2020-11-20 21:15:27 +01:00
|
|
|
|
2021-03-17 21:29:00 +01:00
|
|
|
Result variables
|
2020-11-20 21:15:27 +01:00
|
|
|
^^^^^^^^^^^^^^^^
|
|
|
|
|
2021-03-17 21:29:00 +01:00
|
|
|
This module will set the following variables in your project:
|
|
|
|
|
|
|
|
``CAIRO_FOUND``
|
|
|
|
True if cairo headers and library were found.
|
|
|
|
``CAIRO_INCLUDE_DIRS``
|
|
|
|
Directory where cairo headers are located.
|
|
|
|
``CAIRO_LIBRARIES``
|
|
|
|
cairo libraries to link against.
|
|
|
|
``CAIRO_VERSION_MAJOR``
|
|
|
|
The major version of cairo
|
|
|
|
``CAIRO_VERSION_MINOR``
|
|
|
|
The minor version of cairo
|
|
|
|
``CAIRO_VERSION_PATCH``
|
|
|
|
The patch version of cairo
|
|
|
|
``CAIRO_VERSION_STRING``
|
|
|
|
version number as a string (ex: "1.16.0")
|
2020-11-20 21:15:27 +01:00
|
|
|
#]=======================================================================]
|
|
|
|
|
2021-03-17 21:29:00 +01:00
|
|
|
if(NOT CAIRO_LIBRARY)
|
|
|
|
find_path(CAIRO_INCLUDE_DIR NAMES cairo.h HINTS ${PC_CAIRO_INCLUDEDIR} ${PC_CAIRO_INCLUDE_DIR} PATH_SUFFIXES cairo)
|
|
|
|
find_library(CAIRO_LIBRARY_RELEASE NAMES ${Cairo_NAMES} cairo HINTS ${PC_CAIRO_LIBDIR} ${PC_CAIRO_LIBRARY_DIRS})
|
|
|
|
find_library(CAIRO_LIBRARY_DEBUG NAMES ${Cairo_NAMES} cairod HINTS ${PC_CAIRO_LIBDIR} ${PC_CAIRO_LIBRARY_DIRS})
|
|
|
|
include(SelectLibraryConfigurations)
|
|
|
|
select_library_configurations(CAIRO)
|
|
|
|
else()
|
|
|
|
file(TO_CMAKE_PATH "${CAIRO_LIBRARY}" CAIRO_LIBRARY)
|
|
|
|
endif()
|
2021-01-27 00:42:19 +01:00
|
|
|
|
2021-03-17 21:29:00 +01:00
|
|
|
if(CAIRO_INCLUDE_DIR AND NOT CAIRO_VERSION)
|
|
|
|
if(EXISTS "${CAIRO_INCLUDE_DIR}/cairo-version.h")
|
|
|
|
file(READ "${CAIRO_INCLUDE_DIR}/cairo-version.h" CAIRO_VERSION_CONTENT)
|
2020-11-20 21:15:27 +01:00
|
|
|
|
2021-03-17 21:29:00 +01:00
|
|
|
string(REGEX MATCH "#define +CAIRO_VERSION_MAJOR +([0-9]+)" _dummy "${CAIRO_VERSION_CONTENT}")
|
|
|
|
set(CAIRO_VERSION_MAJOR "${CMAKE_MATCH_1}")
|
2020-11-20 21:15:27 +01:00
|
|
|
|
2021-03-17 21:29:00 +01:00
|
|
|
string(REGEX MATCH "#define +CAIRO_VERSION_MINOR +([0-9]+)" _dummy "${CAIRO_VERSION_CONTENT}")
|
|
|
|
set(CAIRO_VERSION_MINOR "${CMAKE_MATCH_1}")
|
2020-11-20 21:15:27 +01:00
|
|
|
|
2021-03-17 21:29:00 +01:00
|
|
|
string(REGEX MATCH "#define +CAIRO_VERSION_MICRO +([0-9]+)" _dummy "${CAIRO_VERSION_CONTENT}")
|
|
|
|
set(CAIRO_VERSION_PATCH "${CMAKE_MATCH_1}")
|
2020-11-20 21:15:27 +01:00
|
|
|
|
2021-03-17 21:29:00 +01:00
|
|
|
set(CAIRO_VERSION "${CAIRO_VERSION_MAJOR}.${CAIRO_VERSION_MINOR}.${CAIRO_VERSION_PATCH}")
|
|
|
|
set(CAIRO_VERSION_STRING ${CAIRO_VERSION})
|
|
|
|
endif()
|
|
|
|
endif()
|
2020-11-20 21:15:27 +01:00
|
|
|
|
|
|
|
include(FindPackageHandleStandardArgs)
|
2022-08-11 22:54:50 +02:00
|
|
|
find_package_handle_standard_args(Cairo
|
|
|
|
REQUIRED_VARS
|
2021-03-17 21:29:00 +01:00
|
|
|
CAIRO_LIBRARY
|
|
|
|
CAIRO_INCLUDE_DIR
|
2022-08-11 22:54:50 +02:00
|
|
|
VERSION_VAR
|
2021-03-17 21:29:00 +01:00
|
|
|
CAIRO_VERSION_STRING
|
|
|
|
)
|
|
|
|
mark_as_advanced(CAIRO_INCLUDE_DIR CAIRO_LIBRARY)
|
2020-11-20 21:15:27 +01:00
|
|
|
|
2021-03-17 21:29:00 +01:00
|
|
|
if (CAIRO_FOUND)
|
|
|
|
set(CAIRO_LIBRARIES ${CAIRO_LIBRARY})
|
|
|
|
set(CAIRO_INCLUDE_DIRS ${CAIRO_INCLUDE_DIR})
|
|
|
|
if(NOT TARGET Cairo::Cairo)
|
|
|
|
add_library(Cairo::Cairo UNKNOWN IMPORTED)
|
2020-11-20 21:15:27 +01:00
|
|
|
set_target_properties(Cairo::Cairo PROPERTIES
|
2021-03-17 21:29:00 +01:00
|
|
|
INTERFACE_INCLUDE_DIRECTORIES ${CAIRO_INCLUDE_DIR}
|
|
|
|
IMPORTED_LINK_INTERFACE_LANGUAGES C)
|
|
|
|
|
|
|
|
if(CAIRO_LIBRARY_RELEASE)
|
|
|
|
set_property(TARGET Cairo::Cairo APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
|
|
|
|
set_target_properties(Cairo::Cairo PROPERTIES IMPORTED_LOCATION_RELEASE "${CAIRO_LIBRARY_RELEASE}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(CAIRO_LIBRARY_DEBUG)
|
|
|
|
set_property(TARGET Cairo::Cairo APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
|
|
|
|
set_target_properties(Cairo::Cairo PROPERTIES IMPORTED_LOCATION_DEBUG "${CAIRO_LIBRARY_DEBUG}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT CAIRO_LIBRARY_RELEASE AND NOT CAIRO_LIBRARY_DEBUG)
|
|
|
|
set_target_properties(Cairo::Cairo PROPERTIES IMPORTED_LOCATION "${CAIRO_LIBRARY}")
|
|
|
|
endif()
|
|
|
|
endif()
|
2021-01-27 00:42:19 +01:00
|
|
|
endif ()
|