Skip to content

Commit

Permalink
CMake: for shared library builds, link curl to its dependencies with …
Browse files Browse the repository at this point in the history
…PRIVATE

The current PUBLIC visibility causes issues for downstream users.
Cf OSGeo/PROJ#3172 (comment)
  • Loading branch information
rouault committed Jul 8, 2022
1 parent 9153ba7 commit a98f552
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/CMakeLists.txt
Expand Up @@ -95,7 +95,14 @@ if(NOT BUILD_SHARED_LIBS)
set_target_properties(${LIB_NAME} PROPERTIES INTERFACE_COMPILE_DEFINITIONS CURL_STATICLIB)
endif()

target_link_libraries(${LIB_NAME} ${CURL_LIBS})
if(BUILD_SHARED_LIBS)
target_link_libraries(${LIB_NAME} PRIVATE ${CURL_LIBS})
else()
# It is arguable that the default PUBLIC visibility is correct for
# static builds, but it might be a convenient workaround for now,
# as correct dependency tracking for static build requires more effort.
target_link_libraries(${LIB_NAME} ${CURL_LIBS})
endif()

set_target_properties(${LIB_NAME} PROPERTIES
COMPILE_DEFINITIONS BUILDING_LIBCURL
Expand Down

0 comments on commit a98f552

Please sign in to comment.