Skip to content

Missing dependencies on CMake exported target #1384

Open
@wnts

Description

@wnts

The cpprestsdk exported target created during the build process of the libraries
does not carry all required dependencies.
For one, the Boost and openSSL dependencies are not defined on the target.

Commit cb7ca74 seems to have broken this for openSSL, by always defaulting to pkg-config for searching OpenSSL.
The issue leading to that commit has been solved in the find_package module by kitware: https://gitlab.kitware.com/cmake/cmake/-/issues/16885

For Boost this seems to be disabled deliberately...

# FindBoost continually breaks imported targets whenever boost updates.
if(1)
target_include_directories(cpprestsdk_boost_internal INTERFACE "$<BUILD_INTERFACE:${Boost_INCLUDE_DIR}>")
set(_prev)
set(_libs)
foreach(_lib ${Boost_LIBRARIES})
if(_lib STREQUAL "optimized" OR _lib STREQUAL "debug")
else()
if(_prev STREQUAL "optimized")
list(APPEND _libs "$<$<NOT:$<CONFIG:Debug>>:${_lib}>")
elseif(_prev STREQUAL "debug")
list(APPEND _libs "$<$<CONFIG:Debug>:${_lib}>")
else()
list(APPEND _libs "${_lib}")
endif()
endif()
set(_prev "${_lib}")
endforeach()
if (NOT IOS OR NOT EXISTS "${PROJECT_SOURCE_DIR}/../Build_iOS/boost")
target_link_libraries(cpprestsdk_boost_internal INTERFACE "$<BUILD_INTERFACE:${_libs}>")
endif()
else()

Running git blame on this file shows that that comment on line 54 was made 3 years ago...
Is it still relevant?

I saw that at the time serious effort was put into using modern CMake, so it would be nice to actually be able to see that in action.

Also, because of the above, the simple CMakeLists.txt file listed on the Readme is not working.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions