diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2022-08-03 13:58:34 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-08-03 13:58:43 (GMT) |
commit | e7bfd0ac7aed989dc5d58d713627826c06537f89 (patch) | |
tree | da68ef5dab66229b35133fee0c8fe4d7e3a1c984 | |
parent | f8f8b8e60e157cd6e5bffbf8b1dd7f6273cd16f8 (diff) | |
parent | 83e44002aeee2e6d147bf5bbd185137c32ff04ce (diff) | |
download | CMake-e7bfd0ac7aed989dc5d58d713627826c06537f89.zip CMake-e7bfd0ac7aed989dc5d58d713627826c06537f89.tar.gz CMake-e7bfd0ac7aed989dc5d58d713627826c06537f89.tar.bz2 |
Merge topic 'all-verify-interface-header-sets'
83e44002ae VERIFY_INTERFACE_HEADER_SETS: Add verification target for all
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7536
10 files changed, 58 insertions, 0 deletions
diff --git a/Help/prop_tgt/VERIFY_INTERFACE_HEADER_SETS.rst b/Help/prop_tgt/VERIFY_INTERFACE_HEADER_SETS.rst index da461a7..dd415c8 100644 --- a/Help/prop_tgt/VERIFY_INTERFACE_HEADER_SETS.rst +++ b/Help/prop_tgt/VERIFY_INTERFACE_HEADER_SETS.rst @@ -26,6 +26,10 @@ Otherwise, if C++ is enabled globally, the header is compiled as C++. Otherwise, if C is enabled globally, the header is compiled as C. Otherwise, the header file is not compiled. +If any verification targets are created, a top-level target called +``all_verify_interface_header_sets`` is created which depends on all +verification targets. + This property is initialized by the value of the :variable:`CMAKE_VERIFY_INTERFACE_HEADER_SETS` variable if it is set when a target is created. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index d59ac2b..7cd7915 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -8579,6 +8579,9 @@ bool cmGeneratorTarget::AddHeaderSetVerification() } cmTarget* verifyTarget = nullptr; + cmTarget* allVerifyTarget = + this->GlobalGenerator->GetMakefiles().front()->FindTargetToUse( + "all_verify_interface_header_sets", true); auto interfaceFileSetEntries = this->Target->GetInterfaceHeaderSetsEntries(); @@ -8666,6 +8669,15 @@ bool cmGeneratorTarget::AddHeaderSetVerification() verifyTarget->FinalizeTargetCompileInfo( this->Makefile->GetCompileDefinitionsEntries(), perConfigCompileDefinitions); + + if (!allVerifyTarget) { + allVerifyTarget = this->GlobalGenerator->GetMakefiles() + .front() + ->AddNewUtilityTarget( + "all_verify_interface_header_sets", true); + } + + allVerifyTarget->AddUtility(verifyTarget->GetName(), false); } if (fileCgesContextSensitive) { diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index edc4118..4feae6d 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1758,6 +1758,14 @@ bool cmGlobalGenerator::AddHeaderSetVerification() } } + cmTarget* allVerifyTarget = this->Makefiles.front()->FindTargetToUse( + "all_verify_interface_header_sets", true); + if (allVerifyTarget) { + this->LocalGenerators.front()->AddGeneratorTarget( + cm::make_unique<cmGeneratorTarget>(allVerifyTarget, + this->LocalGenerators.front().get())); + } + return true; } diff --git a/Tests/RunCMake/VerifyHeaderSets/AllVerifyInterfaceHeaderSets-all_verify_interface_header_sets-Debug-build-check.cmake b/Tests/RunCMake/VerifyHeaderSets/AllVerifyInterfaceHeaderSets-all_verify_interface_header_sets-Debug-build-check.cmake new file mode 100644 index 0000000..d5a513a --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/AllVerifyInterfaceHeaderSets-all_verify_interface_header_sets-Debug-build-check.cmake @@ -0,0 +1,10 @@ +# A custom command is used to copy the header file from the source directory to +# the binary directory. If the verification target was built, the custom +# command should have been executed, and the file should be present in the +# binary directory. +if(NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/dir1/lib1.h") + string(APPEND RunCMake_TEST_FAILED "${RunCMake_TEST_BINARY_DIR}/dir1/lib1.h should exist but it does not\n") +endif() +if(NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/dir2/lib2.h") + string(APPEND RunCMake_TEST_FAILED "${RunCMake_TEST_BINARY_DIR}/dir2/lib2.h should exist but it does not\n") +endif() diff --git a/Tests/RunCMake/VerifyHeaderSets/AllVerifyInterfaceHeaderSets.cmake b/Tests/RunCMake/VerifyHeaderSets/AllVerifyInterfaceHeaderSets.cmake new file mode 100644 index 0000000..8948bac --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/AllVerifyInterfaceHeaderSets.cmake @@ -0,0 +1,4 @@ +enable_language(C) + +add_subdirectory(dir1) +add_subdirectory(dir2) diff --git a/Tests/RunCMake/VerifyHeaderSets/RunCMakeTest.cmake b/Tests/RunCMake/VerifyHeaderSets/RunCMakeTest.cmake index 9f9a1e7..b4fe720 100644 --- a/Tests/RunCMake/VerifyHeaderSets/RunCMakeTest.cmake +++ b/Tests/RunCMake/VerifyHeaderSets/RunCMakeTest.cmake @@ -44,5 +44,11 @@ run_cmake_build(VerifyHeaderSets interface_lang_test_cxx_verify_interface_header run_cmake_build(VerifyHeaderSets list_verify_interface_header_sets) set(RunCMake_TEST_OPTIONS -DCMAKE_VERIFY_INTERFACE_HEADER_SETS=ON) +run_cmake(AllVerifyInterfaceHeaderSets) +unset(RunCMake_TEST_OPTIONS) + +run_cmake_build(AllVerifyInterfaceHeaderSets all_verify_interface_header_sets) + +set(RunCMake_TEST_OPTIONS -DCMAKE_VERIFY_INTERFACE_HEADER_SETS=ON) run_cmake(VerifyHeaderSetsNonexistent) unset(RunCMake_TEST_OPTIONS) diff --git a/Tests/RunCMake/VerifyHeaderSets/dir1/CMakeLists.txt b/Tests/RunCMake/VerifyHeaderSets/dir1/CMakeLists.txt new file mode 100644 index 0000000..d26e933 --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/dir1/CMakeLists.txt @@ -0,0 +1,3 @@ +add_library(lib1 STATIC ../lib.c) +add_custom_command(OUTPUT lib1.h COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/lib1.h lib1.h) +target_sources(lib1 PUBLIC FILE_SET HEADERS BASE_DIRS ${CMAKE_CURRENT_BINARY_DIR} FILES ${CMAKE_CURRENT_BINARY_DIR}/lib1.h) diff --git a/Tests/RunCMake/VerifyHeaderSets/dir1/lib1.h b/Tests/RunCMake/VerifyHeaderSets/dir1/lib1.h new file mode 100644 index 0000000..69c37ed --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/dir1/lib1.h @@ -0,0 +1,4 @@ +#ifdef _WIN32 +__declspec(dllimport) +#endif + extern void lib1(void); diff --git a/Tests/RunCMake/VerifyHeaderSets/dir2/CMakeLists.txt b/Tests/RunCMake/VerifyHeaderSets/dir2/CMakeLists.txt new file mode 100644 index 0000000..8c3658c --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/dir2/CMakeLists.txt @@ -0,0 +1,3 @@ +add_library(lib2 STATIC ../lib.c) +add_custom_command(OUTPUT lib2.h COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/lib2.h lib2.h) +target_sources(lib2 PUBLIC FILE_SET HEADERS BASE_DIRS ${CMAKE_CURRENT_BINARY_DIR} FILES ${CMAKE_CURRENT_BINARY_DIR}/lib2.h) diff --git a/Tests/RunCMake/VerifyHeaderSets/dir2/lib2.h b/Tests/RunCMake/VerifyHeaderSets/dir2/lib2.h new file mode 100644 index 0000000..fa24a9a --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/dir2/lib2.h @@ -0,0 +1,4 @@ +#ifdef _WIN32 +__declspec(dllimport) +#endif + extern void lib2(void); |