Tests: Add test for CMAKE_DEPENDS_IN_PROJECT_ONLY variable

This commit is contained in:
Brad King 2016-03-22 16:03:28 -04:00
parent b1e1aa1e6a
commit 525402450a
5 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,2 @@
#include <MakeInProjectOnly.h>
int main() { return MakeInProjectOnly(); }

View File

@ -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-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT "
if (check_step EQUAL 1)
set(check_pairs
\"$<TARGET_FILE:MakeInProjectOnly>|${include_dir}/MakeInProjectOnly.h\"
)
else()
set(check_pairs
\"${include_dir}/MakeInProjectOnly.h|\$<TARGET_FILE:MakeInProjectOnly>\"
)
endif()
")

View File

@ -0,0 +1,3 @@
file(WRITE "${RunCMake_TEST_BINARY_DIR}/../MakeInProjectOnly.h" [[
int MakeInProjectOnly(void) { return 0; }
]])

View File

@ -0,0 +1,3 @@
file(WRITE "${RunCMake_TEST_BINARY_DIR}/../MakeInProjectOnly.h" [[
int MakeInProjectOnly(void) { return 1; }
]])

View File

@ -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