From 538721939faef01b00ffd20416e8f7146d7368ac Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 10 Apr 2019 09:29:30 -0400 Subject: Tests: Teach RunCMake to optionally exclude the source dir argument --- Tests/RunCMake/RunCMake.cmake | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index ce71677..5d49909 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -98,8 +98,14 @@ function(run_cmake test) else() set(_D_CMAKE_GENERATOR_INSTANCE "") endif() + if(NOT RunCMake_TEST_NO_SOURCE_DIR) + set(maybe_source_dir "${RunCMake_TEST_SOURCE_DIR}") + else() + set(maybe_source_dir "") + endif() execute_process( - COMMAND ${CMAKE_COMMAND} "${RunCMake_TEST_SOURCE_DIR}" + COMMAND ${CMAKE_COMMAND} + ${maybe_source_dir} -G "${RunCMake_GENERATOR}" -A "${RunCMake_GENERATOR_PLATFORM}" -T "${RunCMake_GENERATOR_TOOLSET}" -- cgit v0.12 From 44d6370db35c82d182bfc9480f0f0031b6b559ed Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 10 Apr 2019 09:30:46 -0400 Subject: Tests: Add RunCMake helper to run cmake with options --- Tests/RunCMake/RunCMake.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index 5d49909..ad3f8f6 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -188,5 +188,10 @@ function(run_cmake_command test) run_cmake(${test}) endfunction() +function(run_cmake_with_options test) + set(RunCMake_TEST_OPTIONS "${ARGN}") + run_cmake(${test}) +endfunction() + # Protect RunCMake tests from calling environment. unset(ENV{MAKEFLAGS}) -- cgit v0.12 From baed22c4b000d524f4890af86cf3c02dc885cba6 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 10 Apr 2019 09:31:38 -0400 Subject: Tests: Fix RunCMake.CommandLine test to use generator with -S and -B The `-S` and `-B` command-line option tests do generate build systems and so should use the generator being tested. --- Tests/RunCMake/CommandLine/RunCMakeTest.cmake | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index 3deabd0..ea749ea 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -82,23 +82,27 @@ project(ExplicitDirsMissing LANGUAGES NONE) set(source_dir ${RunCMake_SOURCE_DIR}/ExplicitDirs) set(binary_dir ${RunCMake_BINARY_DIR}/ExplicitDirs-build) + set(RunCMake_TEST_SOURCE_DIR "${source_dir}") + set(RunCMake_TEST_BINARY_DIR "${binary_dir}") + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_NO_SOURCE_DIR 1) + file(REMOVE_RECURSE "${binary_dir}") - file(MAKE_DIRECTORY "${binary_dir}") - run_cmake_command(S-arg ${CMAKE_COMMAND} -S ${source_dir} ${binary_dir}) - run_cmake_command(S-arg-reverse-order ${CMAKE_COMMAND} ${binary_dir} -S${source_dir} ) - run_cmake_command(S-no-arg ${CMAKE_COMMAND} -S ) - run_cmake_command(S-no-arg2 ${CMAKE_COMMAND} -S -T) - run_cmake_command(S-B ${CMAKE_COMMAND} -S ${source_dir} -B ${binary_dir}) + run_cmake_with_options(S-arg -S ${source_dir} ${binary_dir}) + run_cmake_with_options(S-arg-reverse-order ${binary_dir} -S${source_dir} ) + run_cmake_with_options(S-no-arg -S ) + run_cmake_with_options(S-no-arg2 -S -T) + run_cmake_with_options(S-B -S ${source_dir} -B ${binary_dir}) # make sure that -B can explicitly construct build directories file(REMOVE_RECURSE "${binary_dir}") - run_cmake_command(B-arg ${CMAKE_COMMAND} -B ${binary_dir} ${source_dir}) + run_cmake_with_options(B-arg -B ${binary_dir} ${source_dir}) file(REMOVE_RECURSE "${binary_dir}") - run_cmake_command(B-arg-reverse-order ${CMAKE_COMMAND} ${source_dir} -B${binary_dir}) - run_cmake_command(B-no-arg ${CMAKE_COMMAND} -B ) - run_cmake_command(B-no-arg2 ${CMAKE_COMMAND} -B -T) + run_cmake_with_options(B-arg-reverse-order ${source_dir} -B${binary_dir}) + run_cmake_with_options(B-no-arg -B ) + run_cmake_with_options(B-no-arg2 -B -T) file(REMOVE_RECURSE "${binary_dir}") - run_cmake_command(B-S ${CMAKE_COMMAND} -B${binary_dir} -S${source_dir}) + run_cmake_with_options(B-S -B${binary_dir} -S${source_dir}) endfunction() run_ExplicitDirs() -- cgit v0.12 From 39e7fd8c68a1f039f089756352a418bd0ae36aea Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 10 Apr 2019 09:33:02 -0400 Subject: Tests: Avoid enabling languages in RunCMake.CommandLine -S and -B cases The test project does not compile any sources and so does not need to enable any languages. --- Tests/RunCMake/CommandLine/ExplicitDirs/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Tests/RunCMake/CommandLine/ExplicitDirs/CMakeLists.txt b/Tests/RunCMake/CommandLine/ExplicitDirs/CMakeLists.txt index 0ca5a0a..fc62914 100644 --- a/Tests/RunCMake/CommandLine/ExplicitDirs/CMakeLists.txt +++ b/Tests/RunCMake/CommandLine/ExplicitDirs/CMakeLists.txt @@ -1,4 +1,5 @@ -cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR) +cmake_minimum_required(VERSION 3.14) +project(ExplicitDirs NONE) add_custom_command( OUTPUT output.txt COMMAND ${CMAKE_COMMAND} -E echo CustomCommand > output.txt -- cgit v0.12