From 6c06e953e100f00da08b7f3f67c01d47e96ab978 Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Mon, 13 May 2024 12:05:27 +0200 Subject: [PATCH] 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. --- CMake/FLTKConfig.cmake.in | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMake/FLTKConfig.cmake.in b/CMake/FLTKConfig.cmake.in index 23f784698..0eef0585a 100644 --- a/CMake/FLTKConfig.cmake.in +++ b/CMake/FLTKConfig.cmake.in @@ -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})