mirror of
https://github.com/Kitware/CMake.git
synced 2025-12-31 19:00:54 -06:00
@@ -1068,6 +1068,17 @@ Recognized macros include:
|
||||
|
||||
A literal dollar sign (``$``).
|
||||
|
||||
``${pathListSep}``
|
||||
|
||||
Native character for separating lists of paths, such as ``:`` or ``;``.
|
||||
|
||||
For example, by setting ``PATH`` to
|
||||
``/path/to/ninja/bin${pathListSep}$env{PATH}``, ``${pathListSep}`` will
|
||||
expand to the underlying operating system's character used for
|
||||
concatenation in ``PATH``.
|
||||
|
||||
This is allowed in preset files specifying version ``5`` or above.
|
||||
|
||||
``$env{<variable-name>}``
|
||||
|
||||
Environment variable with name ``<variable-name>``. The variable name may
|
||||
|
||||
5
Help/release/dev/presets-pathListSep.rst
Normal file
5
Help/release/dev/presets-pathListSep.rst
Normal file
@@ -0,0 +1,5 @@
|
||||
presets-pathListSep
|
||||
-------------------
|
||||
|
||||
* :manual:`cmake-presets(7)` files now support a ``${pathListSep}`` macro,
|
||||
which expands to ``:`` or ``;`` based on the platform.
|
||||
@@ -361,6 +361,13 @@ bool ExpandMacros(const cmCMakePresetsGraph& graph, const T& preset,
|
||||
cmSystemTools::GetParentDirectory(preset.OriginFile->Filename);
|
||||
return ExpandMacroResult::Ok;
|
||||
}
|
||||
if (macroName == "pathListSep") {
|
||||
if (version < 5) {
|
||||
return ExpandMacroResult::Error;
|
||||
}
|
||||
macroOut += cmSystemTools::GetSystemPathlistSeparator();
|
||||
return ExpandMacroResult::Ok;
|
||||
}
|
||||
}
|
||||
|
||||
return ExpandMacroResult::Ignore;
|
||||
|
||||
@@ -3429,3 +3429,12 @@ cm::string_view cmSystemTools::GetSystemName()
|
||||
return "";
|
||||
#endif
|
||||
}
|
||||
|
||||
char cmSystemTools::GetSystemPathlistSeparator()
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
return ';';
|
||||
#else
|
||||
return ':';
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -535,6 +535,9 @@ public:
|
||||
/** Get the system name. */
|
||||
static cm::string_view GetSystemName();
|
||||
|
||||
/** Get the system path separator character */
|
||||
static char GetSystemPathlistSeparator();
|
||||
|
||||
private:
|
||||
static bool s_ForceUnixPaths;
|
||||
static bool s_RunCommandHideConsole;
|
||||
|
||||
7
Tests/RunCMake/CMakePresets/PathListSep.cmake
Normal file
7
Tests/RunCMake/CMakePresets/PathListSep.cmake
Normal file
@@ -0,0 +1,7 @@
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/TestVariable.cmake)
|
||||
|
||||
if(CMAKE_HOST_WIN32)
|
||||
test_variable(TEST_PATH_LIST_SEP "" "${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
else()
|
||||
test_variable(TEST_PATH_LIST_SEP "" "${CMAKE_CURRENT_SOURCE_DIR}:${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
endif()
|
||||
13
Tests/RunCMake/CMakePresets/PathListSep.json.in
Normal file
13
Tests/RunCMake/CMakePresets/PathListSep.json.in
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"version": 5,
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "PathListSep",
|
||||
"generator": "@RunCMake_GENERATOR@",
|
||||
"binaryDir": "${sourceDir}/build",
|
||||
"cacheVariables": {
|
||||
"TEST_PATH_LIST_SEP": "${sourceDir}${pathListSep}${sourceDir}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
1
Tests/RunCMake/CMakePresets/PathListSepFuture-result.txt
Normal file
1
Tests/RunCMake/CMakePresets/PathListSepFuture-result.txt
Normal file
@@ -0,0 +1 @@
|
||||
1
|
||||
2
Tests/RunCMake/CMakePresets/PathListSepFuture-stderr.txt
Normal file
2
Tests/RunCMake/CMakePresets/PathListSepFuture-stderr.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
^CMake Error: Could not read presets from [^
|
||||
]*/Tests/RunCMake/CMakePresets/PathListSepFuture: Invalid macro expansion$
|
||||
13
Tests/RunCMake/CMakePresets/PathListSepFuture.json.in
Normal file
13
Tests/RunCMake/CMakePresets/PathListSepFuture.json.in
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"version": 4,
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "PathListSepFuture",
|
||||
"generator": "@RunCMake_GENERATOR@",
|
||||
"binaryDir": "${sourceDir}/build",
|
||||
"cacheVariables": {
|
||||
"TEST_PATH_LIST_SEP": "${sourceDir}${pathListSep}${sourceDir}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -335,6 +335,12 @@ unset(CMakePresets_EXTRA_FILES)
|
||||
set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/FileDirFuture.json.in")
|
||||
run_cmake_presets(FileDirFuture)
|
||||
|
||||
# Test ${pathListSep} macro
|
||||
set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/PathListSep.json.in")
|
||||
run_cmake_presets(PathListSep)
|
||||
set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/PathListSepFuture.json.in")
|
||||
run_cmake_presets(PathListSepFuture)
|
||||
|
||||
# Test conditions
|
||||
set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/Conditions.json.in")
|
||||
run_cmake_presets(ListConditions --list-presets)
|
||||
|
||||
Reference in New Issue
Block a user