From a6e1e0cd6f7dead9406ca7846f22d6c50f984b01 Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Mon, 19 Feb 2024 13:46:15 -0600 Subject: [PATCH] CMake: bugfix: honor debug,optimized,release keywords in LIBRARIES and TARGETS --- cmake/macros/macro_process_feature.cmake | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/cmake/macros/macro_process_feature.cmake b/cmake/macros/macro_process_feature.cmake index a56a361ed3..de53634a25 100644 --- a/cmake/macros/macro_process_feature.cmake +++ b/cmake/macros/macro_process_feature.cmake @@ -166,6 +166,31 @@ macro(process_feature _feature) set(${_feature}_CLEAR_VARIABLES ${_clear} CACHE INTERNAL "") if(${_feature}_FOUND) + # + # Take care of "optimized", "debug", and "general" keywords in + # LIBRARIES and TARGETS variables by distributing affected entries into + # the respective LIBRARIES_(DEBUG|RELEASE) and TARGETS_(DEBUG|RELEASE) + # variables. + # + foreach(_suffix LIBRARIES TARGETS) + set(_temp ${_temp_${_suffix}}) + set(_temp_${_suffix} "") + set(_switch "") + foreach(_entry ${_temp}) + if("${_entry}" STREQUAL "optimized") + set(_split_configuration TRUE) + set(_switch "_RELEASE") + elseif("${_entry}" STREQUAL "debug") + set(_split_configuration TRUE) + set(_switch "_DEBUG") + elseif("${_entry}" STREQUAL "general") + set(_switch "") + else() + list(APPEND _temp_${_suffix}${_switch} ${_entry}) + endif() + endforeach() + endforeach() + # # Deduplicate and stringify entries: # -- 2.39.5