From 525402450a1ccde0e9187c9613752f728a96149b Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 22 Mar 2016 16:03:28 -0400 Subject: [PATCH] Tests: Add test for CMAKE_DEPENDS_IN_PROJECT_ONLY variable --- Tests/RunCMake/BuildDepends/MakeInProjectOnly.c | 2 ++ .../BuildDepends/MakeInProjectOnly.cmake | 16 ++++++++++++++++ .../BuildDepends/MakeInProjectOnly.step1.cmake | 3 +++ .../BuildDepends/MakeInProjectOnly.step2.cmake | 3 +++ Tests/RunCMake/BuildDepends/RunCMakeTest.cmake | 5 +++++ 5 files changed, 29 insertions(+) create mode 100644 Tests/RunCMake/BuildDepends/MakeInProjectOnly.c create mode 100644 Tests/RunCMake/BuildDepends/MakeInProjectOnly.cmake create mode 100644 Tests/RunCMake/BuildDepends/MakeInProjectOnly.step1.cmake create mode 100644 Tests/RunCMake/BuildDepends/MakeInProjectOnly.step2.cmake diff --git a/Tests/RunCMake/BuildDepends/MakeInProjectOnly.c b/Tests/RunCMake/BuildDepends/MakeInProjectOnly.c new file mode 100644 index 000000000..bcb8745bf --- /dev/null +++ b/Tests/RunCMake/BuildDepends/MakeInProjectOnly.c @@ -0,0 +1,2 @@ +#include +int main() { return MakeInProjectOnly(); } diff --git a/Tests/RunCMake/BuildDepends/MakeInProjectOnly.cmake b/Tests/RunCMake/BuildDepends/MakeInProjectOnly.cmake new file mode 100644 index 000000000..add9aeb69 --- /dev/null +++ b/Tests/RunCMake/BuildDepends/MakeInProjectOnly.cmake @@ -0,0 +1,16 @@ +enable_language(C) +get_filename_component(include_dir "${CMAKE_BINARY_DIR}" PATH) +include_directories("${include_dir}") +add_executable(MakeInProjectOnly MakeInProjectOnly.c) +set(CMAKE_DEPENDS_IN_PROJECT_ONLY 1) +file(GENERATE OUTPUT check-$>.cmake CONTENT " +if (check_step EQUAL 1) + set(check_pairs + \"$|${include_dir}/MakeInProjectOnly.h\" + ) +else() + set(check_pairs + \"${include_dir}/MakeInProjectOnly.h|\$\" + ) +endif() +") diff --git a/Tests/RunCMake/BuildDepends/MakeInProjectOnly.step1.cmake b/Tests/RunCMake/BuildDepends/MakeInProjectOnly.step1.cmake new file mode 100644 index 000000000..d6551abe0 --- /dev/null +++ b/Tests/RunCMake/BuildDepends/MakeInProjectOnly.step1.cmake @@ -0,0 +1,3 @@ +file(WRITE "${RunCMake_TEST_BINARY_DIR}/../MakeInProjectOnly.h" [[ +int MakeInProjectOnly(void) { return 0; } +]]) diff --git a/Tests/RunCMake/BuildDepends/MakeInProjectOnly.step2.cmake b/Tests/RunCMake/BuildDepends/MakeInProjectOnly.step2.cmake new file mode 100644 index 000000000..145605be7 --- /dev/null +++ b/Tests/RunCMake/BuildDepends/MakeInProjectOnly.step2.cmake @@ -0,0 +1,3 @@ +file(WRITE "${RunCMake_TEST_BINARY_DIR}/../MakeInProjectOnly.h" [[ +int MakeInProjectOnly(void) { return 1; } +]]) diff --git a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake index 26ffcc0e8..6b2b85a2b 100644 --- a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake +++ b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake @@ -41,6 +41,11 @@ endif() run_BuildDepends(Custom-Always) +if(RunCMake_GENERATOR MATCHES "Make" AND + NOT "${RunCMake_BINARY_DIR}" STREQUAL "${RunCMake_SOURCE_DIR}") + run_BuildDepends(MakeInProjectOnly) +endif() + function(run_ReGeneration) # test re-generation of project even if CMakeLists.txt files disappeared