From 93323cc1dc437704764b0eb487cf23041859a30b Mon Sep 17 00:00:00 2001 From: John Ralls Date: Sun, 10 Dec 2023 13:21:21 -0800 Subject: [PATCH] Fix Win32 build, broken by COMMAND_EXPAND_LISTS Create a win32 analog to make_unix_path_list that escapes the semicolons to prevent cmake turning them into list delimiters. --- common/cmake_modules/GncAddSchemeTargets.cmake | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/common/cmake_modules/GncAddSchemeTargets.cmake b/common/cmake_modules/GncAddSchemeTargets.cmake index 97c3c9d009..9a038def23 100644 --- a/common/cmake_modules/GncAddSchemeTargets.cmake +++ b/common/cmake_modules/GncAddSchemeTargets.cmake @@ -20,11 +20,20 @@ function(make_unix_path PATH) set(${PATH} ${newpath} PARENT_SCOPE) endfunction() -#PATH variables in the environment are separated by colons, but CMake lists are separated by semicolons. This function transforms the separators. +# PATH variables in the environment are separated by colons, but CMake +# lists are separated by semicolons. This function transforms the +# separators. function(make_unix_path_list PATH) string(REPLACE ";" ":" newpath "${${PATH}}") set(${PATH} ${newpath} PARENT_SCOPE) endfunction() +# Meanwhile cmake treats the semicolons in Win32 path lists as its own +# list separators converting them into spaces on the command +# line. Escape them to prevent that. +function(make_win32_path_list PATH) + string(REPLACE ";" "\\\;" newpath "${${PATH}}") + set(${PATH} "${newpath}" PARENT_SCOPE) +endfunction() # This function will set two or four environment variables to a directory in the parent PARENT_SCOPE # * _DIRCLASS (eg "prefix", "sitedir" is used to construct the variable name(s) and in error messages @@ -241,6 +250,7 @@ function(gnc_add_scheme_targets _TARGET) set(fpath "") file(TO_CMAKE_PATH "$ENV{PATH}" fpath) set(LIBRARY_PATH "PATH=${BINDIR_BUILD};${fpath}") + make_win32_path_list(LIBRARY_PATH) else() set (LIBRARY_PATH "LD_LIBRARY_PATH=${LIBDIR_BUILD}:${LIBDIR_BUILD}/gnucash:$ENV{LD_LIBRARY_PATH}") endif() @@ -256,6 +266,9 @@ function(gnc_add_scheme_targets _TARGET) if(NOT MINGW64 OR ${GUILE_EFFECTIVE_VERSION} VERSION_LESS 2.2) make_unix_path_list(_GUILE_LOAD_PATH) make_unix_path_list(_GUILE_LOAD_COMPILED_PATH) + elseif(MINGW64) + make_win32_path_list(_GUILE_LOAD_PATH) + make_win32_path_list(_GUILE_LOAD_COMPILED_PATH) endif() make_unix_path_list(_GNC_MODULE_PATH) if (__DEBUG)