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
This commit is contained in:
Viktor Szakats
2025-12-19 14:57:10 +01:00
parent 7ded0e21cd
commit 1892286086
12 changed files with 23 additions and 28 deletions

4
.github/labeler.yml vendored
View File

@@ -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/**\
}"

View File

@@ -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'

View File

@@ -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)

View File

@@ -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 \

View File

@@ -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")

View File

@@ -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 \

View File

@@ -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 \

View File

@@ -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 --

View File

@@ -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++;
}
}