From: Viktor Szakats Date: Wed, 31 Jul 2024 09:53:31 +0000 (+0200) Subject: cmake: distcheck for files in CMake subdir X-Git-Tag: curl-8_10_0~454 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a118a6ecddb0322a6da07815aabf9e36cd5f44bc;p=thirdparty%2Fcurl.git cmake: distcheck for files in CMake subdir - add CMake option to verify if the `CMake/*.cmake`, `CMake/*.in` files are listed as distributable in autotools' `EXTRA_DIST`. The check can be enabled with `-DENABLE_DIST_TEST=ON` CMake option. - add CI job to that effect. Ref: #14320 Closes #14323 --- diff --git a/.github/workflows/distcheck.yml b/.github/workflows/distcheck.yml index aa047c2cbf..40c256712b 100644 --- a/.github/workflows/distcheck.yml +++ b/.github/workflows/distcheck.yml @@ -129,3 +129,13 @@ jobs: cmake -B build -DCURL_WERROR=ON make -C build -j5 name: 'verify out-of-tree cmake build' + + verify-cmake-test-dist: + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 + + - name: 'cmake test dist' + run: | + cmake -B build -DENABLE_DIST_TEST=ON diff --git a/CMakeLists.txt b/CMakeLists.txt index 86fa2d599e..1ea35e7030 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1609,7 +1609,15 @@ endif() # Ugly (but functional) way to include "Makefile.inc" by transforming it # (= regenerate it). function(transform_makefile_inc INPUT_FILE OUTPUT_FILE) - file(READ ${INPUT_FILE} MAKEFILE_INC_TEXT) + file(STRINGS "${INPUT_FILE}" _makefile_inc_lines) + set(MAKEFILE_INC_TEXT "") + foreach(_line IN LISTS _makefile_inc_lines) + if(_line MATCHES "### USE SIMPLE LIST ASSIGMENTS ABOVE THIS LINE ###") + break() + endif() + set(MAKEFILE_INC_TEXT "${MAKEFILE_INC_TEXT}${_line}\n") + endforeach() + string(REPLACE "$(top_srcdir)" "\${CURL_SOURCE_DIR}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT}) string(REPLACE "$(top_builddir)" "\${CURL_BINARY_DIR}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT}) @@ -1654,6 +1662,23 @@ if(BUILD_TESTING) add_subdirectory(tests) endif() +# Verify if all CMake include/input files are listed as distributable +if(ENABLE_DIST_TEST) + # Get 'CMAKE_DIST' variable + transform_makefile_inc("Makefile.am" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.am.cmake") + include(${CMAKE_CURRENT_BINARY_DIR}/Makefile.am.cmake) + + file(GLOB_RECURSE curl_cmake_files_found RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" + "${CMAKE_CURRENT_SOURCE_DIR}/CMake/*.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/CMake/*.in") + + foreach(_item IN LISTS curl_cmake_files_found) + if(NOT _item IN_LIST CMAKE_DIST) + message(FATAL_ERROR "Source file missing from the Makefile.am CMAKE_DIST list: ${_item}") + endif() + endforeach() +endif() + if(NOT CURL_DISABLE_INSTALL) install(FILES "${PROJECT_SOURCE_DIR}/scripts/mk-ca-bundle.pl" diff --git a/Makefile.am b/Makefile.am index 5d4895685e..ffd319457c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -93,6 +93,8 @@ DIST_SUBDIRS = $(SUBDIRS) tests packages scripts include docs pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libcurl.pc +### USE SIMPLE LIST ASSIGMENTS ABOVE THIS LINE ### DO NOT DELETE + # List of files required to generate VC IDE .dsp, .vcproj and .vcxproj files include lib/Makefile.inc include src/Makefile.inc