diff options
author | Kai Wang <wangkai86@huawei.com> | 2020-12-18 06:47:37 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-01-05 12:48:27 (GMT) |
commit | b696f7807303b421c3f59ff2bf8229c96f09f1fa (patch) | |
tree | 246f99b964b4cf5b43178adde879025dc01c4c37 /Tests | |
parent | da2474626b8a02e957021b30453f5afc8d7246b9 (diff) | |
download | CMake-b696f7807303b421c3f59ff2bf8229c96f09f1fa.zip CMake-b696f7807303b421c3f59ff2bf8229c96f09f1fa.tar.gz CMake-b696f7807303b421c3f59ff2bf8229c96f09f1fa.tar.bz2 |
cmDepends: merge dependers of depend makefile
Since one depender has multiple dependees, depend makefile generated
same depender line by line, to reduce file size and refine make file
parse speed, merge same dependers to one. And add a testcase for
large depend.make which generated source file includes 20000 header
files and run build and incremental build
Signed-off-by: Wangkai <wangkai86@huawei.com>
Signed-off-by: Zhaoyingdong <zhaoyingdong@huawei.com>
Diffstat (limited to 'Tests')
6 files changed, 48 insertions, 3 deletions
diff --git a/Tests/IncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/CMakeLists.txt index d4c19c7..d980a52 100644 --- a/Tests/IncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/CMakeLists.txt @@ -67,7 +67,13 @@ else() endif() # Test escaping of special characters in include directory paths. -set(special_chars "~@&{}()!'") +set(special_chars "~@&{}()'") +if(NOT (CMAKE_GENERATOR STREQUAL "NMake Makefiles" AND + "x${CMAKE_C_COMPILER_ID}" STREQUAL "xMSVC" AND + "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS 13.0)) + # NMake from VS 6 mistakes '!' in a path after a line continuation for a directive. + string(APPEND special_chars "!") +endif() if(NOT CMAKE_GENERATOR MATCHES "(Unix|MinGW|MSYS) Makefiles") # when compiler is used for dependencies, special characters for make are not escaped string(APPEND special_chars "%") diff --git a/Tests/RunCMake/BuildDepends/MakeDependencies.cmake b/Tests/RunCMake/BuildDepends/MakeDependencies.cmake new file mode 100644 index 0000000..33e8c7e --- /dev/null +++ b/Tests/RunCMake/BuildDepends/MakeDependencies.cmake @@ -0,0 +1,13 @@ +enable_language(C) + +add_executable(main ${CMAKE_CURRENT_BINARY_DIR}/main.c) + +file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT " +set(check_pairs + \"$<TARGET_FILE:main>|${CMAKE_CURRENT_BINARY_DIR}/main.c\" + \"$<TARGET_FILE:main>|${CMAKE_CURRENT_BINARY_DIR}/main.h\" + ) +set(check_exes + \"$<TARGET_FILE:main>\" + ) +") diff --git a/Tests/RunCMake/BuildDepends/MakeDependencies.step1.cmake b/Tests/RunCMake/BuildDepends/MakeDependencies.step1.cmake new file mode 100644 index 0000000..c74f033 --- /dev/null +++ b/Tests/RunCMake/BuildDepends/MakeDependencies.step1.cmake @@ -0,0 +1,18 @@ +file(TOUCH "${RunCMake_TEST_BINARY_DIR}/main.c") +foreach(i RANGE 1 20000) + file(WRITE "${RunCMake_TEST_BINARY_DIR}/temp_header_file_${i}.h" + "#define HEADER_${i} ${i}\n" + ) + file(APPEND "${RunCMake_TEST_BINARY_DIR}/main.c" + "#include \"temp_header_file_${i}.h\"\n" + ) +endforeach() +file(APPEND "${RunCMake_TEST_BINARY_DIR}/main.c" + "#include \"main.h\"\n" + ) +file(APPEND "${RunCMake_TEST_BINARY_DIR}/main.c" + "int main(void) { return COUNT; }\n" + ) +file(WRITE "${RunCMake_TEST_BINARY_DIR}/main.h" + "#define COUNT 1\n" + ) diff --git a/Tests/RunCMake/BuildDepends/MakeDependencies.step2.cmake b/Tests/RunCMake/BuildDepends/MakeDependencies.step2.cmake new file mode 100644 index 0000000..c826d3c --- /dev/null +++ b/Tests/RunCMake/BuildDepends/MakeDependencies.step2.cmake @@ -0,0 +1,3 @@ +file(WRITE "${RunCMake_TEST_BINARY_DIR}/main.h" + "#define COUNT 2\n" + ) diff --git a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake index 1b7b8d9..67da6ae 100644 --- a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake +++ b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake @@ -143,3 +143,7 @@ if(RunCMake_GENERATOR MATCHES "Make|Ninja") run_BuildDepends(CustomCommandDepfile) set(run_BuildDepends_skip_step_3 1) endif() + +if(RunCMake_GENERATOR MATCHES "Make") + run_BuildDepends(MakeDependencies) +endif() diff --git a/Tests/RunCMake/CommandLine/cmake_depends-check.cmake b/Tests/RunCMake/CommandLine/cmake_depends-check.cmake index 031478b..e0e3054 100644 --- a/Tests/RunCMake/CommandLine/cmake_depends-check.cmake +++ b/Tests/RunCMake/CommandLine/cmake_depends-check.cmake @@ -3,8 +3,9 @@ if(EXISTS "${depend_make}") file(READ "${depend_make}" depend_make_content) string(REGEX REPLACE "\n+$" "" depend_make_content "${depend_make_content}") if(NOT depend_make_content MATCHES " -CMakeFiles/DepTarget.dir/test.c.o: .*/Tests/RunCMake/CommandLine/cmake_depends/test.c -CMakeFiles/DepTarget.dir/test.c.o: .*/Tests/RunCMake/CommandLine/cmake_depends/test.h$") +CMakeFiles/DepTarget.dir/test.c.o: \\\\ + .*/Tests/RunCMake/CommandLine/cmake_depends/test.c \\\\ + .*/Tests/RunCMake/CommandLine/cmake_depends/test.h$") string(REPLACE "\n" "\n " depend_make_content " ${depend_make_content}") set(RunCMake_TEST_FAILED "depend.make does not have expected content:\n${depend_make_content}") endif() |