diff options
author | Robert Maynard <rmaynard@nvidia.com> | 2021-04-07 18:24:14 (GMT) |
---|---|---|
committer | Robert Maynard <rmaynard@nvidia.com> | 2021-04-15 14:13:49 (GMT) |
commit | d5c3e4ac326328dd4ca48b12b27b11ea19d87363 (patch) | |
tree | 45d0f8e2a50582be6c89885fa52f36bb68d9080c /Tests/RunCMake/CommandLine | |
parent | 13838bbb36dbfeb36243d661378732672477ac8a (diff) | |
download | CMake-d5c3e4ac326328dd4ca48b12b27b11ea19d87363.zip CMake-d5c3e4ac326328dd4ca48b12b27b11ea19d87363.tar.gz CMake-d5c3e4ac326328dd4ca48b12b27b11ea19d87363.tar.bz2 |
cmake: add support for --toolchain command argument
Diffstat (limited to 'Tests/RunCMake/CommandLine')
11 files changed, 36 insertions, 1 deletions
diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index c497472..bf5a96e 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -61,7 +61,6 @@ run_cmake_command(build-bad-dir run_cmake_command(build-bad-generator ${CMAKE_COMMAND} --build ${RunCMake_SOURCE_DIR}/cache-bad-generator) - run_cmake_command(install-prefix-no-arg ${CMAKE_COMMAND} -B DummyBuildDir --install-prefix) run_cmake_command(install-no-dir @@ -153,6 +152,29 @@ project(ExplicitDirsMissing LANGUAGES NONE) endfunction() run_ExplicitDirs() +function(run_Toolchain) + set(RunCMake_TEST_NO_SOURCE_DIR 1) + set(source_dir ${RunCMake_SOURCE_DIR}/Toolchain) + + run_cmake_with_options(toolchain-no-arg -S ${source_dir} --toolchain=) + run_cmake_with_options(toolchain-valid-abs-path -S ${source_dir} --toolchain "${source_dir}/toolchain.cmake") + run_cmake_with_options(toolchain-valid-rel-src-path -S ${source_dir} --toolchain=toolchain.cmake) + + set(RunCMake_TEST_NO_CLEAN 1) + set(binary_dir ${RunCMake_BINARY_DIR}/Toolchain-build) + set(RunCMake_TEST_BINARY_DIR "${binary_dir}") + file(REMOVE_RECURSE "${binary_dir}") + + # Test that we both search the binary dir for toolchain files, and it takes + # precedence over source dir + file(WRITE ${binary_dir}/toolchain.cmake [=[ +set(CMAKE_SYSTEM_NAME Linux) +set(toolchain_file binary_dir) +]=]) + run_cmake_with_options(toolchain-valid-rel-build-path ${CMAKE_COMMAND} -S ${source_dir} -B ${binary_dir} --toolchain toolchain.cmake) +endfunction() +run_Toolchain() + function(run_BuildDir) # Use a single build tree for a few tests without cleaning. set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/BuildDir-build) diff --git a/Tests/RunCMake/CommandLine/Toolchain/CMakeLists.txt b/Tests/RunCMake/CommandLine/Toolchain/CMakeLists.txt new file mode 100644 index 0000000..80d42b8 --- /dev/null +++ b/Tests/RunCMake/CommandLine/Toolchain/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.20) +project(Toolchain LANGUAGES NONE) +message(FATAL_ERROR "${toolchain_file}") diff --git a/Tests/RunCMake/CommandLine/Toolchain/toolchain.cmake b/Tests/RunCMake/CommandLine/Toolchain/toolchain.cmake new file mode 100644 index 0000000..719556c --- /dev/null +++ b/Tests/RunCMake/CommandLine/Toolchain/toolchain.cmake @@ -0,0 +1,2 @@ +set(CMAKE_SYSTEM_NAME Linux) +set(toolchain_file source_dir) diff --git a/Tests/RunCMake/CommandLine/toolchain-no-arg-result.txt b/Tests/RunCMake/CommandLine/toolchain-no-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/toolchain-no-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/toolchain-no-arg-stderr.txt b/Tests/RunCMake/CommandLine/toolchain-no-arg-stderr.txt new file mode 100644 index 0000000..2fec517 --- /dev/null +++ b/Tests/RunCMake/CommandLine/toolchain-no-arg-stderr.txt @@ -0,0 +1 @@ +^CMake Error: No file specified for --toolchain diff --git a/Tests/RunCMake/CommandLine/toolchain-valid-abs-path-result.txt b/Tests/RunCMake/CommandLine/toolchain-valid-abs-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/toolchain-valid-abs-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/toolchain-valid-abs-path-stderr.txt b/Tests/RunCMake/CommandLine/toolchain-valid-abs-path-stderr.txt new file mode 100644 index 0000000..21d5db6 --- /dev/null +++ b/Tests/RunCMake/CommandLine/toolchain-valid-abs-path-stderr.txt @@ -0,0 +1 @@ +^CMake Error.*source_dir diff --git a/Tests/RunCMake/CommandLine/toolchain-valid-rel-build-path-result.txt b/Tests/RunCMake/CommandLine/toolchain-valid-rel-build-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/toolchain-valid-rel-build-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/toolchain-valid-rel-build-path-stderr.txt b/Tests/RunCMake/CommandLine/toolchain-valid-rel-build-path-stderr.txt new file mode 100644 index 0000000..1980051 --- /dev/null +++ b/Tests/RunCMake/CommandLine/toolchain-valid-rel-build-path-stderr.txt @@ -0,0 +1 @@ +^CMake Error.*binary_dir diff --git a/Tests/RunCMake/CommandLine/toolchain-valid-rel-src-path-result.txt b/Tests/RunCMake/CommandLine/toolchain-valid-rel-src-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/toolchain-valid-rel-src-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/toolchain-valid-rel-src-path-stderr.txt b/Tests/RunCMake/CommandLine/toolchain-valid-rel-src-path-stderr.txt new file mode 100644 index 0000000..21d5db6 --- /dev/null +++ b/Tests/RunCMake/CommandLine/toolchain-valid-rel-src-path-stderr.txt @@ -0,0 +1 @@ +^CMake Error.*source_dir |