From d0bb3286f022fdb8f0541599fa39efabb9ce2b63 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Thu, 18 Aug 2022 16:25:46 -0400 Subject: cmake -E capabilities: Tell whether TLS is enabled Fixes: #20507 --- Help/manual/cmake.1.rst | 5 +++++ Help/release/dev/E-capabilities-tls.rst | 5 +++++ Source/cmake.cxx | 4 ++++ Tests/RunCMake/CommandLine/E_capabilities-stdout.txt | 2 +- 4 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 Help/release/dev/E-capabilities-tls.rst diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst index 7eaf3fa..dcea7f9 100644 --- a/Help/manual/cmake.1.rst +++ b/Help/manual/cmake.1.rst @@ -773,6 +773,11 @@ Available commands are: ``true`` if cmake supports server-mode and ``false`` otherwise. Always false since CMake 3.20. + ``tls`` + .. versionadded:: 3.25 + + ``true`` if TLS support is enabled and ``false`` otherwise. + .. option:: cat [--] ... .. versionadded:: 3.18 diff --git a/Help/release/dev/E-capabilities-tls.rst b/Help/release/dev/E-capabilities-tls.rst new file mode 100644 index 0000000..e2324d2 --- /dev/null +++ b/Help/release/dev/E-capabilities-tls.rst @@ -0,0 +1,5 @@ +E-capabilities-tls +------------------ + +* The :manual:`cmake -E capabilities ` command gained a new ``tls`` + field that tells whether or not TLS is enabled. diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 9b2b119..8125227 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -63,6 +63,7 @@ #if !defined(CMAKE_BOOTSTRAP) # include +# include # include # include "cmFileAPI.h" @@ -252,6 +253,8 @@ Json::Value cmake::ReportCapabilitiesJson() const std::vector generatorInfoList; this->GetRegisteredGenerators(generatorInfoList); + auto* curlVersion = curl_version_info(CURLVERSION_FIRST); + JsonValueMapType generatorMap; for (cmake::GeneratorInfo const& gi : generatorInfoList) { if (gi.isAlias) { // skip aliases, they are there for compatibility reasons @@ -286,6 +289,7 @@ Json::Value cmake::ReportCapabilitiesJson() const obj["generators"] = generators; obj["fileApi"] = cmFileAPI::ReportCapabilities(); obj["serverMode"] = false; + obj["tls"] = static_cast(curlVersion->features & CURL_VERSION_SSL); return obj; } diff --git a/Tests/RunCMake/CommandLine/E_capabilities-stdout.txt b/Tests/RunCMake/CommandLine/E_capabilities-stdout.txt index 6a932f1..1452c9b 100644 --- a/Tests/RunCMake/CommandLine/E_capabilities-stdout.txt +++ b/Tests/RunCMake/CommandLine/E_capabilities-stdout.txt @@ -1 +1 @@ -^{"fileApi":{"requests":\[{"kind":"codemodel","version":\[{"major":2,"minor":4}]},{"kind":"cache","version":\[{"major":2,"minor":0}]},{"kind":"cmakeFiles","version":\[{"major":1,"minor":0}]},{"kind":"toolchains","version":\[{"major":1,"minor":0}]}]},"generators":\[.*\],"serverMode":false,"version":{.*}}$ +^{"fileApi":{"requests":\[{"kind":"codemodel","version":\[{"major":2,"minor":4}]},{"kind":"cache","version":\[{"major":2,"minor":0}]},{"kind":"cmakeFiles","version":\[{"major":1,"minor":0}]},{"kind":"toolchains","version":\[{"major":1,"minor":0}]}]},"generators":\[.*\],"serverMode":false,"tls":(true|false),"version":{.*}}$ -- cgit v0.12