From f90e0171fe5de145197765894e655b84bbe287c3 Mon Sep 17 00:00:00 2001 From: Marco Antonio Jaguaribe Costa Date: Sun, 15 Jan 2023 18:07:36 -0300 Subject: [PATCH 1/2] simplify the language/executable validation function removing the 'ALL' corner-case so that the default behavior is to configure all valid languages and applications allows to simplify this function quite a bit --- CMakeLists.txt | 4 ++-- CMakePresets.json | 2 -- cmake/ValidateOptions.cmake | 27 +++++++++++---------------- 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1de14b1347..8c80b67d96 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -107,10 +107,10 @@ bfVFS include(cmake/ValidateOptions.cmake) set(ValidLanguages CHINESE DUTCH ENGLISH FRENCH GERMAN ITALIAN POLISH RUSSIAN) -ValidateOptions("${ValidLanguages}" "Languages" "ENGLISH" "${Languages}" "LangTargets") +ValidateOptions("${ValidLanguages}" "Languages" "${Languages}" "LangTargets") set(ValidApplications JA2 JA2MAPEDITOR JA2UB JA2UBMAPEDITOR) -ValidateOptions("${ValidApplications}" "Applications" "JA2" "${Applications}" "ApplicationTargets") +ValidateOptions("${ValidApplications}" "Applications" "${Applications}" "ApplicationTargets") # Due to widespread preprocessor definition abuse in the codebase, practically diff --git a/CMakePresets.json b/CMakePresets.json index 4c7deaa57d..e8419a74ac 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -6,8 +6,6 @@ "hidden": true, "generator": "Ninja", "cacheVariables": { - "Languages": "CHINESE;DUTCH;ENGLISH;FRENCH;GERMAN;ITALIAN;POLISH;RUSSIAN", - "Applications": "JA2;JA2MAPEDITOR;JA2UB;JA2UBMAPEDITOR", "CMAKE_RUNTIME_OUTPUT_DIRECTORY": "." }, "architecture": { diff --git a/cmake/ValidateOptions.cmake b/cmake/ValidateOptions.cmake index 11778f6bf6..3085695d49 100644 --- a/cmake/ValidateOptions.cmake +++ b/cmake/ValidateOptions.cmake @@ -1,20 +1,15 @@ -function(ValidateOptions ValidOptions ChoiceName DefaultChoice Choice RetVal) +function(ValidateOptions ValidOptions ChoiceName Choice RetVal) if(Choice) - if(Choice MATCHES "ALL") - set(${RetVal} ${ValidOptions} PARENT_SCOPE) - message(STATUS "ALL ${ChoiceName} option set, configuring ${ValidOptions}.") - else() - foreach(x IN LISTS Choice) - if(x IN_LIST ValidOptions) - message(STATUS "Configuring for ${x}.") - else() - message(FATAL_ERROR "${x} not supported. The supported ${ChoiceName} are: ${ValidOptions}.") - endif() - set(${RetVal} ${Choice} PARENT_SCOPE) - endforeach() - endif() + foreach(x IN LISTS Choice) + if(NOT x IN_LIST ValidOptions) + message(FATAL_ERROR "${ChoiceName}=\"${x}\" is not supported. Valid options are: ${ValidOptions}.") + endif() + endforeach() else() - set(${RetVal} ${DefaultChoice} PARENT_SCOPE) - message(STATUS "No -D${ChoiceName}= parameter, configuring ${DefaultChoice} by default.") + set(isDefault "by default.") + set(Choice ${ValidOptions}) endif() + message(STATUS "Configuring ${ChoiceName}=\"${Choice}\" ${isDefault}") + + set(${RetVal} ${Choice} PARENT_SCOPE) endfunction() From 45cad575432d1759d795e55d08aa5cbe413b1a27 Mon Sep 17 00:00:00 2001 From: Marco Antonio Jaguaribe Costa Date: Sun, 15 Jan 2023 19:38:00 -0300 Subject: [PATCH 2/2] keep the CMakePreset.json options listed for ease of use --- CMakePresets.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakePresets.json b/CMakePresets.json index e8419a74ac..4c7deaa57d 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -6,6 +6,8 @@ "hidden": true, "generator": "Ninja", "cacheVariables": { + "Languages": "CHINESE;DUTCH;ENGLISH;FRENCH;GERMAN;ITALIAN;POLISH;RUSSIAN", + "Applications": "JA2;JA2MAPEDITOR;JA2UB;JA2UBMAPEDITOR", "CMAKE_RUNTIME_OUTPUT_DIRECTORY": "." }, "architecture": {