Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
264 changes: 263 additions & 1 deletion .github/workflows/ci.yml

Large diffs are not rendered by default.

32 changes: 29 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ foreach (BOOST_COROSIO_DEPENDENCY ${BOOST_COROSIO_DEPENDENCIES})
endif ()
endforeach ()

# Include asio and filesystem which are needed by capy's tests
# Include asio and filesystem which are needed by corosio's tests
if (BOOST_COROSIO_BUILD_TESTS)
list(APPEND BOOST_COROSIO_INCLUDE_LIBRARIES asio filesystem)
endif ()
Comment on lines +67 to 70
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, locate and read the CMakeLists.txt file
find . -name "CMakeLists.txt" -type f | head -5

Repository: cppalliance/corosio

Length of output: 228


🏁 Script executed:

# Read the CMakeLists.txt file with line numbers
cat -n CMakeLists.txt | head -250

Repository: cppalliance/corosio

Length of output: 12110


🌐 Web query:

Boost CMake find_package asio filesystem components official documentation

💡 Result:

CMake find_package(Boost ...) for Asio and Filesystem (official docs)

Boost.Filesystem (compiled library)

Use a Boost component and link the imported target:

find_package(Boost REQUIRED COMPONENTS filesystem)
target_link_libraries(my_target PRIVATE Boost::filesystem)

CMake provides Boost::<component> imported targets, and it also auto-adds implicit deps (e.g., Boost::filesystemBoost::system) when using these targets. [1]

Boost.Asio (header-only by default)

Asio is header-only unless you opt into separate compilation. [2] So you typically don’t request an asio component; just use Boost headers:

find_package(Boost REQUIRED)          # or: find_package(Boost REQUIRED COMPONENTS headers)
target_link_libraries(my_target PRIVATE Boost::headers)  # alias of Boost::boost

If your code (or other Boost libs you use) requires Boost.System: Boost.System has been header-only since Boost 1.69 (a compatibility “stub” library may still exist). [3]


Primary references

  • CMake FindBoost module (components + Boost::... targets, implicit deps): [1]
  • Boost.Asio “Using” docs (header-only by default; optional separate compilation): [2]
  • Boost Getting Started (Boost.System header-only since 1.69): [3]

Sources: [1] https://cmake.org/cmake/help/latest/module/FindBoost.html | [2] https://www.boost.org/doc/libs/latest/doc/html/boost_asio/using.html | [3] https://www.boost.org/doc/libs/boost_1_81_0/more/getting_started/unix-variants.html


Filesystem and Asio must be included in find_package when tests are enabled

Lines 68-70 add asio and filesystem to BOOST_COROSIO_INCLUDE_LIBRARIES when tests are enabled, but the fallback find_package(Boost REQUIRED COMPONENTS capy url system) at line 111 does not request these components. The subsequent fallback mechanism (lines 112-116) aliases missing targets to Boost::headers, which is incorrect for Boost::filesystem—a compiled library that requires proper linkage separate from headers alone.

Proposed fix
+        set(BOOST_COROSIO_FIND_COMPONENTS capy url system)
+        if (BOOST_COROSIO_BUILD_TESTS)
+            list(APPEND BOOST_COROSIO_FIND_COMPONENTS asio filesystem)
+        endif ()
-        find_package(Boost REQUIRED COMPONENTS capy url system)
+        find_package(Boost REQUIRED COMPONENTS ${BOOST_COROSIO_FIND_COMPONENTS})
🤖 Prompt for AI Agents
In `@CMakeLists.txt` around lines 67 - 70, The fallback find_package call doesn't
request filesystem or asio components when BOOST_COROSIO_BUILD_TESTS is true,
which leads to incorrect aliasing of compiled libs to Boost::headers; update the
CMake logic so that when BOOST_COROSIO_BUILD_TESTS is enabled you add
"filesystem" and "asio" to the list of Boost components passed into
find_package(Boost REQUIRED COMPONENTS ...) (the variable used to build that
components list, e.g. BOOST_COROSIO_INCLUDE_LIBRARIES), and remove/adjust the
fallback aliasing that maps Boost::filesystem/Boost::asio to Boost::headers so
that Boost::filesystem and Boost::asio are discovered as proper linkable targets
and can be linked normally.

