From ccaa1e5abd95738f503b6f4c875313b69afb95f1 Mon Sep 17 00:00:00 2001 From: pradeep Date: Sun, 2 May 2021 03:03:35 +0530 Subject: [PATCH] Handle multiple import configs in Forge Config file --- CMakeModules/ForgeConfig.cmake.in | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/CMakeModules/ForgeConfig.cmake.in b/CMakeModules/ForgeConfig.cmake.in index e4c7737f..6fb18ac2 100644 --- a/CMakeModules/ForgeConfig.cmake.in +++ b/CMakeModules/ForgeConfig.cmake.in @@ -57,16 +57,24 @@ if (NOT TARGET Forge::forge AND endif () if (TARGET Forge::forge) - get_property(config TARGET Forge::forge PROPERTY IMPORTED_CONFIGURATIONS) - if(NOT config) - set(config "NOCONFIG") + get_property(configs TARGET Forge::forge PROPERTY IMPORTED_CONFIGURATIONS) + if(NOT configs) + set(configs "NOCONFIG") endif() - get_property(loc TARGET Forge::forge PROPERTY IMPORTED_LOCATION_${config}) + foreach(config IN LISTS configs) + get_property(loc TARGET Forge::forge PROPERTY IMPORTED_LOCATION_${config}) + + # break if any of the imported configurations exist. All configs write to the same + # location so they are not working as CMake intended. Its fine for single config + # installers like ours. + if(EXISTS ${loc}) + set(Forge_BINARY_EXISTS TRUE) + break() + endif() + endforeach() endif () -if ((TARGET Forge::forge AND EXISTS ${loc}) - OR - TARGET forge) +if ((TARGET Forge::forge AND Forge_BINARY_EXISTS) OR TARGET forge) set(Forge_FOUND ON) if (TARGET forge AND NOT TARGET Forge::forge) add_library(Forge::forge ALIAS forge)