9d96c8da78
vcpkg and upstream CMake find module define different target names for the same package. To circumvent this, create our own Wrap find module, and link against it. Inside the find module, try both target names. Change-Id: Iba488bce0fb410ddb83f6414244f86ad367de72b Reviewed-by: Liang Qi <liang.qi@qt.io> Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
27 lines
931 B
CMake
27 lines
931 B
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 WrapFreetype::WrapFreetype)
|
|
set(WrapFreetype_FOUND ON)
|
|
return()
|
|
endif()
|
|
|
|
set(WrapFreetype_FOUND OFF)
|
|
find_package(Freetype)
|
|
|
|
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(WrapFreetype_FOUND ON)
|
|
set(final_target_name ${target_name})
|
|
|
|
add_library(WrapFreetype::WrapFreetype INTERFACE IMPORTED)
|
|
target_link_libraries(WrapFreetype::WrapFreetype INTERFACE ${final_target_name})
|
|
|
|
break()
|
|
endif()
|
|
endforeach()
|
|
endif()
|