summaryrefslogtreecommitdiff
path: root/CMake/FLTKConfig.cmake.in
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2024-05-13 12:05:27 +0200
committerAlbrecht Schlosser <albrechts.fltk@online.de>2024-05-13 12:05:27 +0200
commit6c06e953e100f00da08b7f3f67c01d47e96ab978 (patch)
treef62237e5a8c28709478bad9362259d4a97e1d865 /CMake/FLTKConfig.cmake.in
parentef33f3e0e2dac2087a4d3096146eb0c628a3a326 (diff)
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.
Diffstat (limited to 'CMake/FLTKConfig.cmake.in')
-rw-r--r--CMake/FLTKConfig.cmake.in6
1 files changed, 6 insertions, 0 deletions
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})