diff options
author | Brad King <brad.king@kitware.com> | 2017-10-03 18:53:34 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-10-19 14:20:08 (GMT) |
commit | 314613d1afd069dd896aa0d5112dfbf2b82af3c3 (patch) | |
tree | d6de6878803459df63b60c86e42c5a1faa6c8fc2 /Tests/RunCMake/GeneratorInstance | |
parent | 358ceee5d84723f60c2db5cdff52445d478d6a42 (diff) | |
download | CMake-314613d1afd069dd896aa0d5112dfbf2b82af3c3.zip CMake-314613d1afd069dd896aa0d5112dfbf2b82af3c3.tar.gz CMake-314613d1afd069dd896aa0d5112dfbf2b82af3c3.tar.bz2 |
Add infrastructure for generators to select a build tool instance
Add cache entry `CMAKE_GENERATOR_INSTANCE` to hold the instance location
persistently across re-runs of CMake in a given build tree.
For now we reject the option by default if explicitly set. It will be
implemented on a per-generator basis. Pass the setting into try_compile
project generation. Add a RunCMake.GeneratorInstance test to cover
basic use cases for the option. Verify that `CMAKE_GENERATOR_INSTANCE`
is empty by default, and that it is rejected when the generator does not
support a user setting.
Issue: #17268
Diffstat (limited to 'Tests/RunCMake/GeneratorInstance')
12 files changed, 51 insertions, 0 deletions
diff --git a/Tests/RunCMake/GeneratorInstance/BadInstance-result.txt b/Tests/RunCMake/GeneratorInstance/BadInstance-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorInstance/BadInstance-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorInstance/BadInstance-stderr.txt b/Tests/RunCMake/GeneratorInstance/BadInstance-stderr.txt new file mode 100644 index 0000000..5d01c4f --- /dev/null +++ b/Tests/RunCMake/GeneratorInstance/BadInstance-stderr.txt @@ -0,0 +1,10 @@ +CMake Error at CMakeLists.txt:[0-9]+ \(project\): + Generator + + .* + + does not support instance specification, but instance + + Bad Instance + + was specified.$ diff --git a/Tests/RunCMake/GeneratorInstance/BadInstance-toolchain.cmake b/Tests/RunCMake/GeneratorInstance/BadInstance-toolchain.cmake new file mode 100644 index 0000000..1d99259 --- /dev/null +++ b/Tests/RunCMake/GeneratorInstance/BadInstance-toolchain.cmake @@ -0,0 +1 @@ +set(CMAKE_GENERATOR_INSTANCE "Bad Instance") diff --git a/Tests/RunCMake/GeneratorInstance/BadInstance.cmake b/Tests/RunCMake/GeneratorInstance/BadInstance.cmake new file mode 100644 index 0000000..2fc38e5 --- /dev/null +++ b/Tests/RunCMake/GeneratorInstance/BadInstance.cmake @@ -0,0 +1 @@ +message(FATAL_ERROR "This should not be reached!") diff --git a/Tests/RunCMake/GeneratorInstance/BadInstanceToolchain-result.txt b/Tests/RunCMake/GeneratorInstance/BadInstanceToolchain-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorInstance/BadInstanceToolchain-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorInstance/BadInstanceToolchain-stderr.txt b/Tests/RunCMake/GeneratorInstance/BadInstanceToolchain-stderr.txt new file mode 100644 index 0000000..5d01c4f --- /dev/null +++ b/Tests/RunCMake/GeneratorInstance/BadInstanceToolchain-stderr.txt @@ -0,0 +1,10 @@ +CMake Error at CMakeLists.txt:[0-9]+ \(project\): + Generator + + .* + + does not support instance specification, but instance + + Bad Instance + + was specified.$ diff --git a/Tests/RunCMake/GeneratorInstance/BadInstanceToolchain.cmake b/Tests/RunCMake/GeneratorInstance/BadInstanceToolchain.cmake new file mode 100644 index 0000000..2fc38e5 --- /dev/null +++ b/Tests/RunCMake/GeneratorInstance/BadInstanceToolchain.cmake @@ -0,0 +1 @@ +message(FATAL_ERROR "This should not be reached!") diff --git a/Tests/RunCMake/GeneratorInstance/CMakeLists.txt b/Tests/RunCMake/GeneratorInstance/CMakeLists.txt new file mode 100644 index 0000000..d3137f6 --- /dev/null +++ b/Tests/RunCMake/GeneratorInstance/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.9) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/GeneratorInstance/NoInstance-result.txt b/Tests/RunCMake/GeneratorInstance/NoInstance-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorInstance/NoInstance-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorInstance/NoInstance-stderr.txt b/Tests/RunCMake/GeneratorInstance/NoInstance-stderr.txt new file mode 100644 index 0000000..e7b52fd --- /dev/null +++ b/Tests/RunCMake/GeneratorInstance/NoInstance-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at NoInstance.cmake:2 \(message\): + CMAKE_GENERATOR_INSTANCE is empty as expected. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorInstance/NoInstance.cmake b/Tests/RunCMake/GeneratorInstance/NoInstance.cmake new file mode 100644 index 0000000..2e6782e --- /dev/null +++ b/Tests/RunCMake/GeneratorInstance/NoInstance.cmake @@ -0,0 +1,7 @@ +if("x${CMAKE_GENERATOR_INSTANCE}" STREQUAL "x") + message(FATAL_ERROR "CMAKE_GENERATOR_INSTANCE is empty as expected.") +else() + message(FATAL_ERROR + "CMAKE_GENERATOR_INSTANCE is \"${CMAKE_GENERATOR_INSTANCE}\" " + "but should be empty!") +endif() diff --git a/Tests/RunCMake/GeneratorInstance/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorInstance/RunCMakeTest.cmake new file mode 100644 index 0000000..f66da10 --- /dev/null +++ b/Tests/RunCMake/GeneratorInstance/RunCMakeTest.cmake @@ -0,0 +1,11 @@ +include(RunCMake) + +set(RunCMake_GENERATOR_INSTANCE "") +run_cmake(NoInstance) + +set(RunCMake_GENERATOR_INSTANCE "Bad Instance") +run_cmake(BadInstance) + +set(RunCMake_TEST_OPTIONS -DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/BadInstance-toolchain.cmake) +run_cmake(BadInstanceToolchain) +unset(RunCMake_TEST_OPTIONS) |