From 55a97b0cb133b7a5dc28dfabec77a1b9f742c301 Mon Sep 17 00:00:00 2001 From: Thomas Sondergaard Date: Thu, 23 Jun 2022 08:51:50 +0200 Subject: [PATCH] CMakeLists.txt: Provide both 'freetype' and 'Freetype::Freetype' targets. FreeType can be located by consuming projects that use `find_package(Freetype)` either via the old `MODULE` path (which uses `FindFreetype.cmake` supplied by CMake), or via the new `CONFIG` path (which uses `freetype-config.cmake` as supplied by this project). Up to this point the CMake module has supplied the target `Freetype::Freetype` and the config file provided by this project the target `freetype`. Now we supply both `freetype` and `Freetype::Freetype` so that consuming projects can always use the target `Freetype::Freetype` regardless of what path was taken by `find_package(Freetype)`. Fixes #1165. --- CMakeLists.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d12897cba..feb4be39a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -498,6 +498,13 @@ if (BUILD_FRAMEWORK) ) endif () +# 'freetype-interface' is an interface library, to be accessed with +# `EXPORT_NAME Freetype::Freetype`. This is the target name provided by +# CMake's `FindFreetype.cmake`, so we provide it for compatibility. +add_library(freetype-interface INTERFACE) +set_target_properties(freetype-interface PROPERTIES + EXPORT_NAME Freetype::Freetype + INTERFACE_LINK_LIBRARIES freetype) set(PKGCONFIG_REQUIRES "") set(PKGCONFIG_REQUIRES_PRIVATE "") @@ -615,7 +622,7 @@ if (NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL) COMPATIBILITY SameMajorVersion) install( - TARGETS freetype + TARGETS freetype freetype-interface EXPORT freetype-targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}