diff options
author | Brad King <brad.king@kitware.com> | 2019-08-29 13:37:26 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-08-29 13:38:21 (GMT) |
commit | fa36e2151d25358c7946a53c4440f0487210770d (patch) | |
tree | 8909e40db9d7a8c54ea047d5ea6d92f2592a3264 /Tests/RunCMake/VS10Project | |
parent | 030570d71ff8b15a7242203f2638d3b77af755b9 (diff) | |
parent | 8da78d4efe0e4d0ef8708ecd94cf886c3f7d9ae4 (diff) | |
download | CMake-fa36e2151d25358c7946a53c4440f0487210770d.zip CMake-fa36e2151d25358c7946a53c4440f0487210770d.tar.gz CMake-fa36e2151d25358c7946a53c4440f0487210770d.tar.bz2 |
Merge topic 'precompile-headers'
8da78d4efe Precompile headers: Update documentation
5772930164 Precompile headers: Add unit tests
519606704e Precompile headers: Add support for Visual Studio generators
28be170fbc Precompile headers: Add support for Xcode generator
b8626261e9 Precompile headers: Add methods to generate PCH sources
375d01c680 PCH: add example/test
9b6797e71d PCH: add target_precompile_headers command
0467a2f91b PCH: add PRECOMPILE_HEADERS to special properties
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Daniel Pfeifer <daniel@pfeifer-mail.de>
Acked-by: Ivan171 <heavenandhell171@gmail.com>
Acked-by: Stanislav Ershov <digital.stream.of.mind@gmail.com>
Acked-by: Steve Mokris <smokris@softpixel.com>
Acked-by: Evgeniy Dushistov <dushistov@mail.ru>
Acked-by: Danila Malyutin <flashmozzg@gmail.com>
Acked-by: Viktor Kirilov <vik.kirilov@gmail.com>
Acked-by: Lucas Zhao <zhaopf6@163.com>
Merge-request: !3553
Diffstat (limited to 'Tests/RunCMake/VS10Project')
-rw-r--r-- | Tests/RunCMake/VS10Project/RunCMakeTest.cmake | 1 | ||||
-rw-r--r-- | Tests/RunCMake/VS10Project/VsPrecompileHeaders-check.cmake | 69 | ||||
-rw-r--r-- | Tests/RunCMake/VS10Project/VsPrecompileHeaders.cmake | 4 |
3 files changed, 74 insertions, 0 deletions
diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake index 5ca069a..72154e7 100644 --- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake +++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake @@ -25,6 +25,7 @@ run_cmake(VsProjectImport) run_cmake(VsPackageReferences) run_cmake(VsDpiAware) run_cmake(VsDpiAwareBadParam) +run_cmake(VsPrecompileHeaders) if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.05) run_cmake(VsJustMyCode) diff --git a/Tests/RunCMake/VS10Project/VsPrecompileHeaders-check.cmake b/Tests/RunCMake/VS10Project/VsPrecompileHeaders-check.cmake new file mode 100644 index 0000000..82ca421 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsPrecompileHeaders-check.cmake @@ -0,0 +1,69 @@ +set(pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/cmake_pch.hxx") +set(pch_source "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/cmake_pch.cxx") + +file(TO_NATIVE_PATH "${pch_source}" pch_source_win) + +if(NOT EXISTS "${pch_header}") + set(RunCMake_TEST_FAILED "Generated PCH header ${pch_header} does not exist.") + return() +endif() +if(NOT EXISTS "${pch_source}") + set(RunCMake_TEST_FAILED "Generated PCH header ${pch_source} does not exist.") + return() +endif() + +set(tgt_project "${RunCMake_TEST_BINARY_DIR}/tgt.vcxproj") +if (NOT EXISTS "${tgt_project}") + set(RunCMake_TEST_FAILED "Generated project file ${tgt_project} doesn't exist.") + return() +endif() + +file(STRINGS ${tgt_project} tgt_projects_strings) + +foreach(line IN LISTS tgt_projects_strings) + if (line MATCHES "<PrecompiledHeader.*>Use</PrecompiledHeader>") + set(have_pch_use ON) + endif() + + if (line MATCHES "<PrecompiledHeader.*>Create</PrecompiledHeader>") + set(have_pch_create ON) + endif() + + if (line MATCHES "<PrecompiledHeaderFile.*>${pch_header}</PrecompiledHeaderFile>") + set(have_pch_header ON) + endif() + + if (line MATCHES "<ForcedIncludeFiles.*>${pch_header}</ForcedIncludeFiles>") + set(have_force_pch_header ON) + endif() + + string(FIND "${line}" "<ClCompile Include=\"${pch_source_win}\">" find_pos) + if (NOT find_pos EQUAL "-1") + set(have_pch_source_compile ON) + endif() +endforeach() + +if (NOT have_pch_use) + set(RunCMake_TEST_FAILED "Generated project should have the <PrecompiledHeader>Use</PrecompiledHeader> block.") + return() +endif() + +if (NOT have_pch_create) + set(RunCMake_TEST_FAILED "Generated project should have the <PrecompiledHeader>Create</PrecompiledHeader> block.") + return() +endif() + +if (NOT have_pch_header) + set(RunCMake_TEST_FAILED "Generated project should have the <PrecompiledHeaderFile>${pch_header}</PrecompiledHeaderFile> block.") + return() +endif() + +if (NOT have_force_pch_header) + set(RunCMake_TEST_FAILED "Generated project should have the <ForcedIncludeFiles>${pch_header}</ForcedIncludeFiles> block.") + return() +endif() + +if (NOT have_pch_source_compile) + set(RunCMake_TEST_FAILED "Generated project should have the <ClCompile Include=\"${pch_source_win}\"> block.") + return() +endif() diff --git a/Tests/RunCMake/VS10Project/VsPrecompileHeaders.cmake b/Tests/RunCMake/VS10Project/VsPrecompileHeaders.cmake new file mode 100644 index 0000000..6d208c9 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsPrecompileHeaders.cmake @@ -0,0 +1,4 @@ +project(VsPrecompileHeaders CXX) + +add_library(tgt SHARED empty.cxx) +target_precompile_headers(tgt PRIVATE stdafx.h) |