Skip to content

Commit

Permalink
configure: do not echo most inherited LDFLAGS to config files
Browse files Browse the repository at this point in the history
`libcurl.pc` `Libs.private` (since 8.11.0, and in `Libs` before 7.20.0)
and `curl-config` `--static-libs` (since 7.17.1, and in `Libs` between
7.7.2-7.25.0). This included all flags inherited from the environment,
in addition to those coming from dependency detections.

To avoid spilling all linker flags inherited from the environment to
the libcurl config files, this patch omits them all, except `-L`, `-F`,
`--library-path=` and `-framework` options, which are still passed.
The rationale for the exceptions is that `LIBS` is passed as-is, and
`LDFLAGS`, `LIBS` are the canonical way to pass custom libs options
to a build. `LIBS` may not work without a matching custom libpath.

This brings autotools behaviour closer to cmake, and `curl-config`
closer to `libcurl.pc`.

Follow-up to 9f56bb6 curl#14681
Follow-up to 4c8adc8
Reported-by: Peter Marko
Fixes curl#15533
Closes curl#15550
  • Loading branch information
vszakats committed Nov 14, 2024
1 parent 2638570 commit e244d50
Show file tree
Hide file tree
Showing 14 changed files with 116 additions and 11 deletions.
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2054,7 +2054,6 @@ if(NOT CURL_DISABLE_INSTALL)
else()
set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
endif()
set(LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
# "a" (Linux) or "lib" (Windows)
string(REPLACE "." "" libext "${CMAKE_STATIC_LIBRARY_SUFFIX}")

Expand Down Expand Up @@ -2135,11 +2134,12 @@ if(NOT CURL_DISABLE_INSTALL)
if(LIBCURL_PC_LIBS_PRIVATE)
string(REPLACE ";" " " LIBCURL_PC_LIBS_PRIVATE "${LIBCURL_PC_LIBS_PRIVATE}")
endif()
set(LIBCURL_PC_LDFLAGS_PRIVATE "${CMAKE_SHARED_LINKER_FLAGS}")
if(_ldflags)
list(REMOVE_DUPLICATES _ldflags)
string(REPLACE ";" " " _ldflags "${_ldflags}")
set(LDFLAGS "${LDFLAGS} ${_ldflags}")
string(STRIP "${LDFLAGS}" LDFLAGS)
set(LIBCURL_PC_LDFLAGS_PRIVATE "${LIBCURL_PC_LDFLAGS_PRIVATE} ${_ldflags}")
string(STRIP "${LIBCURL_PC_LDFLAGS_PRIVATE}" LIBCURL_PC_LDFLAGS_PRIVATE)
endif()
set(LIBCURL_PC_CFLAGS_PRIVATE "-DCURL_STATICLIB")

Expand Down Expand Up @@ -2171,8 +2171,8 @@ if(NOT CURL_DISABLE_INSTALL)
# ENABLE_STATIC
# exec_prefix
# includedir
# LDFLAGS
# LIBCURL_PC_CFLAGS
# LIBCURL_PC_LDFLAGS_PRIVATE
# LIBCURL_PC_LIBS_PRIVATE
# libdir
# libext
Expand All @@ -2196,9 +2196,9 @@ if(NOT CURL_DISABLE_INSTALL)
# CURLVERSION
# exec_prefix
# includedir
# LDFLAGS
# LIBCURL_PC_CFLAGS
# LIBCURL_PC_CFLAGS_PRIVATE
# LIBCURL_PC_LDFLAGS_PRIVATE
# LIBCURL_PC_LIBS
# LIBCURL_PC_LIBS_PRIVATE
# LIBCURL_PC_REQUIRES
Expand Down
Loading

0 comments on commit e244d50

Please sign in to comment.