]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cmake: initialize variables where missing
authorViktor Szakats <commit@vsz.me>
Thu, 6 Feb 2025 00:22:22 +0000 (01:22 +0100)
committerViktor Szakats <commit@vsz.me>
Thu, 6 Feb 2025 22:32:37 +0000 (23:32 +0100)
As detected using `cmake --warn-uninitialized`.

It also lists:
- variables inherited from `Makefile.inc`, which this PR does not fix.

- a documented CMake global variable, which is unexpected:
  `CMAKE_MODULE_PATH`.
  I'd expect CMake to initialize its namespace.

- envs: `CI`, `CURL_CI` and `CURL_BUILDINFO`. Unexpected, as the manual
  mentions variables only. As of August 2024, there is no solution to
  silence them:
  https://discourse.cmake.org/t/how-to-test-for-set-env-variables-without-getting-warnings/11401

https://cmake.org/cmake/help/latest/manual/cmake.1.html#cmdoption-cmake-warn-uninitialized

Closes #16198

CMake/Macros.cmake
CMakeLists.txt
lib/CMakeLists.txt

index ad0df18af86a4f0715961873f9bbb928c227a1b9..8653f36b0a5a663b17c611113ca28d3a8bf13a43 100644 (file)
@@ -34,11 +34,14 @@ macro(check_include_file_concat_curl _file _variable)
   endif()
 endmacro()
 
+set(CURL_TEST_DEFINES "")  # Initialize global variable
+
 # For other curl specific tests, use this macro.
 # Return result in variable: CURL_TEST_OUTPUT
 macro(curl_internal_test _curl_test)
   if(NOT DEFINED "${_curl_test}")
     string(REPLACE ";" " " _cmake_required_definitions "${CMAKE_REQUIRED_DEFINITIONS}")
+    set(_curl_test_add_libraries "")
     if(CMAKE_REQUIRED_LIBRARIES)
       set(_curl_test_add_libraries
         "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
index 1e09bf0c7d16bc55a89f594f35031665cf46b753..ce1318c6dde6ecc327b396c374d4dcbeaf7ee1d4 100644 (file)
@@ -2469,6 +2469,7 @@ if(NOT CURL_DISABLE_INSTALL)
 endif()
 
 # Save build info for test runner to pick up and log
+set(_cmake_sysroot "")
 if(CMAKE_OSX_SYSROOT)
   set(_cmake_sysroot ${CMAKE_OSX_SYSROOT})
 elseif(CMAKE_SYSROOT)
index c1863b0de343409298255a788756cf99281984bd..168fa20cf3cbe4f6554912859782b1e8899d9caa 100644 (file)
@@ -65,6 +65,13 @@ endif()
 
 ## Library definition
 
+if(NOT DEFINED IMPORT_LIB_SUFFIX)
+  set(IMPORT_LIB_SUFFIX "")
+endif()
+if(NOT DEFINED STATIC_LIB_SUFFIX)
+  set(STATIC_LIB_SUFFIX "")
+endif()
+
 # Add "_imp" as a suffix before the extension to avoid conflicting with
 # the statically linked "libcurl.lib" (typically with MSVC)
 if(WIN32 AND