Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running CMake Configure twice on Linux results in different curl_config.h #7100

Closed
AllianceDarkSylinc opened this issue May 20, 2021 · 0 comments

Comments

@AllianceDarkSylinc
Copy link

AllianceDarkSylinc commented May 20, 2021

I did this

It is quite common practice to run CMake configure more than once.
In fact super ultra common for IDEs like QtCreator.

The first run results in this file:

curl_config.first.run.h.zip

The second run results in this file:

curl_config.next.runs.h.zip

To be more concrete, the only 2 differences (at least on Ubuntu 18.04 LTS) are these:

#define CURL_CA_BUNDLE "/etc/ssl/certs/ca-certificates.crt"
#define CURL_CA_PATH "/etc/ssl/certs"

vs

/* #undef CURL_CA_BUNDLE */
/* #undef CURL_CA_PATH */

I expected the following

The first file should always be created

Why this happens?

This happens because the CMake script starts using CURL_CA_BUNDLE_SET as a temporary variable to drive logic.

But then once it's done it sets CURL_CA_BUNDLE_SET both as a user-configurable variable to drive logic, and a way to inform the user that the CA Bundle has been set.

So when the script is ran a 2nd time, it sees CURL_CA_BUNDLE_SET is set 'manually' (the code seems to assume it's been set by the user) and thus early outs from autodetecting the paths.

Solutions

I believe this is what's intended:

set(CURL_CA_BUNDLE_SET TRUE CACHE BOOL "Path to the CA bundle has been set")
set(CURL_CA_PATH "/etc/ssl/certs" CACHE STRING
		  "Location of default CA path. Set 'none' to disable or 'auto' for auto-detection. Defaults to 'auto'.")

It fixes the problem because now the script also remembers the path that were searched during the 1st run.

This is the patch:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2ffb72faf..7ea5867b7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -851,7 +851,8 @@ elseif(CURL_CA_PATH_AUTODETECT OR CURL_CA_BUNDLE_AUTODETECT)
     foreach(SEARCH_CA_BUNDLE_PATH ${SEARCH_CA_BUNDLE_PATHS})
       if(EXISTS "${SEARCH_CA_BUNDLE_PATH}")
         message(STATUS "Found CA bundle: ${SEARCH_CA_BUNDLE_PATH}")
-        set(CURL_CA_BUNDLE "${SEARCH_CA_BUNDLE_PATH}")
+        set(CURL_CA_BUNDLE "${SEARCH_CA_BUNDLE_PATH}" CACHE STRING
+            "Path to the CA bundle. Set 'none' to disable or 'auto' for auto-detection. Defaults to 'auto'.")
         set(CURL_CA_BUNDLE_SET TRUE CACHE BOOL "Path to the CA bundle has been set")
         break()
       endif()
@@ -860,7 +861,8 @@ elseif(CURL_CA_PATH_AUTODETECT OR CURL_CA_BUNDLE_AUTODETECT)
 
   if(CURL_CA_PATH_AUTODETECT AND (NOT CURL_CA_PATH_SET))
     if(EXISTS "/etc/ssl/certs")
-      set(CURL_CA_PATH "/etc/ssl/certs")
+      set(CURL_CA_PATH "/etc/ssl/certs" CACHE STRING
+          "Location of default CA path. Set 'none' to disable or 'auto' for auto-detection. Defaults to 'auto'.")
       set(CURL_CA_PATH_SET TRUE CACHE BOOL "Path to the CA bundle has been set")
     endif()
   endif()

I can submit a PR if you want me to; but I'm not 100% if this is the intended solution.

Update: PR 7101 submitted

curl/libcurl version

curl-7.76.1.tar.bz2

Bug is present as of latest d845d39

operating system

Xubuntu 18.04 LTS
CMake version 3.20.2 (via snap)

Linux matias-ubuntu 5.11.0-051100-generic #202102142330 SMP Sun Feb 14 23:33:21 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

darksylinc added a commit to darksylinc/curl that referenced this issue May 20, 2021
Closes curl#7100

Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar>
@bagder bagder closed this as completed in 458a2d8 May 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant