qt5base-lts/cmake/FindWrapSystemFreetype.cmake
Alexandru Croitor b0772b41c2 CMake: Display found information in some of the Find modules
Change-Id: I5d92f2f1a552888361a2939577c2b0177c62b596
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-06-26 22:14:48 +02:00

38 lines
1.4 KiB
CMake

# We can't create the same interface imported target multiple times, CMake will complain if we do
# that. This can happen if the find_package call is done in multiple different subdirectories.
if(TARGET WrapSystemFreetype::WrapSystemFreetype)
set(WrapSystemFreetype_FOUND ON)
return()
endif()
set(WrapSystemFreetype_FOUND OFF)
# Hunter has the package named freetype, but exports the Freetype::Freetype target as upstream
# First try the CONFIG package, and afterwards the MODULE if not found
find_package(Freetype QUIET CONFIG NAMES Freetype freetype QUIET)
if(NOT Freetype_FOUND)
find_package(Freetype QUIET MODULE)
endif()
if(Freetype_FOUND)
# vcpkg defines a lower case target name, while upstream Find module defines a prefixed
# upper case name.
set(potential_target_names Freetype::Freetype freetype)
foreach(target_name ${potential_target_names})
if(TARGET ${target_name})
set(WrapSystemFreetype_FOUND ON)
set(final_target_name ${target_name})
add_library(WrapSystemFreetype::WrapSystemFreetype INTERFACE IMPORTED)
target_link_libraries(WrapSystemFreetype::WrapSystemFreetype INTERFACE
${final_target_name})
break()
endif()
endforeach()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(WrapSystemFreetype DEFAULT_MSG WrapSystemFreetype_FOUND)