]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cmake: add test for `DISABLE` options, add `CURL_DISABLE_HEADERS_API`
authorViktor Szakats <commit@vsz.me>
Fri, 17 Nov 2023 21:42:54 +0000 (21:42 +0000)
committerViktor Szakats <commit@vsz.me>
Mon, 20 Nov 2023 22:28:17 +0000 (22:28 +0000)
- 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

CMakeLists.txt
lib/curl_config.h.cmake
tests/disable-scan.pl

index db138237aab8ddd2a5b8ce26620d2ba80c5df96c..a71b5b0b5d886d56885f96216cdd3e2f62b7b061 100644 (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)
index 3da5a41eb7b6283bd63e4db2f5740b548be7192b..274c2c168215badf0e10e34413c12fcf99122ccb 100644 (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
 
index 99f5436af5a92130138b888789bb3ef4c995c3c5..b6f3179cf751b87d9b05a8f9eed9e9aa232f0c0c 100755 (executable)
@@ -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++;