From d3940dee8a68f78126b34bde1788539a9f770c3e Mon Sep 17 00:00:00 2001 From: Floze Date: Sat, 18 Jul 2026 22:12:50 +0400 Subject: [PATCH] Avoid source glob checks in no-op builds --- CMakeLists.txt | 3 +-- cmake/yaml-cpp-sources.cmake | 35 +++++++++++++++++++++++++++++ test/CMakeLists.txt | 5 +++++ test/cmake/verify-source-list.cmake | 21 +++++++++++++++++ 4 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 cmake/yaml-cpp-sources.cmake create mode 100644 test/cmake/verify-source-list.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index f6415ffcd..c1eee6ad5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,8 +55,7 @@ if (NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY) MultiThreaded$<$:Debug>$<${msvc-shared_rt}:DLL>) endif() -file(GLOB yaml-cpp-contrib-sources CONFIGURE_DEPENDS "src/contrib/*.cpp") -file(GLOB yaml-cpp-sources CONFIGURE_DEPENDS "src/*.cpp") +include("${CMAKE_CURRENT_LIST_DIR}/cmake/yaml-cpp-sources.cmake") set(msvc-rt $) diff --git a/cmake/yaml-cpp-sources.cmake b/cmake/yaml-cpp-sources.cmake new file mode 100644 index 000000000..eb1a48aec --- /dev/null +++ b/cmake/yaml-cpp-sources.cmake @@ -0,0 +1,35 @@ +set(yaml-cpp-contrib-sources + src/contrib/graphbuilder.cpp + src/contrib/graphbuilderadapter.cpp) + +set(yaml-cpp-sources + src/binary.cpp + src/convert.cpp + src/depthguard.cpp + src/directives.cpp + src/emit.cpp + src/emitfromevents.cpp + src/emitter.cpp + src/emitterstate.cpp + src/emitterutils.cpp + src/exceptions.cpp + src/exp.cpp + src/fptostring.cpp + src/memory.cpp + src/node.cpp + src/node_data.cpp + src/nodebuilder.cpp + src/nodeevents.cpp + src/null.cpp + src/ostream_wrapper.cpp + src/parse.cpp + src/parser.cpp + src/regex_yaml.cpp + src/scanner.cpp + src/scanscalar.cpp + src/scantag.cpp + src/scantoken.cpp + src/simplekey.cpp + src/singledocparser.cpp + src/stream.cpp + src/tag.cpp) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4c3878a60..61922745c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -47,6 +47,11 @@ endif() add_test(NAME yaml-cpp::test COMMAND yaml-cpp-tests) +add_test( + NAME yaml-cpp::source-list + COMMAND ${CMAKE_COMMAND} + -D YAML_CPP_SOURCE_DIR=${PROJECT_SOURCE_DIR} + -P ${PROJECT_SOURCE_DIR}/test/cmake/verify-source-list.cmake) if (build-windows-dll) add_custom_command( diff --git a/test/cmake/verify-source-list.cmake b/test/cmake/verify-source-list.cmake new file mode 100644 index 000000000..3b6013692 --- /dev/null +++ b/test/cmake/verify-source-list.cmake @@ -0,0 +1,21 @@ +include("${YAML_CPP_SOURCE_DIR}/cmake/yaml-cpp-sources.cmake") + +file(GLOB actual_sources + LIST_DIRECTORIES false + RELATIVE "${YAML_CPP_SOURCE_DIR}" + "${YAML_CPP_SOURCE_DIR}/src/*.cpp" + "${YAML_CPP_SOURCE_DIR}/src/contrib/*.cpp") + +set(expected_sources + ${yaml-cpp-contrib-sources} + ${yaml-cpp-sources}) + +list(SORT actual_sources) +list(SORT expected_sources) + +if(NOT "${actual_sources}" STREQUAL "${expected_sources}") + message(FATAL_ERROR + "yaml-cpp source list is out of date.\n" + "Expected: ${expected_sources}\n" + "Actual: ${actual_sources}") +endif()