Skip to content

Commit 7b13937

Browse files
committed
Handle multiple import configs in Forge Config file
(cherry picked from commit 0dffff2)
1 parent bf2d831 commit 7b13937

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

CMakeModules/ForgeConfig.cmake.in

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,24 @@ if (NOT TARGET Forge::forge AND
5757
endif ()
5858

5959
if (TARGET Forge::forge)
60-
get_property(config TARGET Forge::forge PROPERTY IMPORTED_CONFIGURATIONS)
61-
if(NOT config)
62-
set(config "NOCONFIG")
60+
get_property(configs TARGET Forge::forge PROPERTY IMPORTED_CONFIGURATIONS)
61+
if(NOT configs)
62+
set(configs "NOCONFIG")
6363
endif()
64-
get_property(loc TARGET Forge::forge PROPERTY IMPORTED_LOCATION_${config})
64+
foreach(config IN LISTS configs)
65+
get_property(loc TARGET Forge::forge PROPERTY IMPORTED_LOCATION_${config})
66+
67+
# break if any of the imported configurations exist. All configs write to the same
68+
# location so they are not working as CMake intended. Its fine for single config
69+
# installers like ours.
70+
if(EXISTS ${loc})
71+
set(Forge_BINARY_EXISTS TRUE)
72+
break()
73+
endif()
74+
endforeach()
6575
endif ()
6676

67-
if ((TARGET Forge::forge AND EXISTS ${loc})
68-
OR
69-
TARGET forge)
77+
if ((TARGET Forge::forge AND Forge_BINARY_EXISTS) OR TARGET forge)
7078
set(Forge_FOUND ON)
7179
if (TARGET forge AND NOT TARGET Forge::forge)
7280
add_library(Forge::forge ALIAS forge)

0 commit comments

Comments
 (0)