cmake: tidy up string append and list prepend syntax

- `set(VAR "${VAR}<value>")` ->
  `string(APPEND VAR "<value>")`
  Available since CMake 3.4:
  https://cmake.org/cmake/help/latest/command/string.html#append

- `set(VAR "${VAR2}-or-<value>;${VAR}")` ->
  `set(VAR "${VAR2}-or-<value>" ${VAR})`

Closes #16144
This commit is contained in:
Viktor Szakats 2025-02-01 12:31:13 +01:00
parent fcd5c2baff
commit 3c128966ed
No known key found for this signature in database
GPG Key ID: B5ABD165E2AEF201
4 changed files with 66 additions and 70 deletions

View File

@ -274,6 +274,6 @@ endif()
if(_picky) if(_picky)
string(REPLACE ";" " " _picky "${_picky}") string(REPLACE ";" " " _picky "${_picky}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_picky}") string(APPEND CMAKE_C_FLAGS " ${_picky}")
message(STATUS "Picky compiler options: ${_picky}") message(STATUS "Picky compiler options: ${_picky}")
endif() endif()

View File

@ -61,12 +61,12 @@ if(NOT "$ENV{CURL_BUILDINFO}$ENV{CURL_CI}$ENV{CI}" STREQUAL "")
else() else()
set(_cache_var_type ":${_cache_var_type}") set(_cache_var_type ":${_cache_var_type}")
endif() endif()
set(_cmake_args "${_cmake_args} -D${_cache_var}${_cache_var_type}=\"${_cache_var_value}\"") string(APPEND _cmake_args " -D${_cache_var}${_cache_var_type}=\"${_cache_var_value}\"")
endif() endif()
endforeach() endforeach()
endif() endif()
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake;${CMAKE_MODULE_PATH}") set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake" ${CMAKE_MODULE_PATH})
include(Utilities) include(Utilities)
include(Macros) include(Macros)
include(CMakeDependentOption) include(CMakeDependentOption)
@ -105,49 +105,49 @@ endif()
set(_target_flags "") set(_target_flags "")
if(APPLE) if(APPLE)
set(_target_flags "${_target_flags} APPLE") string(APPEND _target_flags " APPLE")
endif() endif()
if(UNIX) if(UNIX)
set(_target_flags "${_target_flags} UNIX") string(APPEND _target_flags " UNIX")
endif() endif()
if(BSD) if(BSD)
set(_target_flags "${_target_flags} BSD") string(APPEND _target_flags " BSD")
endif() endif()
if(ANDROID) if(ANDROID)
set(_target_flags "${_target_flags} ANDROID-${ANDROID_PLATFORM_LEVEL}") string(APPEND _target_flags " ANDROID-${ANDROID_PLATFORM_LEVEL}")
endif() endif()
if(WIN32) if(WIN32)
set(_target_flags "${_target_flags} WIN32") string(APPEND _target_flags " WIN32")
endif() endif()
if(WINDOWS_STORE) if(WINDOWS_STORE)
set(_target_flags "${_target_flags} UWP") string(APPEND _target_flags " UWP")
endif() endif()
if(CYGWIN) if(CYGWIN)
set(_target_flags "${_target_flags} CYGWIN") string(APPEND _target_flags " CYGWIN")
endif() endif()
if(MSYS) if(MSYS)
set(_target_flags "${_target_flags} MSYS") string(APPEND _target_flags " MSYS")
endif() endif()
if(DOS) if(DOS)
set(_target_flags "${_target_flags} DOS") string(APPEND _target_flags " DOS")
endif() endif()
if(AMIGA) if(AMIGA)
set(_target_flags "${_target_flags} AMIGA") string(APPEND _target_flags " AMIGA")
endif() endif()
if(CMAKE_COMPILER_IS_GNUCC) if(CMAKE_COMPILER_IS_GNUCC)
set(_target_flags "${_target_flags} GCC") string(APPEND _target_flags " GCC")
endif() endif()
if(MINGW) if(MINGW)
set(_target_flags "${_target_flags} MINGW") string(APPEND _target_flags " MINGW")
endif() endif()
if(MSVC) if(MSVC)
set(_target_flags "${_target_flags} MSVC-${MSVC_VERSION}") string(APPEND _target_flags " MSVC-${MSVC_VERSION}")
endif() endif()
if(VCPKG_TOOLCHAIN) if(VCPKG_TOOLCHAIN)
set(_target_flags "${_target_flags} VCPKG") string(APPEND _target_flags " VCPKG")
endif() endif()
if(CMAKE_CROSSCOMPILING) if(CMAKE_CROSSCOMPILING)
set(_target_flags "${_target_flags} CROSS") string(APPEND _target_flags " CROSS")
endif() endif()
message(STATUS "CMake platform flags:${_target_flags}") message(STATUS "CMake platform flags:${_target_flags}")
@ -193,8 +193,8 @@ if(WIN32)
option(CURL_STATIC_CRT "Build libcurl with static CRT with MSVC (/MT)" OFF) option(CURL_STATIC_CRT "Build libcurl with static CRT with MSVC (/MT)" OFF)
if(CURL_STATIC_CRT AND MSVC) if(CURL_STATIC_CRT AND MSVC)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>") set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -MT") string(APPEND CMAKE_C_FLAGS_RELEASE " -MT")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -MTd") string(APPEND CMAKE_C_FLAGS_DEBUG " -MTd")
endif() endif()
option(ENABLE_UNICODE "Use the Unicode version of the Windows API functions" OFF) option(ENABLE_UNICODE "Use the Unicode version of the Windows API functions" OFF)
@ -256,7 +256,7 @@ endif()
include(PickyWarnings) include(PickyWarnings)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux") if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE") # Required for sendmmsg() string(APPEND CMAKE_C_FLAGS " -D_GNU_SOURCE") # Required for sendmmsg()
endif() endif()
option(ENABLE_DEBUG "Enable curl debug features (for developing curl itself)" OFF) option(ENABLE_DEBUG "Enable curl debug features (for developing curl itself)" OFF)
@ -350,7 +350,7 @@ if(ENABLE_ARES)
list(APPEND LIBCURL_PC_REQUIRES_PRIVATE ${CARES_PC_REQUIRES}) list(APPEND LIBCURL_PC_REQUIRES_PRIVATE ${CARES_PC_REQUIRES})
link_directories(${CARES_LIBRARY_DIRS}) link_directories(${CARES_LIBRARY_DIRS})
if(CARES_CFLAGS) if(CARES_CFLAGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CARES_CFLAGS}") string(APPEND CMAKE_C_FLAGS " ${CARES_CFLAGS}")
endif() endif()
endif() endif()
@ -542,7 +542,7 @@ endif()
# Disable warnings on Borland to avoid changing 3rd party code. # Disable warnings on Borland to avoid changing 3rd party code.
if(BORLAND) if(BORLAND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w-") string(APPEND CMAKE_C_FLAGS " -w-")
endif() endif()
# If we are on AIX, do the _ALL_SOURCE magic # If we are on AIX, do the _ALL_SOURCE magic
@ -619,7 +619,7 @@ elseif(AMIGA)
elseif(NOT WIN32 AND NOT APPLE) elseif(NOT WIN32 AND NOT APPLE)
check_library_exists("socket" "connect" "" HAVE_LIBSOCKET) check_library_exists("socket" "connect" "" HAVE_LIBSOCKET)
if(HAVE_LIBSOCKET) if(HAVE_LIBSOCKET)
set(CURL_LIBS "socket;${CURL_LIBS}") set(CURL_LIBS "socket" ${CURL_LIBS})
endif() endif()
endif() endif()
@ -793,7 +793,7 @@ if(CURL_USE_MBEDTLS)
include_directories(SYSTEM ${MBEDTLS_INCLUDE_DIRS}) include_directories(SYSTEM ${MBEDTLS_INCLUDE_DIRS})
link_directories(${MBEDTLS_LIBRARY_DIRS}) link_directories(${MBEDTLS_LIBRARY_DIRS})
if(MBEDTLS_CFLAGS) if(MBEDTLS_CFLAGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MBEDTLS_CFLAGS}") string(APPEND CMAKE_C_FLAGS " ${MBEDTLS_CFLAGS}")
endif() endif()
if(CURL_DEFAULT_SSL_BACKEND AND CURL_DEFAULT_SSL_BACKEND STREQUAL "mbedtls") if(CURL_DEFAULT_SSL_BACKEND AND CURL_DEFAULT_SSL_BACKEND STREQUAL "mbedtls")
@ -827,7 +827,7 @@ if(CURL_USE_WOLFSSL)
include_directories(SYSTEM ${WOLFSSL_INCLUDE_DIRS}) include_directories(SYSTEM ${WOLFSSL_INCLUDE_DIRS})
link_directories(${WOLFSSL_LIBRARY_DIRS}) link_directories(${WOLFSSL_LIBRARY_DIRS})
if(WOLFSSL_CFLAGS) if(WOLFSSL_CFLAGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WOLFSSL_CFLAGS}") string(APPEND CMAKE_C_FLAGS " ${WOLFSSL_CFLAGS}")
endif() endif()
if(CURL_DEFAULT_SSL_BACKEND AND CURL_DEFAULT_SSL_BACKEND STREQUAL "wolfssl") if(CURL_DEFAULT_SSL_BACKEND AND CURL_DEFAULT_SSL_BACKEND STREQUAL "wolfssl")
@ -856,7 +856,7 @@ if(CURL_USE_GNUTLS)
include_directories(SYSTEM ${GNUTLS_INCLUDE_DIRS} ${NETTLE_INCLUDE_DIRS}) include_directories(SYSTEM ${GNUTLS_INCLUDE_DIRS} ${NETTLE_INCLUDE_DIRS})
link_directories(${NETTLE_LIBRARY_DIRS}) link_directories(${NETTLE_LIBRARY_DIRS})
if(NETTLE_CFLAGS) if(NETTLE_CFLAGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${NETTLE_CFLAGS}") string(APPEND CMAKE_C_FLAGS " ${NETTLE_CFLAGS}")
endif() endif()
if(CURL_DEFAULT_SSL_BACKEND AND CURL_DEFAULT_SSL_BACKEND STREQUAL "gnutls") if(CURL_DEFAULT_SSL_BACKEND AND CURL_DEFAULT_SSL_BACKEND STREQUAL "gnutls")
@ -883,7 +883,7 @@ if(CURL_USE_RUSTLS)
include_directories(SYSTEM ${RUSTLS_INCLUDE_DIRS}) include_directories(SYSTEM ${RUSTLS_INCLUDE_DIRS})
link_directories(${RUSTLS_LIBRARY_DIRS}) link_directories(${RUSTLS_LIBRARY_DIRS})
if(RUSTLS_CFLAGS) if(RUSTLS_CFLAGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${RUSTLS_CFLAGS}") string(APPEND CMAKE_C_FLAGS " ${RUSTLS_CFLAGS}")
endif() endif()
if(CURL_DEFAULT_SSL_BACKEND AND CURL_DEFAULT_SSL_BACKEND STREQUAL "rustls") if(CURL_DEFAULT_SSL_BACKEND AND CURL_DEFAULT_SSL_BACKEND STREQUAL "rustls")
@ -919,7 +919,7 @@ if(BROTLI_FOUND)
include_directories(SYSTEM ${BROTLI_INCLUDE_DIRS}) include_directories(SYSTEM ${BROTLI_INCLUDE_DIRS})
link_directories(${BROTLI_LIBRARY_DIRS}) link_directories(${BROTLI_LIBRARY_DIRS})
if(BROTLI_CFLAGS) if(BROTLI_CFLAGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${BROTLI_CFLAGS}") string(APPEND CMAKE_C_FLAGS " ${BROTLI_CFLAGS}")
endif() endif()
endif() endif()
@ -934,7 +934,7 @@ if(ZSTD_FOUND)
include_directories(SYSTEM ${ZSTD_INCLUDE_DIRS}) include_directories(SYSTEM ${ZSTD_INCLUDE_DIRS})
link_directories(${ZSTD_LIBRARY_DIRS}) link_directories(${ZSTD_LIBRARY_DIRS})
if(ZSTD_CFLAGS) if(ZSTD_CFLAGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ZSTD_CFLAGS}") string(APPEND CMAKE_C_FLAGS " ${ZSTD_CFLAGS}")
endif() endif()
else() else()
message(WARNING "zstd v1.0.0 or newer is required, disabling zstd support.") message(WARNING "zstd v1.0.0 or newer is required, disabling zstd support.")
@ -1053,7 +1053,7 @@ if(USE_NGHTTP2)
include_directories(SYSTEM ${NGHTTP2_INCLUDE_DIRS}) include_directories(SYSTEM ${NGHTTP2_INCLUDE_DIRS})
link_directories(${NGHTTP2_LIBRARY_DIRS}) link_directories(${NGHTTP2_LIBRARY_DIRS})
if(NGHTTP2_CFLAGS) if(NGHTTP2_CFLAGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${NGHTTP2_CFLAGS}") string(APPEND CMAKE_C_FLAGS " ${NGHTTP2_CFLAGS}")
endif() endif()
else() else()
set(USE_NGHTTP2 OFF) set(USE_NGHTTP2 OFF)
@ -1085,7 +1085,7 @@ if(USE_NGTCP2)
include_directories(SYSTEM ${NGTCP2_INCLUDE_DIRS}) include_directories(SYSTEM ${NGTCP2_INCLUDE_DIRS})
link_directories(${NGTCP2_LIBRARY_DIRS}) link_directories(${NGTCP2_LIBRARY_DIRS})
if(NGTCP2_CFLAGS) if(NGTCP2_CFLAGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${NGTCP2_CFLAGS}") string(APPEND CMAKE_C_FLAGS " ${NGTCP2_CFLAGS}")
endif() endif()
find_package(NGHTTP3 REQUIRED) find_package(NGHTTP3 REQUIRED)
@ -1096,7 +1096,7 @@ if(USE_NGTCP2)
include_directories(SYSTEM ${NGHTTP3_INCLUDE_DIRS}) include_directories(SYSTEM ${NGHTTP3_INCLUDE_DIRS})
link_directories(${NGHTTP3_LIBRARY_DIRS}) link_directories(${NGHTTP3_LIBRARY_DIRS})
if(NGHTTP3_CFLAGS) if(NGHTTP3_CFLAGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${NGHTTP3_CFLAGS}") string(APPEND CMAKE_C_FLAGS " ${NGHTTP3_CFLAGS}")
endif() endif()
endif() endif()
@ -1116,7 +1116,7 @@ if(USE_QUICHE)
include_directories(SYSTEM ${QUICHE_INCLUDE_DIRS}) include_directories(SYSTEM ${QUICHE_INCLUDE_DIRS})
link_directories(${QUICHE_LIBRARY_DIRS}) link_directories(${QUICHE_LIBRARY_DIRS})
if(QUICHE_CFLAGS) if(QUICHE_CFLAGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${QUICHE_CFLAGS}") string(APPEND CMAKE_C_FLAGS " ${QUICHE_CFLAGS}")
endif() endif()
if(NOT DEFINED HAVE_QUICHE_CONN_SET_QLOG_FD) if(NOT DEFINED HAVE_QUICHE_CONN_SET_QLOG_FD)
cmake_push_check_state() cmake_push_check_state()
@ -1145,7 +1145,7 @@ if(USE_MSH3)
include_directories(SYSTEM ${MSH3_INCLUDE_DIRS}) include_directories(SYSTEM ${MSH3_INCLUDE_DIRS})
link_directories(${MSH3_LIBRARY_DIRS}) link_directories(${MSH3_LIBRARY_DIRS})
if(MSH3_CFLAGS) if(MSH3_CFLAGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MSH3_CFLAGS}") string(APPEND CMAKE_C_FLAGS " ${MSH3_CFLAGS}")
endif() endif()
endif() endif()
@ -1191,15 +1191,15 @@ if(NOT CURL_DISABLE_LDAP)
find_package(LDAP) find_package(LDAP)
if(LDAP_FOUND) if(LDAP_FOUND)
set(HAVE_LBER_H 1) set(HAVE_LBER_H 1)
set(CURL_LIBS "${LDAP_LIBRARIES};${CURL_LIBS}") set(CURL_LIBS ${LDAP_LIBRARIES} ${CURL_LIBS})
list(APPEND CURL_LIBDIRS ${LDAP_LIBRARY_DIRS}) list(APPEND CURL_LIBDIRS ${LDAP_LIBRARY_DIRS})
if(LDAP_PC_REQUIRES) if(LDAP_PC_REQUIRES)
set(LIBCURL_PC_REQUIRES_PRIVATE "${LDAP_PC_REQUIRES};${LIBCURL_PC_REQUIRES_PRIVATE}") set(LIBCURL_PC_REQUIRES_PRIVATE ${LDAP_PC_REQUIRES} ${LIBCURL_PC_REQUIRES_PRIVATE})
endif() endif()
include_directories(SYSTEM ${LDAP_INCLUDE_DIRS}) include_directories(SYSTEM ${LDAP_INCLUDE_DIRS})
link_directories(${LDAP_LIBRARY_DIRS}) link_directories(${LDAP_LIBRARY_DIRS})
if(LDAP_CFLAGS) if(LDAP_CFLAGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LDAP_CFLAGS}") string(APPEND CMAKE_C_FLAGS " ${LDAP_CFLAGS}")
endif() endif()
# LDAP feature checks # LDAP feature checks
@ -1269,13 +1269,13 @@ set(HAVE_LIBIDN2 OFF)
if(USE_LIBIDN2 AND NOT USE_APPLE_IDN AND NOT USE_WIN32_IDN) if(USE_LIBIDN2 AND NOT USE_APPLE_IDN AND NOT USE_WIN32_IDN)
find_package(Libidn2) find_package(Libidn2)
if(LIBIDN2_FOUND) if(LIBIDN2_FOUND)
set(CURL_LIBS "${LIBIDN2_LIBRARIES};${CURL_LIBS}") set(CURL_LIBS ${LIBIDN2_LIBRARIES} ${CURL_LIBS})
list(APPEND CURL_LIBDIRS ${LIBIDN2_LIBRARY_DIRS}) list(APPEND CURL_LIBDIRS ${LIBIDN2_LIBRARY_DIRS})
set(LIBCURL_PC_REQUIRES_PRIVATE "${LIBIDN2_PC_REQUIRES};${LIBCURL_PC_REQUIRES_PRIVATE}") set(LIBCURL_PC_REQUIRES_PRIVATE ${LIBIDN2_PC_REQUIRES} ${LIBCURL_PC_REQUIRES_PRIVATE})
include_directories(SYSTEM ${LIBIDN2_INCLUDE_DIRS}) include_directories(SYSTEM ${LIBIDN2_INCLUDE_DIRS})
link_directories(${LIBIDN2_LIBRARY_DIRS}) link_directories(${LIBIDN2_LIBRARY_DIRS})
if(LIBIDN2_CFLAGS) if(LIBIDN2_CFLAGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBIDN2_CFLAGS}") string(APPEND CMAKE_C_FLAGS " ${LIBIDN2_CFLAGS}")
endif() endif()
set(HAVE_IDN2_H 1) set(HAVE_IDN2_H 1)
set(HAVE_LIBIDN2 1) set(HAVE_LIBIDN2 1)
@ -1295,7 +1295,7 @@ if(CURL_USE_LIBPSL)
include_directories(SYSTEM ${LIBPSL_INCLUDE_DIRS}) include_directories(SYSTEM ${LIBPSL_INCLUDE_DIRS})
link_directories(${LIBPSL_LIBRARY_DIRS}) link_directories(${LIBPSL_LIBRARY_DIRS})
if(LIBPSL_CFLAGS) if(LIBPSL_CFLAGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBPSL_CFLAGS}") string(APPEND CMAKE_C_FLAGS " ${LIBPSL_CFLAGS}")
endif() endif()
set(USE_LIBPSL ON) set(USE_LIBPSL ON)
endif() endif()
@ -1314,7 +1314,7 @@ if(CURL_USE_LIBSSH2)
include_directories(SYSTEM ${LIBSSH2_INCLUDE_DIRS}) include_directories(SYSTEM ${LIBSSH2_INCLUDE_DIRS})
link_directories(${LIBSSH2_LIBRARY_DIRS}) link_directories(${LIBSSH2_LIBRARY_DIRS})
if(LIBSSH2_CFLAGS) if(LIBSSH2_CFLAGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBSSH2_CFLAGS}") string(APPEND CMAKE_C_FLAGS " ${LIBSSH2_CFLAGS}")
endif() endif()
set(USE_LIBSSH2 ON) set(USE_LIBSSH2 ON)
endif() endif()
@ -1331,7 +1331,7 @@ if(NOT USE_LIBSSH2 AND CURL_USE_LIBSSH)
include_directories(SYSTEM ${LIBSSH_INCLUDE_DIRS}) include_directories(SYSTEM ${LIBSSH_INCLUDE_DIRS})
link_directories(${LIBSSH_LIBRARY_DIRS}) link_directories(${LIBSSH_LIBRARY_DIRS})
if(LIBSSH_CFLAGS) if(LIBSSH_CFLAGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBSSH_CFLAGS}") string(APPEND CMAKE_C_FLAGS " ${LIBSSH_CFLAGS}")
endif() endif()
set(USE_LIBSSH ON) set(USE_LIBSSH ON)
endif() endif()
@ -1363,7 +1363,7 @@ if(CURL_USE_GSASL)
include_directories(SYSTEM ${LIBGSASL_INCLUDE_DIRS}) include_directories(SYSTEM ${LIBGSASL_INCLUDE_DIRS})
link_directories(${LIBGSASL_LIBRARY_DIRS}) link_directories(${LIBGSASL_LIBRARY_DIRS})
if(LIBGSASL_CFLAGS) if(LIBGSASL_CFLAGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBGSASL_CFLAGS}") string(APPEND CMAKE_C_FLAGS " ${LIBGSASL_CFLAGS}")
endif() endif()
set(USE_GSASL ON) set(USE_GSASL ON)
endif() endif()
@ -1382,7 +1382,7 @@ if(CURL_USE_GSSAPI)
include_directories(SYSTEM ${GSS_INCLUDE_DIRS}) include_directories(SYSTEM ${GSS_INCLUDE_DIRS})
link_directories(${GSS_LIBRARY_DIRS}) link_directories(${GSS_LIBRARY_DIRS})
if(GSS_CFLAGS) if(GSS_CFLAGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GSS_CFLAGS}") string(APPEND CMAKE_C_FLAGS " ${GSS_CFLAGS}")
endif() endif()
if(GSS_FLAVOUR STREQUAL "GNU") if(GSS_FLAVOUR STREQUAL "GNU")
@ -1408,7 +1408,7 @@ if(CURL_USE_GSSAPI)
endif() endif()
if(NOT DEFINED HAVE_GSS_C_NT_HOSTBASED_SERVICE) if(NOT DEFINED HAVE_GSS_C_NT_HOSTBASED_SERVICE)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${GSS_CFLAGS}") string(APPEND CMAKE_REQUIRED_FLAGS " ${GSS_CFLAGS}")
list(APPEND CMAKE_REQUIRED_LIBRARIES ${GSS_LIBRARIES}) list(APPEND CMAKE_REQUIRED_LIBRARIES ${GSS_LIBRARIES})
curl_required_libpaths("${GSS_LIBRARY_DIRS}") curl_required_libpaths("${GSS_LIBRARY_DIRS}")
check_symbol_exists("GSS_C_NT_HOSTBASED_SERVICE" "${_include_list}" HAVE_GSS_C_NT_HOSTBASED_SERVICE) check_symbol_exists("GSS_C_NT_HOSTBASED_SERVICE" "${_include_list}" HAVE_GSS_C_NT_HOSTBASED_SERVICE)
@ -1438,7 +1438,7 @@ if(CURL_USE_LIBUV)
include_directories(SYSTEM ${LIBUV_INCLUDE_DIRS}) include_directories(SYSTEM ${LIBUV_INCLUDE_DIRS})
link_directories(${LIBUV_LIBRARY_DIRS}) link_directories(${LIBUV_LIBRARY_DIRS})
if(LIBUV_CFLAGS) if(LIBUV_CFLAGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBUV_CFLAGS}") string(APPEND CMAKE_C_FLAGS " ${LIBUV_CFLAGS}")
endif() endif()
set(USE_LIBUV ON) set(USE_LIBUV ON)
set(HAVE_UV_H ON) set(HAVE_UV_H ON)
@ -1453,7 +1453,7 @@ if(USE_LIBRTMP)
include_directories(SYSTEM ${LIBRTMP_INCLUDE_DIRS}) include_directories(SYSTEM ${LIBRTMP_INCLUDE_DIRS})
link_directories(${LIBRTMP_LIBRARY_DIRS}) link_directories(${LIBRTMP_LIBRARY_DIRS})
if(LIBRTMP_CFLAGS) if(LIBRTMP_CFLAGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBRTMP_CFLAGS}") string(APPEND CMAKE_C_FLAGS " ${LIBRTMP_CFLAGS}")
endif() endif()
endif() endif()
@ -1650,7 +1650,7 @@ foreach(_variable IN ITEMS
HAVE_UNISTD_H HAVE_UNISTD_H
) )
if(${_variable}) if(${_variable})
set(CURL_TEST_DEFINES "${CURL_TEST_DEFINES} -D${_variable}") string(APPEND CURL_TEST_DEFINES " -D${_variable}")
endif() endif()
endforeach() endforeach()
@ -1911,7 +1911,7 @@ if(CMAKE_COMPILER_IS_GNUCC AND APPLE)
# The Mac version of GCC warns about use of long double. Disable it. # The Mac version of GCC warns about use of long double. Disable it.
get_source_file_property(_mprintf_compile_flags "mprintf.c" COMPILE_FLAGS) get_source_file_property(_mprintf_compile_flags "mprintf.c" COMPILE_FLAGS)
if(_mprintf_compile_flags) if(_mprintf_compile_flags)
set(_mprintf_compile_flags "${_mprintf_compile_flags} -Wno-long-double") string(APPEND _mprintf_compile_flags " -Wno-long-double")
else() else()
set(_mprintf_compile_flags "-Wno-long-double") set(_mprintf_compile_flags "-Wno-long-double")
endif() endif()
@ -1936,7 +1936,7 @@ if(WIN32)
endif() endif()
# Use the manifest embedded in the Windows Resource # Use the manifest embedded in the Windows Resource
set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} -DCURL_EMBED_MANIFEST") string(APPEND CMAKE_RC_FLAGS " -DCURL_EMBED_MANIFEST")
# We use crypto functions that are not available for UWP apps # We use crypto functions that are not available for UWP apps
if(NOT WINDOWS_STORE) if(NOT WINDOWS_STORE)
@ -1951,26 +1951,25 @@ endif()
if(MSVC) if(MSVC)
# Disable default manifest added by CMake # Disable default manifest added by CMake
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -MANIFEST:NO") string(APPEND CMAKE_EXE_LINKER_FLAGS " -MANIFEST:NO")
if(CMAKE_C_FLAGS MATCHES "[/-]W[0-4]") if(CMAKE_C_FLAGS MATCHES "[/-]W[0-4]")
string(REGEX REPLACE "[/-]W[0-4]" "-W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") string(REGEX REPLACE "[/-]W[0-4]" "-W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
else() else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -W4") string(APPEND CMAKE_C_FLAGS " -W4")
endif() endif()
# Use multithreaded compilation on VS2008+ # Use multithreaded compilation on VS2008+
if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND MSVC_VERSION GREATER_EQUAL 1500) if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND MSVC_VERSION GREATER_EQUAL 1500)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -MP") string(APPEND CMAKE_C_FLAGS " -MP")
endif() endif()
endif() endif()
if(CURL_WERROR) if(CURL_WERROR)
if(MSVC) if(MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -WX") string(APPEND CMAKE_C_FLAGS " -WX")
else() else()
# This assumes clang or gcc style options string(APPEND CMAKE_C_FLAGS " -Werror") # This assumes clang or gcc style options
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
endif() endif()
endif() endif()
@ -2244,15 +2243,15 @@ if(NOT CURL_DISABLE_INSTALL)
set(_sys_libdirs "") set(_sys_libdirs "")
foreach(_libdir IN LISTS CMAKE_SYSTEM_PREFIX_PATH) foreach(_libdir IN LISTS CMAKE_SYSTEM_PREFIX_PATH)
if(_libdir MATCHES "/$") if(_libdir MATCHES "/$")
set(_libdir "${_libdir}lib") string(APPEND _libdir "lib")
else() else()
set(_libdir "${_libdir}/lib") string(APPEND _libdir "/lib")
endif() endif()
if(IS_DIRECTORY "${_libdir}") if(IS_DIRECTORY "${_libdir}")
list(APPEND _sys_libdirs "${_libdir}") list(APPEND _sys_libdirs "${_libdir}")
endif() endif()
if(DEFINED CMAKE_LIBRARY_ARCHITECTURE) if(DEFINED CMAKE_LIBRARY_ARCHITECTURE)
set(_libdir "${_libdir}/${CMAKE_LIBRARY_ARCHITECTURE}") string(APPEND _libdir "/${CMAKE_LIBRARY_ARCHITECTURE}")
if(IS_DIRECTORY "${_libdir}") if(IS_DIRECTORY "${_libdir}")
list(APPEND _sys_libdirs "${_libdir}") list(APPEND _sys_libdirs "${_libdir}")
endif() endif()

View File

@ -41,10 +41,10 @@ add_subdirectory(certs EXCLUDE_FROM_ALL)
function(curl_add_runtests _targetname _test_flags) function(curl_add_runtests _targetname _test_flags)
if(CURL_TEST_BUNDLES) if(CURL_TEST_BUNDLES)
set(_test_flags "${_test_flags} -bundle") string(APPEND _test_flags " -bundle")
endif() endif()
if(NOT BUILD_LIBCURL_DOCS) if(NOT BUILD_LIBCURL_DOCS)
set(_test_flags "${_test_flags} !documentation") string(APPEND _test_flags " !documentation")
endif() endif()
# Skip walking through dependent targets before running tests in CI. # Skip walking through dependent targets before running tests in CI.
# This avoids: GNU Make doing a slow re-evaluation of all targets and # This avoids: GNU Make doing a slow re-evaluation of all targets and
@ -85,12 +85,12 @@ endfunction()
if(MSVC OR CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") if(MSVC OR CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
set(CURL_CPP "\"${CMAKE_C_COMPILER}\" -E") set(CURL_CPP "\"${CMAKE_C_COMPILER}\" -E")
if(APPLE AND CMAKE_OSX_SYSROOT) if(APPLE AND CMAKE_OSX_SYSROOT)
set(CURL_CPP "${CURL_CPP} -isysroot ${CMAKE_OSX_SYSROOT}") string(APPEND CURL_CPP " -isysroot ${CMAKE_OSX_SYSROOT}")
endif() endif()
# Add header directories, like autotools builds do. # Add header directories, like autotools builds do.
get_property(_include_dirs TARGET ${LIB_SELECTED} PROPERTY INCLUDE_DIRECTORIES) get_property(_include_dirs TARGET ${LIB_SELECTED} PROPERTY INCLUDE_DIRECTORIES)
foreach(_include_dir IN LISTS _include_dirs) foreach(_include_dir IN LISTS _include_dirs)
set(CURL_CPP "${CURL_CPP} -I${_include_dir}") string(APPEND CURL_CPP " -I${_include_dir}")
endforeach() endforeach()
else() else()
set(CURL_CPP "cpp") set(CURL_CPP "cpp")

View File

@ -670,15 +670,11 @@ sub checksystemfeatures {
$feature{"alt-svc"} = $feat =~ /alt-svc/i; $feature{"alt-svc"} = $feat =~ /alt-svc/i;
# HSTS support # HSTS support
$feature{"HSTS"} = $feat =~ /HSTS/i; $feature{"HSTS"} = $feat =~ /HSTS/i;
$feature{"asyn-rr"} = $feat =~ /asyn-rr/;
if($feat =~ /AsynchDNS/i) { if($feat =~ /AsynchDNS/i) {
if(!$feature{"c-ares"} || $feature{"asyn-rr"}) { if(!$feature{"c-ares"}) {
# this means threaded resolver # this means threaded resolver
$feature{"threaded-resolver"} = 1; $feature{"threaded-resolver"} = 1;
$resolver="threaded"; $resolver="threaded";
# does not count as "real" c-ares
$feature{"c-ares"} = 0;
} }
} }
# http2 enabled # http2 enabled
@ -702,6 +698,7 @@ sub checksystemfeatures {
# Thread-safe init # Thread-safe init
$feature{"threadsafe"} = $feat =~ /threadsafe/i; $feature{"threadsafe"} = $feat =~ /threadsafe/i;
$feature{"HTTPSRR"} = $feat =~ /HTTPSRR/; $feature{"HTTPSRR"} = $feat =~ /HTTPSRR/;
$feature{"asyn-rr"} = $feat =~ /asyn-rr/;
} }
# #
# Test harness currently uses a non-stunnel server in order to # Test harness currently uses a non-stunnel server in order to