diff options
author | Brad King <brad.king@kitware.com> | 2019-07-25 11:15:42 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-07-25 11:15:42 (GMT) |
commit | 070a5e3835b11f76cc8ed8c4a2191295caf8069b (patch) | |
tree | f23ed04329300fbe5eccb84b9e2bde9d164a3c73 /Tests | |
parent | 420073e53622bd344c9525bce4778ed6aed6276d (diff) | |
parent | d46bac5d38320907cc1f11a223fddd9a11c9b184 (diff) | |
download | CMake-070a5e3835b11f76cc8ed8c4a2191295caf8069b.zip CMake-070a5e3835b11f76cc8ed8c4a2191295caf8069b.tar.gz CMake-070a5e3835b11f76cc8ed8c4a2191295caf8069b.tar.bz2 |
Merge branch 'makefile-depend-relative-include' into release-3.15
Merge-request: !3599
Diffstat (limited to 'Tests')
5 files changed, 35 insertions, 1 deletions
diff --git a/Tests/RunCMake/BuildDepends/BuildUnderSource.c b/Tests/RunCMake/BuildDepends/BuildUnderSource.c new file mode 100644 index 0000000..688a040 --- /dev/null +++ b/Tests/RunCMake/BuildDepends/BuildUnderSource.c @@ -0,0 +1,5 @@ +#include "BuildUnderSource.h" +int main(void) +{ + return BUILD_UNDER_SOURCE; +} diff --git a/Tests/RunCMake/BuildDepends/BuildUnderSource.cmake b/Tests/RunCMake/BuildDepends/BuildUnderSource.cmake new file mode 100644 index 0000000..aa2a44f --- /dev/null +++ b/Tests/RunCMake/BuildDepends/BuildUnderSource.cmake @@ -0,0 +1,9 @@ +enable_language(C) +include_directories(include) +add_executable(BuildUnderSource BuildUnderSource.c) + +file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT " +set(check_pairs + \"$<TARGET_FILE:BuildUnderSource>|${CMAKE_CURRENT_SOURCE_DIR}/include/BuildUnderSource.h\" + ) +") diff --git a/Tests/RunCMake/BuildDepends/BuildUnderSource.step1.cmake b/Tests/RunCMake/BuildDepends/BuildUnderSource.step1.cmake new file mode 100644 index 0000000..2cdd32b --- /dev/null +++ b/Tests/RunCMake/BuildDepends/BuildUnderSource.step1.cmake @@ -0,0 +1,3 @@ +file(WRITE "${RunCMake_TEST_SOURCE_DIR}/include/BuildUnderSource.h" [[ +#define BUILD_UNDER_SOURCE 1 +]]) diff --git a/Tests/RunCMake/BuildDepends/BuildUnderSource.step2.cmake b/Tests/RunCMake/BuildDepends/BuildUnderSource.step2.cmake new file mode 100644 index 0000000..8e4b858 --- /dev/null +++ b/Tests/RunCMake/BuildDepends/BuildUnderSource.step2.cmake @@ -0,0 +1,3 @@ +file(WRITE "${RunCMake_TEST_SOURCE_DIR}/include/BuildUnderSource.h" [[ +#define BUILD_UNDER_SOURCE 2 +]]) diff --git a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake index 3445beb..14ae243 100644 --- a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake +++ b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake @@ -9,7 +9,9 @@ endif() function(run_BuildDepends CASE) # Use a single build tree for a few tests without cleaning. - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${CASE}-build) + if(NOT RunCMake_TEST_BINARY_DIR) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${CASE}-build) + endif() set(RunCMake_TEST_NO_CLEAN 1) if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug) @@ -44,6 +46,18 @@ endif() run_BuildDepends(Custom-Symbolic-and-Byproduct) run_BuildDepends(Custom-Always) +# Test header dependencies with a build tree underneath a source tree. +set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/BuildUnderSource") +set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/BuildUnderSource/build") +file(REMOVE_RECURSE "${RunCMake_TEST_SOURCE_DIR}") +file(MAKE_DIRECTORY "${RunCMake_TEST_SOURCE_DIR}/include") +foreach(f CMakeLists.txt BuildUnderSource.cmake BuildUnderSource.c) + configure_file("${RunCMake_SOURCE_DIR}/${f}" "${RunCMake_TEST_SOURCE_DIR}/${f}" COPYONLY) +endforeach() +run_BuildDepends(BuildUnderSource) +unset(RunCMake_TEST_BINARY_DIR) +unset(RunCMake_TEST_SOURCE_DIR) + if(RunCMake_GENERATOR MATCHES "Make") run_BuildDepends(MakeCustomIncludes) if(NOT "${RunCMake_BINARY_DIR}" STREQUAL "${RunCMake_SOURCE_DIR}") |