Bug: `try_compile` does not work with `ALIAS` targets
Quick example:
add_library(Package::Target ALIAS PkgConfig::Package)
...
try_compile(test_package_api
SOURCES ${CMAKE_CURRENT_LIST_DIR}/test_package_api.cxx
LINK_LIBRARIES Package::Target
)
This one does not work because in the generated <targetName>Targets.cmake
the target is PkgConfig::Package
, while in the CMakeLists.txt
it is Package::Target
.
Temporary workaround try ALIASED_TARGET
beforehand to get the real target.
get_target_property(_real_target Package::Target ALIASED_TARGET)
if (NOT _real_target)
set(_real_target Package::Target)
endif ()
Edited by Cristian Le