Expand Down Expand Up @@ -197,6 +197,13 @@ boost_corosio_setup_properties(boost_corosio)
#-------------------------------------------------
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
find_package(WolfSSL)
# MinGW's linker is single-pass and order-sensitive; system libs must follow
# the static libraries that reference them. Add as interface dependencies so
# CMake's dependency ordering places them after WolfSSL in the link command.
if (MINGW AND TARGET WolfSSL::WolfSSL)
set_property(TARGET WolfSSL::WolfSSL APPEND PROPERTY
INTERFACE_LINK_LIBRARIES ws2_32 crypt32)
endif()
if (WolfSSL_FOUND)
file(GLOB_RECURSE BOOST_COROSIO_WOLFSSL_HEADERS CONFIGURE_DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/include/boost/corosio/wolfssl/*.hpp")
Expand All @@ -209,7 +216,13 @@ if (WolfSSL_FOUND)
add_library(Boost::corosio_wolfssl ALIAS boost_corosio_wolfssl)
boost_corosio_setup_properties(boost_corosio_wolfssl)
target_link_libraries(boost_corosio_wolfssl PUBLIC boost_corosio)
target_link_libraries(boost_corosio_wolfssl PRIVATE WolfSSL::WolfSSL)
# PUBLIC ensures WolfSSL is linked into final executables (static lib deps don't embed)
target_link_libraries(boost_corosio_wolfssl PUBLIC WolfSSL::WolfSSL)
# WolfSSL on Windows needs crypt32 for certificate store access.
# For MinGW, this is handled via WolfSSL::WolfSSL's interface deps (link order matters).
if (WIN32 AND NOT MINGW)
target_link_libraries(boost_corosio_wolfssl PUBLIC crypt32)
endif ()
target_compile_definitions(boost_corosio_wolfssl PUBLIC BOOST_COROSIO_HAS_WOLFSSL)
endif ()

Expand All @@ -219,6 +232,13 @@ endif ()
#
#-------------------------------------------------
find_package(OpenSSL)
# MinGW's linker is single-pass and order-sensitive; system libs must follow
# the static libraries that reference them. Add as interface dependencies so
# CMake's dependency ordering places them after OpenSSL in the link command.
if (MINGW AND TARGET OpenSSL::Crypto)
set_property(TARGET OpenSSL::Crypto APPEND PROPERTY
INTERFACE_LINK_LIBRARIES ws2_32 crypt32)
endif()
if (OpenSSL_FOUND)
file(GLOB_RECURSE BOOST_COROSIO_OPENSSL_HEADERS CONFIGURE_DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/include/boost/corosio/openssl/*.hpp")
Expand All @@ -231,7 +251,13 @@ if (OpenSSL_FOUND)
add_library(Boost::corosio_openssl ALIAS boost_corosio_openssl)
boost_corosio_setup_properties(boost_corosio_openssl)
target_link_libraries(boost_corosio_openssl PUBLIC boost_corosio)
target_link_libraries(boost_corosio_openssl PRIVATE OpenSSL::SSL OpenSSL::Crypto)
# PUBLIC ensures OpenSSL is linked into final executables (static lib deps don't embed)
target_link_libraries(boost_corosio_openssl PUBLIC OpenSSL::SSL OpenSSL::Crypto)
# OpenSSL on Windows needs ws2_32 and crypt32 for socket and cert APIs.
# For MinGW, this is handled via OpenSSL::Crypto's interface deps (link order matters).
if (WIN32 AND NOT MINGW)
target_link_libraries(boost_corosio_openssl PUBLIC ws2_32 crypt32)
endif ()
target_compile_definitions(boost_corosio_openssl PUBLIC BOOST_COROSIO_HAS_OPENSSL)
endif ()

Expand Down
22 changes: 21 additions & 1 deletion build/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ project boost/corosio

# System libraries
lib ws2_32 ;
lib crypt32 ;

alias corosio_sources : [ glob-tree-ex src/corosio/src : *.cpp ] ;

Expand All @@ -52,6 +53,22 @@ lib boost_corosio
<include>../include
;

# OpenSSL
using openssl ;

alias corosio_openssl_sources : [ glob-tree-ex src/openssl/src : *.cpp ] ;

lib boost_corosio_openssl
: corosio_openssl_sources
: requirements
<library>/boost/corosio//boost_corosio
<include>../src/corosio
[ ac.check-library /openssl//ssl : <library>/openssl//ssl <library>/openssl//crypto : <build>no ]
: usage-requirements
<library>/boost/corosio//boost_corosio
<define>BOOST_COROSIO_HAS_OPENSSL
;

# WolfSSL
using wolfssl ;

Expand All @@ -61,10 +78,13 @@ lib boost_corosio_wolfssl
: corosio_wolfssl_sources
: requirements
<library>/boost/corosio//boost_corosio
<include>../src/corosio
[ ac.check-library /wolfssl//wolfssl : <library>/wolfssl//wolfssl : <build>no ]
<target-os>windows:<library>crypt32
: usage-requirements
<library>/boost/corosio//boost_corosio
<define>BOOST_COROSIO_HAS_WOLFSSL
<target-os>windows:<library>crypt32
;

boost-install boost_corosio boost_corosio_wolfssl ;
boost-install boost_corosio boost_corosio_openssl boost_corosio_wolfssl ;
12 changes: 10 additions & 2 deletions cmake/FindWolfSSL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,16 @@
# Provides imported targets:
# WolfSSL::WolfSSL

find_path(WolfSSL_INCLUDE_DIR "wolfssl/ssl.h")
find_library(WolfSSL_LIBRARY NAMES "wolfssl" "libwolfssl")
find_path(WolfSSL_INCLUDE_DIR "wolfssl/ssl.h"
HINTS
"$ENV{WOLFSSL_INCLUDE}"
"$ENV{WOLFSSL_ROOT}/include"
)
find_library(WolfSSL_LIBRARY NAMES "wolfssl" "libwolfssl"
HINTS
"$ENV{WOLFSSL_LIBRARY_PATH}"
"$ENV{WOLFSSL_ROOT}/lib"
)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(WolfSSL
Expand Down
Loading
Loading