Fix "Cannot build project with CMake ..." (#970)

... (add_library cannot create ALIAS target "fltk" because target
"fltk::fltk" is imported but not globally visible)

It turned out that this was due to a CMake feature that was changed in
CMake 3.18. This commit makes imported FLTK targets globally visible
for CMake versions less than 3.18.
This commit is contained in:
Albrecht Schlosser 2024-05-13 12:05:27 +02:00
parent ef33f3e0e2
commit 6c06e953e1
1 changed files with 6 additions and 0 deletions

View File

@ -89,6 +89,12 @@ else(CMAKE_CROSSCOMPILING)
function(_fltk_make_alias target from)
if(TARGET ${from} AND NOT TARGET ${target})
# message(STATUS "FLTKConfig.cmake - create alias: ${target} from ${from}")
# promote imported target to global visibility (CMake < 3.18 only)
if(CMAKE_VERSION VERSION_LESS "3.18")
set_target_properties(${from} PROPERTIES IMPORTED_GLOBAL TRUE)
endif()
get_target_property(ttype ${from} TYPE)
if(ttype STREQUAL "EXECUTABLE")
add_executable(${target} ALIAS ${from})