From 18922860867357062b5fe3fbf60b77ea34007855 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 19 Dec 2025 14:57:10 +0100 Subject: [PATCH] cmake: match filename suffixes with file content To: - simplify recognizing CMake sources. - ensure syntax highlighters use the correct file type. - sync .h template filename with its autotools counterpart. Also: - cmakelint.sh: simplify, alpha sort the filelist. - perlcheck.sh: simplify. Closes #20039 --- .github/labeler.yml | 4 ++-- .github/workflows/configure-vs-cmake.yml | 4 ++-- ..._uninstall.cmake.in => cmake_uninstall.in.cmake} | 0 .../{curl-config.cmake.in => curl-config.in.cmake} | 0 CMakeLists.txt | 4 ++-- Makefile.am | 4 ++-- lib/CMakeLists.txt | 2 +- lib/Makefile.am | 2 +- lib/{curl_config.h.cmake => curl_config-cmake.h.in} | 0 scripts/cmakelint.sh | 10 ++++------ scripts/perlcheck.sh | 13 +++++-------- tests/test1165.pl | 8 ++++---- 12 files changed, 23 insertions(+), 28 deletions(-) rename CMake/{cmake_uninstall.cmake.in => cmake_uninstall.in.cmake} (100%) rename CMake/{curl-config.cmake.in => curl-config.in.cmake} (100%) rename lib/{curl_config.h.cmake => curl_config-cmake.h.in} (100%) diff --git a/.github/labeler.yml b/.github/labeler.yml index 7ff3971bdc..a3ca5d38be 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -65,7 +65,7 @@ build: **/*.mk,\ *.m4,\ docs/INSTALL-CMAKE.md,\ - lib/curl_config.h.cmake,\ + lib/curl_config-cmake.h.in,\ lib/libcurl*.in,\ CMake/**,\ CMakeLists.txt,\ @@ -98,7 +98,7 @@ cmake: **/CMakeLists.txt,\ CMake/**,\ docs/INSTALL-CMAKE.md,\ - lib/curl_config.h.cmake,\ + lib/curl_config-cmake.h.in,\ tests/cmake/**\ }" diff --git a/.github/workflows/configure-vs-cmake.yml b/.github/workflows/configure-vs-cmake.yml index 6d68262cee..52c808db44 100644 --- a/.github/workflows/configure-vs-cmake.yml +++ b/.github/workflows/configure-vs-cmake.yml @@ -12,7 +12,7 @@ name: 'configure-vs-cmake' - '**/*.m4' - '**/CMakeLists.txt' - 'CMake/**' - - 'lib/curl_config.h.cmake' + - 'lib/curl_config-cmake.h.in' - 'tests/cmake/**' - '.github/scripts/cmp-config.pl' - '.github/workflows/configure-vs-cmake.yml' @@ -25,7 +25,7 @@ name: 'configure-vs-cmake' - '**/*.m4' - '**/CMakeLists.txt' - 'CMake/**' - - 'lib/curl_config.h.cmake' + - 'lib/curl_config-cmake.h.in' - 'tests/cmake/**' - '.github/scripts/cmp-config.pl' - '.github/workflows/configure-vs-cmake.yml' diff --git a/CMake/cmake_uninstall.cmake.in b/CMake/cmake_uninstall.in.cmake similarity index 100% rename from CMake/cmake_uninstall.cmake.in rename to CMake/cmake_uninstall.in.cmake diff --git a/CMake/curl-config.cmake.in b/CMake/curl-config.in.cmake similarity index 100% rename from CMake/curl-config.cmake.in rename to CMake/curl-config.in.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index c67d187e12..43ec013508 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2339,7 +2339,7 @@ if(NOT CURL_DISABLE_INSTALL) # USE_RUSTLS # USE_WIN32_LDAP CURL_DISABLE_LDAP # USE_WOLFSSL - configure_package_config_file("CMake/curl-config.cmake.in" + configure_package_config_file("CMake/curl-config.in.cmake" "${_project_config}" INSTALL_DESTINATION ${_install_cmake_dir} PATH_VARS CMAKE_INSTALL_INCLUDEDIR) @@ -2380,7 +2380,7 @@ if(NOT CURL_DISABLE_INSTALL) if(NOT TARGET curl_uninstall) configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/CMake/cmake_uninstall.cmake.in" + "${CMAKE_CURRENT_SOURCE_DIR}/CMake/cmake_uninstall.in.cmake" "${CMAKE_CURRENT_BINARY_DIR}/CMake/cmake_uninstall.cmake" @ONLY) diff --git a/Makefile.am b/Makefile.am index 876e1ee0f5..5f6bb670e5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -27,8 +27,8 @@ AUTOMAKE_OPTIONS = foreign ACLOCAL_AMFLAGS = -I m4 CMAKE_DIST = \ - CMake/cmake_uninstall.cmake.in \ - CMake/curl-config.cmake.in \ + CMake/cmake_uninstall.in.cmake \ + CMake/curl-config.in.cmake \ CMake/CurlSymbolHiding.cmake \ CMake/CurlTests.c \ CMake/FindBrotli.cmake \ diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 66a6c776f3..0f842f0cc1 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -26,7 +26,7 @@ set(LIBCURL_OUTPUT_NAME "${LIB_NAME}" CACHE STRING "Basename of the curl library set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS ${CURL_DEBUG_MACROS} "BUILDING_LIBCURL") -configure_file("curl_config.h.cmake" "${CMAKE_CURRENT_BINARY_DIR}/curl_config.h") +configure_file("curl_config-cmake.h.in" "${CMAKE_CURRENT_BINARY_DIR}/curl_config.h") # Get CSOURCES, HHEADERS, LIB_RCFILES variables curl_transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake") diff --git a/lib/Makefile.am b/lib/Makefile.am index 813b2224eb..833d756648 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -26,7 +26,7 @@ AUTOMAKE_OPTIONS = foreign nostdinc # Get CSOURCES, HHEADERS, LIB_RCFILES variables include Makefile.inc -CMAKE_DIST = CMakeLists.txt curl_config.h.cmake +CMAKE_DIST = CMakeLists.txt curl_config-cmake.h.in EXTRA_DIST = config-mac.h config-os400.h config-plan9.h config-riscos.h \ config-win32.h curl_config.h.in $(LIB_RCFILES) libcurl.def \ diff --git a/lib/curl_config.h.cmake b/lib/curl_config-cmake.h.in similarity index 100% rename from lib/curl_config.h.cmake rename to lib/curl_config-cmake.h.in diff --git a/scripts/cmakelint.sh b/scripts/cmakelint.sh index a9bd7472d4..dc66829fc8 100755 --- a/scripts/cmakelint.sh +++ b/scripts/cmakelint.sh @@ -45,15 +45,13 @@ cd "$(dirname "$0")"/.. { if [ -n "${1:-}" ]; then - for A in "$@"; do printf "%s\n" "$A"; done + for A in "$@"; do printf '%s\n' "$A"; done elif git rev-parse --is-inside-work-tree >/dev/null 2>&1; then - git ls-files + git ls-files '**CMakeLists.txt' '*.cmake' else - # strip off the leading ./ to make the grep regexes work properly - find . -type f | sed 's@^\./@@' + find . -type f \( -name 'CMakeLists.txt' -o -name '*.cmake' \) fi -} | grep -E '(^CMake|/CMake|\.cmake$|\.cmake\.in$)' | grep -v -E '(\.h\.cmake|\.c)$' \ - | xargs \ +} | sort | xargs \ cmake-lint \ --suppress-decorations \ --disable \ diff --git a/scripts/perlcheck.sh b/scripts/perlcheck.sh index 4d2996d2f7..c243f50271 100755 --- a/scripts/perlcheck.sh +++ b/scripts/perlcheck.sh @@ -38,14 +38,11 @@ echo "parallel: ${procs}" { if [ -n "${1:-}" ]; then - for A in "$@"; do printf "%s\n" "$A"; done + for A in "$@"; do printf '%s\n' "$A"; done elif git rev-parse --is-inside-work-tree >/dev/null 2>&1; then - { - git ls-files | grep -E '\.(pl|pm)$' - git grep -l '^#!/usr/bin/env perl' - } | sort -u + git ls-files '*.pl' '*.pm' + git grep -l '^#!/usr/bin/env perl' else - # strip off the leading ./ to make the grep regexes work properly - find . -type f \( -name '*.pl' -o -name '*.pm' \) | sed 's@^\./@@' + find . -type f \( -name '*.pl' -o -name '*.pm' \) fi -} | xargs -n 1 -P "${procs}" perl -c -Itests -- +} | sort -u | xargs -n 1 -P "${procs}" perl -c -Itests -- diff --git a/tests/test1165.pl b/tests/test1165.pl index f0468d12fd..5546fbded9 100755 --- a/tests/test1165.pl +++ b/tests/test1165.pl @@ -30,7 +30,7 @@ use warnings; my %disable; # the DISABLE options that can be set by CMakeLists.txt my %disable_cmake; -# the DISABLE options propagated via curl_config.h.cmake +# the DISABLE options propagated via curl_config-cmake.h.in my %disable_cmake_config_h; # the DISABLE options that are used in C files my %file; @@ -83,7 +83,7 @@ sub scan_cmake { } sub scan_cmake_config_h { - scanconf_cmake(\%disable_cmake_config_h, "$root/lib/curl_config.h.cmake"); + scanconf_cmake(\%disable_cmake_config_h, "$root/lib/curl_config-cmake.h.in"); } my %whitelisted = ('CURL_DISABLE_DEPRECATION' => 1); @@ -165,10 +165,10 @@ for my $s (sort keys %disable_cmake) { } } -# Check the CMakeLists.txt symbols for use in curl_config.h.cmake +# Check the CMakeLists.txt symbols for use in curl_config-cmake.h.in for my $s (sort keys %disable_cmake) { if(!$disable_cmake_config_h{$s}) { - printf "Present in CMakeLists.txt, not propagated via curl_config.h.cmake: %s\n", $s; + printf "Present in CMakeLists.txt, not propagated via curl_config-cmake.h.in: %s\n", $s; $error++; } }