summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/CommandLine
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-05-22 14:30:43 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-05-22 14:32:43 (GMT)
commit8ed6efbbd377c0941ba018200282fc961aa7d20e (patch)
treecf5f8c2f55359033068eb3206b8f1887c4b43bdd /Tests/RunCMake/CommandLine
parentfc4cbbc2a5f9f7d38e77c991a88400b29c39f182 (diff)
parentd0f0ba0f7a39e70fbed197e717292b74150cf84f (diff)
downloadCMake-8ed6efbbd377c0941ba018200282fc961aa7d20e.zip
CMake-8ed6efbbd377c0941ba018200282fc961aa7d20e.tar.gz
CMake-8ed6efbbd377c0941ba018200282fc961aa7d20e.tar.bz2
Merge topic 'default-generator-env'
d0f0ba0f7a Tests: Add environment generator tests a48ce8f4bf Help: Add documentation for default generator environment variables 083cf7e8a2 cmake: Allow default generator to be set by environment variables Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3218
Diffstat (limited to 'Tests/RunCMake/CommandLine')
-rw-r--r--Tests/RunCMake/CommandLine/EnvGenerator/CMakeLists.txt10
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-A-platform-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-A-platform-stderr-vs9.txt2
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-A-platform-stderr.txt2
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-G-implicit-platform-stdout.txt1
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-T-toolset-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-T-toolset-stderr.txt2
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-bad-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-bad-stderr.txt5
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-instance-invalid-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-instance-invalid-stderr.txt2
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-ninja-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-ninja-stderr.txt4
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-platform-invalid-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-platform-invalid-stderr-vs9.txt2
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-platform-invalid-stderr.txt2
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-toolset-invalid-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-toolset-invalid-stderr.txt2
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-unset-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-unset-stderr.txt4
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-warnings-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-warnings-stderr.txt7
-rw-r--r--Tests/RunCMake/CommandLine/RunCMakeTest.cmake68
23 files changed, 122 insertions, 0 deletions
diff --git a/Tests/RunCMake/CommandLine/EnvGenerator/CMakeLists.txt b/Tests/RunCMake/CommandLine/EnvGenerator/CMakeLists.txt
new file mode 100644
index 0000000..2b8c65c
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/EnvGenerator/CMakeLists.txt
@@ -0,0 +1,10 @@
+cmake_minimum_required(VERSION 3.14)
+project(EnvGenerator C)
+if(CMAKE_GENERATOR MATCHES "Visual Studio")
+ message(STATUS "CMAKE_VS_PLATFORM_NAME='${CMAKE_VS_PLATFORM_NAME}'")
+endif()
+add_custom_command(
+ OUTPUT output.txt
+ COMMAND ${CMAKE_COMMAND} -E echo CustomCommand > output.txt
+ )
+add_custom_target(CustomTarget ALL DEPENDS output.txt)
diff --git a/Tests/RunCMake/CommandLine/Envgen-A-platform-result.txt b/Tests/RunCMake/CommandLine/Envgen-A-platform-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-A-platform-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/Envgen-A-platform-stderr-vs9.txt b/Tests/RunCMake/CommandLine/Envgen-A-platform-stderr-vs9.txt
new file mode 100644
index 0000000..4eae6aa
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-A-platform-stderr-vs9.txt
@@ -0,0 +1,2 @@
+^CMake Error at CMakeLists.+
+ No CMAKE_C_COMPILER could be found.
diff --git a/Tests/RunCMake/CommandLine/Envgen-A-platform-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-A-platform-stderr.txt
new file mode 100644
index 0000000..09c2d2b
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-A-platform-stderr.txt
@@ -0,0 +1,2 @@
+^CMake Error at CMakeLists.+
+.+Platform='fromcli'.+
diff --git a/Tests/RunCMake/CommandLine/Envgen-G-implicit-platform-stdout.txt b/Tests/RunCMake/CommandLine/Envgen-G-implicit-platform-stdout.txt
new file mode 100644
index 0000000..4dd6be1
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-G-implicit-platform-stdout.txt
@@ -0,0 +1 @@
+-- CMAKE_VS_PLATFORM_NAME='(x64|Win32)'
diff --git a/Tests/RunCMake/CommandLine/Envgen-T-toolset-result.txt b/Tests/RunCMake/CommandLine/Envgen-T-toolset-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-T-toolset-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/Envgen-T-toolset-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-T-toolset-stderr.txt
new file mode 100644
index 0000000..b432c19
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-T-toolset-stderr.txt
@@ -0,0 +1,2 @@
+^CMake Error at CMakeLists.+
+.+(Platform Toolset = 'fromcli'|Specified platform toolset \(fromcli\) is not installed or invalid).+
diff --git a/Tests/RunCMake/CommandLine/Envgen-bad-result.txt b/Tests/RunCMake/CommandLine/Envgen-bad-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-bad-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/Envgen-bad-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-bad-stderr.txt
new file mode 100644
index 0000000..4a1215e
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-bad-stderr.txt
@@ -0,0 +1,5 @@
+^CMake Error: No generator specified for -G
+CMake Error: CMAKE_GENERATOR was set but the specified generator doesn't exist. Using CMake default.
+
+Generators.*
+\* (Unix Makefiles|Visual Studio).*
diff --git a/Tests/RunCMake/CommandLine/Envgen-instance-invalid-result.txt b/Tests/RunCMake/CommandLine/Envgen-instance-invalid-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-instance-invalid-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/Envgen-instance-invalid-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-instance-invalid-stderr.txt
new file mode 100644
index 0000000..d53daa5
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-instance-invalid-stderr.txt
@@ -0,0 +1,2 @@
+^CMake Error at CMakeLists.+
+ could not find specified instance of Visual Studio.+
diff --git a/Tests/RunCMake/CommandLine/Envgen-ninja-result.txt b/Tests/RunCMake/CommandLine/Envgen-ninja-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-ninja-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/Envgen-ninja-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-ninja-stderr.txt
new file mode 100644
index 0000000..0d455db
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-ninja-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error: No generator specified for -G
+
+Generators.*
+\* Ninja.*
diff --git a/Tests/RunCMake/CommandLine/Envgen-platform-invalid-result.txt b/Tests/RunCMake/CommandLine/Envgen-platform-invalid-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-platform-invalid-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/Envgen-platform-invalid-stderr-vs9.txt b/Tests/RunCMake/CommandLine/Envgen-platform-invalid-stderr-vs9.txt
new file mode 100644
index 0000000..4eae6aa
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-platform-invalid-stderr-vs9.txt
@@ -0,0 +1,2 @@
+^CMake Error at CMakeLists.+
+ No CMAKE_C_COMPILER could be found.
diff --git a/Tests/RunCMake/CommandLine/Envgen-platform-invalid-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-platform-invalid-stderr.txt
new file mode 100644
index 0000000..76a8f1c
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-platform-invalid-stderr.txt
@@ -0,0 +1,2 @@
+^CMake Error at CMakeLists.+
+.+Platform='invalid'.+
diff --git a/Tests/RunCMake/CommandLine/Envgen-toolset-invalid-result.txt b/Tests/RunCMake/CommandLine/Envgen-toolset-invalid-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-toolset-invalid-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/Envgen-toolset-invalid-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-toolset-invalid-stderr.txt
new file mode 100644
index 0000000..51fce60
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-toolset-invalid-stderr.txt
@@ -0,0 +1,2 @@
+^CMake Error at CMakeLists.+
+.+(Platform Toolset = 'invalid'|Specified platform toolset \(invalid\) is not installed or invalid).+
diff --git a/Tests/RunCMake/CommandLine/Envgen-unset-result.txt b/Tests/RunCMake/CommandLine/Envgen-unset-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-unset-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/Envgen-unset-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-unset-stderr.txt
new file mode 100644
index 0000000..ec6ec92
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-unset-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error: No generator specified for -G
+
+Generators.*
+\* (Unix Makefiles|Visual Studio).*
diff --git a/Tests/RunCMake/CommandLine/Envgen-warnings-result.txt b/Tests/RunCMake/CommandLine/Envgen-warnings-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-warnings-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/Envgen-warnings-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-warnings-stderr.txt
new file mode 100644
index 0000000..47f9c9e
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-warnings-stderr.txt
@@ -0,0 +1,7 @@
+^Warning: Environment variable CMAKE_GENERATOR_INSTANCE will be ignored, because CMAKE_GENERATOR is not set.
+Warning: Environment variable CMAKE_GENERATOR_PLATFORM will be ignored, because CMAKE_GENERATOR is not set.
+Warning: Environment variable CMAKE_GENERATOR_TOOLSET will be ignored, because CMAKE_GENERATOR is not set.
+CMake Error: No generator specified for -G
+
+Generators.*
+\* (Unix Makefiles|Visual Studio).*
diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
index b9aa536..cee996c 100644
--- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
@@ -172,6 +172,74 @@ function(run_BuildDir)
endfunction()
run_BuildDir()
+function(run_EnvironmentGenerator)
+ set(source_dir ${RunCMake_SOURCE_DIR}/EnvGenerator)
+
+ set(ENV{CMAKE_GENERATOR_INSTANCE} "instance")
+ set(ENV{CMAKE_GENERATOR_PLATFORM} "platform")
+ set(ENV{CMAKE_GENERATOR_TOOLSET} "toolset")
+ run_cmake_command(Envgen-warnings ${CMAKE_COMMAND} -G)
+ unset(ENV{CMAKE_GENERATOR_INSTANCE})
+ unset(ENV{CMAKE_GENERATOR_PLATFORM})
+ unset(ENV{CMAKE_GENERATOR_TOOLSET})
+
+ # Test CMAKE_GENERATOR without actual configuring
+ run_cmake_command(Envgen-unset ${CMAKE_COMMAND} -G)
+ set(ENV{CMAKE_GENERATOR} "Ninja")
+ run_cmake_command(Envgen-ninja ${CMAKE_COMMAND} -G)
+ set(ENV{CMAKE_GENERATOR} "NoSuchGenerator")
+ run_cmake_command(Envgen-bad ${CMAKE_COMMAND} -G)
+ unset(ENV{CMAKE_GENERATOR})
+
+ if(RunCMake_GENERATOR MATCHES "Visual Studio.*")
+ set(ENV{CMAKE_GENERATOR} "${RunCMake_GENERATOR}")
+ run_cmake_command(Envgen ${CMAKE_COMMAND} ${source_dir})
+ # Toolset is available since VS 2010.
+ if(RunCMake_GENERATOR MATCHES "Visual Studio [1-9][0-9]")
+ set(ENV{CMAKE_GENERATOR_TOOLSET} "invalid")
+ # Envvar shouldn't affect existing build tree
+ run_cmake_command(Envgen-toolset-existing ${CMAKE_COMMAND} -E chdir ..
+ ${CMAKE_COMMAND} --build Envgen-build)
+ run_cmake_command(Envgen-toolset-invalid ${CMAKE_COMMAND} ${source_dir})
+ # Command line -G implies -T""
+ run_cmake_command(Envgen-G-implicit-toolset ${CMAKE_COMMAND} -G "${RunCMake_GENERATOR}" ${source_dir})
+ run_cmake_command(Envgen-T-toolset ${CMAKE_COMMAND} -T "fromcli" ${source_dir})
+ unset(ENV{CMAKE_GENERATOR_TOOLSET})
+ endif()
+ # Platform can be set only if not in generator name.
+ if(RunCMake_GENERATOR MATCHES "^Visual Studio [0-9]+ [0-9]+$")
+ set(ENV{CMAKE_GENERATOR_PLATFORM} "invalid")
+ # Envvar shouldn't affect existing build tree
+ run_cmake_command(Envgen-platform-existing ${CMAKE_COMMAND} -E chdir ..
+ ${CMAKE_COMMAND} --build Envgen-build)
+ if(RunCMake_GENERATOR MATCHES "^Visual Studio 9 ")
+ set(RunCMake-stderr-file "Envgen-platform-invalid-stderr-vs9.txt")
+ endif()
+ run_cmake_command(Envgen-platform-invalid ${CMAKE_COMMAND} ${source_dir})
+ unset(RunCMake-stderr-file)
+ # Command line -G implies -A""
+ run_cmake_command(Envgen-G-implicit-platform ${CMAKE_COMMAND} -G "${RunCMake_GENERATOR}" ${source_dir})
+ if(RunCMake_GENERATOR MATCHES "^Visual Studio 9 ")
+ set(RunCMake-stderr-file "Envgen-A-platform-stderr-vs9.txt")
+ endif()
+ run_cmake_command(Envgen-A-platform ${CMAKE_COMMAND} -A "fromcli" ${source_dir})
+ unset(RunCMake-stderr-file)
+ unset(ENV{CMAKE_GENERATOR_PLATFORM})
+ endif()
+ # Instance is available since VS 2017.
+ if(RunCMake_GENERATOR MATCHES "Visual Studio (15|16).*")
+ set(ENV{CMAKE_GENERATOR_INSTANCE} "invalid")
+ # Envvar shouldn't affect existing build tree
+ run_cmake_command(Envgen-instance-existing ${CMAKE_COMMAND} -E chdir ..
+ ${CMAKE_COMMAND} --build Envgen-build)
+ run_cmake_command(Envgen-instance-invalid ${CMAKE_COMMAND} ${source_dir})
+ unset(ENV{CMAKE_GENERATOR_INSTANCE})
+ endif()
+ unset(ENV{CMAKE_GENERATOR})
+ endif()
+endfunction()
+run_EnvironmentGenerator()
+
if(RunCMake_GENERATOR STREQUAL "Ninja")
# Use a single build tree for a few tests without cleaning.
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Build-build)