cmake: respect cflags/libdirs of native pkg-config detections
In Find modules with native pkg-config detection (libgsasl, libidn2, libssh, libuv, nettle) use the C compiler flags returned by pkg-config. Also use the library paths, and return the pathless library names. Also: - add these library paths to `libcurl.pc`/`curl-config`. - fix libgsasl detection to use the detected header directory. FindGSS already did this before this patch. Fixes #14641 Closes #14652
This commit is contained in:
parent
4f09967a3c
commit
7c0b6eb3bd
@ -33,6 +33,8 @@
|
||||
# LIBGSASL_FOUND System has libgsasl
|
||||
# LIBGSASL_INCLUDE_DIRS The libgsasl include directories
|
||||
# LIBGSASL_LIBRARIES The libgsasl library names
|
||||
# LIBGSASL_LIBRARY_DIRS The libgsasl library directories
|
||||
# LIBGSASL_CFLAGS Required compiler flags
|
||||
# LIBGSASL_VERSION Version of libgsasl
|
||||
|
||||
if(CURL_USE_PKGCONFIG AND
|
||||
@ -43,7 +45,7 @@ if(CURL_USE_PKGCONFIG AND
|
||||
endif()
|
||||
|
||||
if(LIBGSASL_FOUND)
|
||||
set(LIBGSASL_LIBRARIES ${LIBGSASL_LINK_LIBRARIES})
|
||||
string(REPLACE ";" " " LIBGSASL_CFLAGS "${LIBGSASL_CFLAGS}")
|
||||
message(STATUS "Found Libgsasl (via pkg-config): ${LIBGSASL_INCLUDE_DIRS} (found version \"${LIBGSASL_VERSION}\")")
|
||||
else()
|
||||
find_path(LIBGSASL_INCLUDE_DIR NAMES "gsasl.h")
|
||||
|
||||
@ -33,6 +33,8 @@
|
||||
# LIBIDN2_FOUND System has libidn2
|
||||
# LIBIDN2_INCLUDE_DIRS The libidn2 include directories
|
||||
# LIBIDN2_LIBRARIES The libidn2 library names
|
||||
# LIBIDN2_LIBRARY_DIRS The libidn2 library directories
|
||||
# LIBIDN2_CFLAGS Required compiler flags
|
||||
# LIBIDN2_VERSION Version of libidn2
|
||||
|
||||
if(CURL_USE_PKGCONFIG AND
|
||||
@ -43,7 +45,7 @@ if(CURL_USE_PKGCONFIG AND
|
||||
endif()
|
||||
|
||||
if(LIBIDN2_FOUND)
|
||||
set(LIBIDN2_LIBRARIES ${LIBIDN2_LINK_LIBRARIES})
|
||||
string(REPLACE ";" " " LIBIDN2_CFLAGS "${LIBIDN2_CFLAGS}")
|
||||
message(STATUS "Found Libidn2 (via pkg-config): ${LIBIDN2_INCLUDE_DIRS} (found version \"${LIBIDN2_VERSION}\")")
|
||||
else()
|
||||
find_path(LIBIDN2_INCLUDE_DIR NAMES "idn2.h")
|
||||
|
||||
@ -33,6 +33,8 @@
|
||||
# LIBSSH_FOUND System has libssh
|
||||
# LIBSSH_INCLUDE_DIRS The libssh include directories
|
||||
# LIBSSH_LIBRARIES The libssh library names
|
||||
# LIBSSH_LIBRARY_DIRS The libssh library directories
|
||||
# LIBSSH_CFLAGS Required compiler flags
|
||||
# LIBSSH_VERSION Version of libssh
|
||||
|
||||
if(CURL_USE_PKGCONFIG AND
|
||||
@ -43,10 +45,7 @@ if(CURL_USE_PKGCONFIG AND
|
||||
endif()
|
||||
|
||||
if(LIBSSH_FOUND)
|
||||
if(NOT DEFINED LIBSSH_LINK_LIBRARIES)
|
||||
set(LIBSSH_LINK_LIBRARIES ${LIBSSH_LIBRARIES}) # Workaround for some systems (seen on Old Linux CI)
|
||||
endif()
|
||||
set(LIBSSH_LIBRARIES ${LIBSSH_LINK_LIBRARIES})
|
||||
string(REPLACE ";" " " LIBSSH_CFLAGS "${LIBSSH_CFLAGS}")
|
||||
message(STATUS "Found Libssh (via pkg-config): ${LIBSSH_INCLUDE_DIRS} (found version \"${LIBSSH_VERSION}\")")
|
||||
else()
|
||||
find_path(LIBSSH_INCLUDE_DIR NAMES "libssh/libssh.h")
|
||||
|
||||
@ -33,6 +33,8 @@
|
||||
# LIBUV_FOUND System has libuv
|
||||
# LIBUV_INCLUDE_DIRS The libuv include directories
|
||||
# LIBUV_LIBRARIES The libuv library names
|
||||
# LIBUV_LIBRARY_DIRS The libuv library directories
|
||||
# LIBUV_CFLAGS Required compiler flags
|
||||
# LIBUV_VERSION Version of libuv
|
||||
|
||||
if(CURL_USE_PKGCONFIG AND
|
||||
@ -43,7 +45,7 @@ if(CURL_USE_PKGCONFIG AND
|
||||
endif()
|
||||
|
||||
if(LIBUV_FOUND)
|
||||
set(LIBUV_LIBRARIES ${LIBUV_LINK_LIBRARIES})
|
||||
string(REPLACE ";" " " LIBUV_CFLAGS "${LIBUV_CFLAGS}")
|
||||
message(STATUS "Found Libuv (via pkg-config): ${LIBUV_INCLUDE_DIRS} (found version \"${LIBUV_VERSION}\")")
|
||||
else()
|
||||
find_path(LIBUV_INCLUDE_DIR NAMES "uv.h")
|
||||
|
||||
@ -33,6 +33,8 @@
|
||||
# NETTLE_FOUND System has nettle
|
||||
# NETTLE_INCLUDE_DIRS The nettle include directories
|
||||
# NETTLE_LIBRARIES The nettle library names
|
||||
# NETTLE_LIBRARY_DIRS The nettle library directories
|
||||
# NETTLE_CFLAGS Required compiler flags
|
||||
# NETTLE_VERSION Version of nettle
|
||||
|
||||
if(CURL_USE_PKGCONFIG AND
|
||||
@ -43,7 +45,7 @@ if(CURL_USE_PKGCONFIG AND
|
||||
endif()
|
||||
|
||||
if(NETTLE_FOUND)
|
||||
set(NETTLE_LIBRARIES ${NETTLE_LINK_LIBRARIES})
|
||||
string(REPLACE ";" " " NETTLE_CFLAGS "${NETTLE_CFLAGS}")
|
||||
message(STATUS "Found Nettle (via pkg-config): ${NETTLE_INCLUDE_DIRS} (found version \"${NETTLE_VERSION}\")")
|
||||
else()
|
||||
find_path(NETTLE_INCLUDE_DIR NAMES "nettle/sha2.h")
|
||||
|
||||
@ -219,6 +219,7 @@ option(CURL_USE_PKGCONFIG "Enable pkg-config to detect dependencies" ${_curl_use
|
||||
|
||||
# Initialize CURL_LIBS
|
||||
set(CURL_LIBS "")
|
||||
set(CURL_LIBDIRS "")
|
||||
set(LIBCURL_PC_REQUIRES_PRIVATE "")
|
||||
|
||||
if(ENABLE_ARES)
|
||||
@ -621,8 +622,13 @@ if(CURL_USE_GNUTLS)
|
||||
set(_ssl_enabled ON)
|
||||
set(USE_GNUTLS ON)
|
||||
list(APPEND CURL_LIBS ${GNUTLS_LIBRARIES} ${NETTLE_LIBRARIES})
|
||||
list(APPEND CURL_LIBDIRS ${NETTLE_LIBRARY_DIRS})
|
||||
list(APPEND LIBCURL_PC_REQUIRES_PRIVATE "gnutls" "nettle")
|
||||
include_directories(${GNUTLS_INCLUDE_DIRS} ${NETTLE_INCLUDE_DIRS})
|
||||
link_directories(${NETTLE_LIBRARY_DIRS})
|
||||
if(NETTLE_CFLAGS)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${NETTLE_CFLAGS}")
|
||||
endif()
|
||||
|
||||
if(CURL_DEFAULT_SSL_BACKEND AND CURL_DEFAULT_SSL_BACKEND STREQUAL "gnutls")
|
||||
set(_valid_default_ssl_backend TRUE)
|
||||
@ -999,8 +1005,13 @@ if(USE_LIBIDN2)
|
||||
find_package(Libidn2)
|
||||
if(LIBIDN2_FOUND)
|
||||
set(CURL_LIBS "${LIBIDN2_LIBRARIES};${CURL_LIBS}")
|
||||
list(APPEND CURL_LIBDIRS ${LIBIDN2_LIBRARY_DIRS})
|
||||
set(LIBCURL_PC_REQUIRES_PRIVATE "libidn2;${LIBCURL_PC_REQUIRES_PRIVATE}")
|
||||
include_directories(${LIBIDN2_INCLUDE_DIRS})
|
||||
link_directories(${LIBIDN2_LIBRARY_DIRS})
|
||||
if(LIBIDN2_CFLAGS)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBIDN2_CFLAGS}")
|
||||
endif()
|
||||
set(HAVE_IDN2_H 1)
|
||||
set(HAVE_LIBIDN2 1)
|
||||
endif()
|
||||
@ -1071,8 +1082,13 @@ if(NOT USE_LIBSSH2 AND CURL_USE_LIBSSH)
|
||||
find_package(Libssh REQUIRED)
|
||||
if(LIBSSH_FOUND)
|
||||
list(APPEND CURL_LIBS ${LIBSSH_LIBRARIES})
|
||||
list(APPEND CURL_LIBDIRS ${LIBSSH_LIBRARY_DIRS})
|
||||
list(APPEND LIBCURL_PC_REQUIRES_PRIVATE "libssh")
|
||||
include_directories(${LIBSSH_INCLUDE_DIRS})
|
||||
link_directories(${LIBSSH_LIBRARY_DIRS})
|
||||
if(LIBSSH_CFLAGS)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBSSH_CFLAGS}")
|
||||
endif()
|
||||
set(USE_LIBSSH ON)
|
||||
endif()
|
||||
endif()
|
||||
@ -1101,7 +1117,13 @@ if(CURL_USE_GSASL)
|
||||
find_package(Libgsasl REQUIRED)
|
||||
if(LIBGSASL_FOUND)
|
||||
list(APPEND CURL_LIBS ${LIBGSASL_LIBRARIES})
|
||||
list(APPEND CURL_LIBDIRS ${LIBGSASL_LIBRARY_DIRS})
|
||||
list(APPEND LIBCURL_PC_REQUIRES_PRIVATE "libgsasl")
|
||||
include_directories(${LIBGSASL_INCLUDE_DIRS})
|
||||
link_directories(${LIBGSASL_LIBRARY_DIRS})
|
||||
if(LIBGSASL_CFLAGS)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBGSASL_CFLAGS}")
|
||||
endif()
|
||||
set(USE_GSASL ON)
|
||||
endif()
|
||||
endif()
|
||||
@ -1175,8 +1197,13 @@ if(CURL_USE_LIBUV)
|
||||
find_package(Libuv REQUIRED)
|
||||
if(LIBUV_FOUND)
|
||||
list(APPEND CURL_LIBS ${LIBUV_LIBRARIES})
|
||||
list(APPEND CURL_LIBDIRS ${LIBUV_LIBRARY_DIRS})
|
||||
list(APPEND LIBCURL_PC_REQUIRES_PRIVATE "libuv")
|
||||
include_directories(${LIBUV_INCLUDE_DIRS})
|
||||
link_directories(${LIBUV_LIBRARY_DIRS})
|
||||
if(LIBUV_CFLAGS)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBUV_CFLAGS}")
|
||||
endif()
|
||||
set(USE_LIBUV ON)
|
||||
set(HAVE_UV_H ON)
|
||||
endif()
|
||||
@ -1936,6 +1963,10 @@ if(NOT CURL_DISABLE_INSTALL)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
foreach(_lib IN LISTS CURL_LIBDIRS)
|
||||
set(LIBCURL_PC_LIBS_PRIVATE "${LIBCURL_PC_LIBS_PRIVATE} -L${_lib}")
|
||||
endforeach()
|
||||
|
||||
foreach(_lib IN LISTS CMAKE_C_IMPLICIT_LINK_LIBRARIES CURL_LIBS)
|
||||
if(TARGET "${_lib}")
|
||||
set(_libname "${_lib}")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user