diff options
author | Brad King <brad.king@kitware.com> | 2019-04-11 14:12:08 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-04-11 14:12:32 (GMT) |
commit | 5ae15061c36f45551d0308a5ff916067970705ff (patch) | |
tree | 57e853dde06f5891c3209692300ff3167dfa8dca /Tests | |
parent | be101e909e42c4a22c180d29ee217d5b8c4508d1 (diff) | |
parent | 39e7fd8c68a1f039f089756352a418bd0ae36aea (diff) | |
download | CMake-5ae15061c36f45551d0308a5ff916067970705ff.zip CMake-5ae15061c36f45551d0308a5ff916067970705ff.tar.gz CMake-5ae15061c36f45551d0308a5ff916067970705ff.tar.bz2 |
Merge topic 'test-explicit-dirs'
39e7fd8c68 Tests: Avoid enabling languages in RunCMake.CommandLine -S and -B cases
baed22c4b0 Tests: Fix RunCMake.CommandLine test to use generator with -S and -B
44d6370db3 Tests: Add RunCMake helper to run cmake with options
538721939f Tests: Teach RunCMake to optionally exclude the source dir argument
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3209
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/RunCMake/CommandLine/ExplicitDirs/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Tests/RunCMake/CommandLine/RunCMakeTest.cmake | 26 | ||||
-rw-r--r-- | Tests/RunCMake/RunCMake.cmake | 13 |
3 files changed, 29 insertions, 13 deletions
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 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() diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index ce71677..ad3f8f6 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}" @@ -182,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}) |