cmake: add test for DISABLE options, add CURL_DISABLE_HEADERS_API

- tests: verify CMake `DISABLE` options.

  Make an exception for 2 CMake-only ones, and one more that's
  using a different naming scheme, also in autotools and source.

- cmake: add support for `CURL_DISABLE_HEADERS_API`.

Suggested-by: Daniel Stenberg
Ref: https://github.com/curl/curl/pull/12345#pullrequestreview-1736238641

Closes #12353
This commit is contained in:
Viktor Szakats 2023-11-17 21:42:54 +00:00
parent b9b50f3193
commit 33493db2af
No known key found for this signature in database
GPG Key ID: B5ABD165E2AEF201
3 changed files with 46 additions and 0 deletions

View File

@ -222,6 +222,8 @@ option(CURL_DISABLE_GETOPTIONS "disables curl_easy_options API for existing opti
mark_as_advanced(CURL_DISABLE_GETOPTIONS)
option(CURL_DISABLE_GOPHER "disables Gopher" OFF)
mark_as_advanced(CURL_DISABLE_GOPHER)
option(CURL_DISABLE_HEADERS_API "disables headers-api support" OFF)
mark_as_advanced(CURL_DISABLE_HEADERS_API)
option(CURL_DISABLE_HSTS "disables HSTS support" OFF)
mark_as_advanced(CURL_DISABLE_HSTS)
option(CURL_DISABLE_HTTP "disables HTTP" OFF)

View File

@ -80,6 +80,9 @@
/* disables GOPHER */
#cmakedefine CURL_DISABLE_GOPHER 1
/* disables headers-api support */
#cmakedefine CURL_DISABLE_HEADERS_API 1
/* disables HSTS support */
#cmakedefine CURL_DISABLE_HSTS 1

View File

@ -29,6 +29,8 @@ use warnings;
# the DISABLE options that can be set by configure
my %disable;
# the DISABLE options that can be set by CMakeLists.txt
my %disable_cmake;
# the DISABLE options that are used in C files
my %file;
# the DISABLE options that are documented
@ -61,6 +63,24 @@ sub scan_configure {
}
}
sub scanconf_cmake {
my ($f)=@_;
open S, "<$f";
while(<S>) {
if(/(CURL_DISABLE_[A-Z_]+)/g) {
my ($sym)=($1);
if(not $sym =~ /(CURL_DISABLE_INSTALL|CURL_DISABLE_TESTS|CURL_DISABLE_SRP)/) {
$disable_cmake{$sym} = 1;
}
}
}
close S;
}
sub scan_cmake {
scanconf_cmake("$root/CMakeLists.txt");
}
sub scan_file {
my ($source)=@_;
open F, "<$source";
@ -104,6 +124,7 @@ sub scan_docs {
}
scan_configure();
scan_cmake();
scan_sources();
scan_docs();
@ -121,12 +142,28 @@ for my $s (sort keys %disable) {
}
}
# Check the CMakeLists.txt symbols for use in code
for my $s (sort keys %disable_cmake) {
if(!$file{$s}) {
printf "Present in CMakeLists.txt, not used by code: %s\n", $s;
$error++;
}
if(!$docs{$s}) {
printf "Present in CMakeLists.txt, not documented in $DOCS: %s\n", $s;
$error++;
}
}
# Check the code symbols for use in configure
for my $s (sort keys %file) {
if(!$disable{$s}) {
printf "Not set by configure: %s (%s)\n", $s, $file{$s};
$error++;
}
if(!$disable_cmake{$s}) {
printf "Not set by CMakeLists.txt: %s (%s)\n", $s, $file{$s};
$error++;
}
if(!$docs{$s}) {
printf "Used in code, not documented in $DOCS: %s\n", $s;
$error++;
@ -139,6 +176,10 @@ for my $s (sort keys %docs) {
printf "Documented but not in configure: %s\n", $s;
$error++;
}
if(!$disable_cmake{$s}) {
printf "Documented but not in CMakeLists.txt: %s\n", $s;
$error++;
}
if(!$file{$s}) {
printf "Documented, but not used by code: %s\n", $s;
$error++;