summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2021-07-16 14:18:31 (GMT)
committerKyle Edwards <kyle.edwards@kitware.com>2021-07-16 14:25:40 (GMT)
commitaa874dc6090cf6b6c9621572419738d105ff4ba3 (patch)
treec61ee79c28a4d8b3ff104eb317195eb738c8f2f7 /Tests
parent7c6234dd21b7af95e7edea6b281d859dafb2ae81 (diff)
downloadCMake-aa874dc6090cf6b6c9621572419738d105ff4ba3.zip
CMake-aa874dc6090cf6b6c9621572419738d105ff4ba3.tar.gz
CMake-aa874dc6090cf6b6c9621572419738d105ff4ba3.tar.bz2
CMakePresets.json: Fix expansion issue with empty binaryDir
When resolving binaryDir into a full path from a relative path, we forgot to check if binaryDir is altogether empty, causing empty binaryDir's to resolve to the source directory. Fix this. Fixes: #22434
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/CMakePresets/OptionalBinaryDirFieldNoS.cmake4
-rw-r--r--Tests/RunCMake/CMakePresets/OptionalBinaryDirFieldNoS.json.in9
-rw-r--r--Tests/RunCMake/CMakePresets/RunCMakeTest.cmake5
3 files changed, 18 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMakePresets/OptionalBinaryDirFieldNoS.cmake b/Tests/RunCMake/CMakePresets/OptionalBinaryDirFieldNoS.cmake
new file mode 100644
index 0000000..ae8a0de
--- /dev/null
+++ b/Tests/RunCMake/CMakePresets/OptionalBinaryDirFieldNoS.cmake
@@ -0,0 +1,4 @@
+include(${CMAKE_CURRENT_LIST_DIR}/TestVariable.cmake)
+
+get_filename_component(_parent_dir "${CMAKE_SOURCE_DIR}" DIRECTORY)
+test_variable(CMAKE_BINARY_DIR "" "${_parent_dir}/OptionalBinaryDirFieldNoS-build")
diff --git a/Tests/RunCMake/CMakePresets/OptionalBinaryDirFieldNoS.json.in b/Tests/RunCMake/CMakePresets/OptionalBinaryDirFieldNoS.json.in
new file mode 100644
index 0000000..0e3addd
--- /dev/null
+++ b/Tests/RunCMake/CMakePresets/OptionalBinaryDirFieldNoS.json.in
@@ -0,0 +1,9 @@
+{
+ "version": 3,
+ "configurePresets": [
+ {
+ "name": "OptionalBinaryDirFieldNoS",
+ "generator": "@RunCMake_GENERATOR@"
+ }
+ ]
+}
diff --git a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake
index 3b9806a..31bd8a4 100644
--- a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake
@@ -312,6 +312,11 @@ unset(CMakePresets_FILE)
# Test optional generator and buildDir fields
run_cmake_presets(OptionalBinaryDirField -B "${RunCMake_BINARY_DIR}/OptionalBinaryDirField/build")
run_cmake_presets(OptionalGeneratorField -G "${RunCMake_GENERATOR}")
+set(CMakePresets_NO_S_ARG TRUE)
+set(CMakePresets_SOURCE_ARG "../OptionalBinaryDirFieldNoS")
+run_cmake_presets(OptionalBinaryDirFieldNoS)
+unset(CMakePresets_SOURCE_ARG)
+unset(CMakePresets_NO_S_ARG)
# Test the example from the documentation
file(READ "${RunCMake_SOURCE_DIR}/../../../Help/manual/presets/example.json" _example)