From: Viktor Szakats Date: Wed, 6 Nov 2024 12:53:12 +0000 (+0100) Subject: cmake: replace `unset(VAR)` with `set(VAR "")` for init X-Git-Tag: curl-8_12_0~336 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b4aa93114c0c70c5edd746ca21a9c71755f4f37a;p=thirdparty%2Fcurl.git cmake: replace `unset(VAR)` with `set(VAR "")` for init Also add cleanup `unset()`s where missing. Reported-by: Kai Pastor Bug: https://github.com/curl/curl/pull/15255#issuecomment-2458659626 Follow-up to 8b09138083640039ce35657a68eeb10b903ed0a5 #14610 Closes #15497 --- diff --git a/CMake/CurlSymbolHiding.cmake b/CMake/CurlSymbolHiding.cmake index 16ec3feccc..df601aa3c2 100644 --- a/CMake/CurlSymbolHiding.cmake +++ b/CMake/CurlSymbolHiding.cmake @@ -32,8 +32,8 @@ if(WIN32 AND (ENABLE_DEBUG OR ENABLE_CURLDEBUG)) endif() set(CURL_HIDES_PRIVATE_SYMBOLS FALSE) -unset(CURL_EXTERN_SYMBOL) -unset(CURL_CFLAG_SYMBOLS_HIDE) +set(CURL_EXTERN_SYMBOL "") +set(CURL_CFLAG_SYMBOLS_HIDE "") if(CURL_HIDDEN_SYMBOLS) if(CMAKE_C_COMPILER_ID MATCHES "Clang" AND NOT MSVC) diff --git a/CMake/FindLDAP.cmake b/CMake/FindLDAP.cmake index 417eb57888..07346206ea 100644 --- a/CMake/FindLDAP.cmake +++ b/CMake/FindLDAP.cmake @@ -62,7 +62,7 @@ else() # ldap.h and lber.h both being stubs to include and . # This causes an infinite inclusion loop in compile. set(_save_cmake_system_framework_path ${CMAKE_SYSTEM_FRAMEWORK_PATH}) - unset(CMAKE_SYSTEM_FRAMEWORK_PATH) + set(CMAKE_SYSTEM_FRAMEWORK_PATH "") find_path(LDAP_INCLUDE_DIR NAMES "ldap.h") set(CMAKE_SYSTEM_FRAMEWORK_PATH ${_save_cmake_system_framework_path}) find_library(LDAP_LIBRARY NAMES "ldap") diff --git a/CMake/OtherTests.cmake b/CMake/OtherTests.cmake index 62eef12d71..5a9602368e 100644 --- a/CMake/OtherTests.cmake +++ b/CMake/OtherTests.cmake @@ -37,7 +37,7 @@ set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY") if(NOT DEFINED HAVE_STRUCT_SOCKADDR_STORAGE) cmake_push_check_state() - unset(CMAKE_EXTRA_INCLUDE_FILES) + set(CMAKE_EXTRA_INCLUDE_FILES "") if(WIN32) set(CMAKE_EXTRA_INCLUDE_FILES "winsock2.h") set(CMAKE_REQUIRED_LIBRARIES "ws2_32") diff --git a/CMake/PickyWarnings.cmake b/CMake/PickyWarnings.cmake index b62f97f10a..eccab10dee 100644 --- a/CMake/PickyWarnings.cmake +++ b/CMake/PickyWarnings.cmake @@ -23,7 +23,7 @@ ########################################################################### include(CheckCCompilerFlag) -unset(_picky) +set(_picky "") if(CURL_WERROR AND ((CMAKE_COMPILER_IS_GNUCC AND diff --git a/CMakeLists.txt b/CMakeLists.txt index f5d70c891c..412c8a4ab2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,7 +86,7 @@ project(CURL VERSION "${_curl_version_sem}" LANGUAGES C) -unset(_target_flags) +set(_target_flags "") if(APPLE) set(_target_flags "${_target_flags} APPLE") endif() @@ -1874,7 +1874,7 @@ if(NOT CURL_DISABLE_NTLM AND endif() # Clear list and try to detect available protocols -unset(_items) +set(_items "") _add_if("HTTP" NOT CURL_DISABLE_HTTP) _add_if("HTTPS" NOT CURL_DISABLE_HTTP AND _ssl_enabled) _add_if("FTP" NOT CURL_DISABLE_FTP) @@ -1917,7 +1917,7 @@ string(TOLOWER "${SUPPORT_PROTOCOLS}" _support_protocols_lower) message(STATUS "Protocols: ${_support_protocols_lower}") # Clear list and try to detect available features -unset(_items) +set(_items "") _add_if("SSL" _ssl_enabled) _add_if("IPv6" ENABLE_IPV6) _add_if("UnixSockets" USE_UNIX_SOCKETS) @@ -1969,7 +1969,7 @@ string(REPLACE ";" " " SUPPORT_FEATURES "${_items}") message(STATUS "Features: ${SUPPORT_FEATURES}") # Clear list and collect SSL backends -unset(_items) +set(_items "") _add_if("Schannel" _ssl_enabled AND USE_SCHANNEL) _add_if("OpenSSL" _ssl_enabled AND USE_OPENSSL AND OPENSSL_VERSION VERSION_LESS 3.0.0) _add_if("OpenSSL v3+" _ssl_enabled AND USE_OPENSSL AND NOT OPENSSL_VERSION VERSION_LESS 3.0.0) @@ -2041,7 +2041,7 @@ if(NOT CURL_DISABLE_INSTALL) endforeach() # Avoid getting unnecessary -L options for known system directories. - unset(_sys_libdirs) + set(_sys_libdirs "") foreach(_libdir IN LISTS CMAKE_SYSTEM_PREFIX_PATH) if(_libdir MATCHES "/$") set(_libdir "${_libdir}lib") @@ -2066,7 +2066,7 @@ if(NOT CURL_DISABLE_INSTALL) endif() endforeach() - unset(_implicit_libs) + set(_implicit_libs "") if(NOT MINGW AND NOT UNIX) set(_implicit_libs ${CMAKE_C_IMPLICIT_LINK_LIBRARIES}) endif() diff --git a/docs/libcurl/CMakeLists.txt b/docs/libcurl/CMakeLists.txt index 4af47af342..0241e58e00 100644 --- a/docs/libcurl/CMakeLists.txt +++ b/docs/libcurl/CMakeLists.txt @@ -33,8 +33,8 @@ function(add_manual_pages _listname) set(_files_per_batch 200) endif() set(_file_count 0) - unset(_rofffiles) - unset(_mdfiles) + set(_rofffiles "") + set(_mdfiles "") set(_eol "_EOL_") foreach(_file IN LISTS ${_listname} _eol) math(EXPR _file_count "${_file_count} + 1") @@ -46,8 +46,8 @@ function(add_manual_pages _listname) VERBATIM ) set(_file_count 0) - unset(_rofffiles) - unset(_mdfiles) + set(_rofffiles "") + set(_mdfiles "") endif() list(APPEND _rofffiles "${CMAKE_CURRENT_BINARY_DIR}/${_file}") @@ -59,6 +59,8 @@ function(add_manual_pages _listname) endif() list(APPEND _mdfiles "${_mdfile}") endforeach() + unset(_rofffiles) + unset(_mdfiles) endfunction() add_custom_command(OUTPUT "libcurl-symbols.md" @@ -75,11 +77,12 @@ add_custom_command(OUTPUT "libcurl-symbols.md" add_manual_pages(man_MANS) add_custom_target(curl-man ALL DEPENDS ${man_MANS}) if(NOT CURL_DISABLE_INSTALL) - unset(_src) + set(_src "") foreach(_f IN LISTS man_MANS) list(APPEND _src "${CMAKE_CURRENT_BINARY_DIR}/${_f}") endforeach() install(FILES ${_src} DESTINATION "${CMAKE_INSTALL_MANDIR}/man3") + unset(_src) endif() add_subdirectory(opts) diff --git a/docs/libcurl/opts/CMakeLists.txt b/docs/libcurl/opts/CMakeLists.txt index 99683c4062..052d269043 100644 --- a/docs/libcurl/opts/CMakeLists.txt +++ b/docs/libcurl/opts/CMakeLists.txt @@ -29,7 +29,7 @@ add_manual_pages(man_MANS) add_custom_target(curl-opts-man DEPENDS ${man_MANS}) add_dependencies(curl-man curl-opts-man) if(NOT CURL_DISABLE_INSTALL) - unset(_src) + set(_src "") foreach(_f IN LISTS man_MANS) list(APPEND _src "${CMAKE_CURRENT_BINARY_DIR}/${_f}") endforeach() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 0e40b2e192..86f229dde8 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -49,7 +49,7 @@ function(add_runtests _targetname _test_flags) # Skip walking through dependent targets before running tests in CI. # This avoids: GNU Make doing a slow re-evaluation of all targets and # skipping them, MSBuild doing a re-evaluation, and actually rebuilding them. - unset(_depends) + set(_depends "") if(NOT _targetname STREQUAL "test-ci") set(_depends "testdeps") endif() @@ -69,7 +69,7 @@ function(add_runtests _targetname _test_flags) endfunction() function(add_pytest _targetname _test_flags) - unset(_depends) + set(_depends "") if(NOT _targetname STREQUAL "pytest-ci") set(_depends "test-http-clients") endif()