99
1010# corosio_resolve_deps()
1111#
12- # Resolve all build dependencies: sibling Boost libraries when inside a
13- # boost tree, Capy via find_package / FetchContent, and Threads.
12+ # Resolve build dependencies: sibling Boost libraries when inside a
13+ # boost tree, and Threads. Capy (Boost::capy) must be provided by
14+ # the consumer — CMake resolves the target reference at generation
15+ # time, so declaration order does not matter.
1416#
1517# Must be a macro so find_package results propagate to the caller's scope.
1618macro (corosio_resolve_deps )
@@ -29,55 +31,6 @@ macro(corosio_resolve_deps)
2931 unset (CMAKE_FOLDER)
3032 endif ()
3133
32- # Capy: prefer already-available target, then find_package, then FetchContent
33- if (NOT TARGET Boost::capy)
34- find_package (boost_capy QUIET )
35- endif ()
36-
37- if (NOT TARGET Boost::capy)
38- include (FetchContent )
39-
40- # Match capy branch to corosio's current branch when possible
41- if (NOT DEFINED CACHE{BOOST_COROSIO_CAPY_TAG})
42- execute_process (
43- COMMAND git rev-parse --abbrev-ref HEAD
44- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
45- OUTPUT_VARIABLE _corosio_branch
46- OUTPUT_STRIP_TRAILING_WHITESPACE
47- ERROR_QUIET
48- RESULT_VARIABLE _git_result )
49- if (_git_result EQUAL 0 AND _corosio_branch)
50- execute_process (
51- COMMAND git ls-remote --heads
52- https://github.com/cppalliance/capy.git
53- ${_corosio_branch}
54- OUTPUT_VARIABLE _capy_has_branch
55- OUTPUT_STRIP_TRAILING_WHITESPACE
56- ERROR_QUIET
57- TIMEOUT 30 )
58- if (_capy_has_branch)
59- set (_default_capy_tag "${_corosio_branch} " )
60- endif ()
61- endif ()
62- if (NOT DEFINED _default_capy_tag)
63- set (_default_capy_tag "develop" )
64- endif ()
65- endif ()
66- set (BOOST_COROSIO_CAPY_TAG "${_default_capy_tag} " CACHE STRING
67- "Git tag/branch for capy when fetching via FetchContent" )
68-
69- message (STATUS "Fetching capy..." )
70- set (BOOST_CAPY_BUILD_TESTS OFF CACHE BOOL "" FORCE )
71- set (BOOST_CAPY_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE )
72- FetchContent_Declare (
73- capy
74- GIT_REPOSITORY https://github.com/cppalliance/capy.git
75- GIT_TAG ${BOOST_COROSIO_CAPY_TAG}
76- GIT_SHALLOW TRUE
77- )
78- FetchContent_MakeAvailable (capy)
79- endif ()
80-
8134 find_package (Threads REQUIRED )
8235endmacro ()
8336
@@ -196,9 +149,11 @@ function(corosio_install)
196149 $<INSTALL_INTERFACE :${CMAKE_INSTALL_INCLUDEDIR} >)
197150 endforeach ()
198151
199- if (boost_capy_FOUND)
200- # Capy from find_package (imported target): full install with
201- # CMake package config and export sets.
152+ get_target_property (_capy_imported boost_capy IMPORTED )
153+
154+ if (_capy_imported)
155+ # Capy is an imported target (find_package, vcpkg, conan):
156+ # full install with export sets and package config.
202157 include (CMakePackageConfigHelpers )
203158
204159 set (BOOST_COROSIO_INSTALL_CMAKEDIR
@@ -233,9 +188,9 @@ function(corosio_install)
233188 install (FILES ${_corosio_config_files}
234189 DESTINATION ${BOOST_COROSIO_INSTALL_CMAKEDIR} )
235190 else ()
236- # Capy from source tree (boost root or FetchContent): export sets
237- # can't work because capy isn 't an imported target. Install the
238- # library and headers only .
191+ # Capy from source tree (boost root, FetchContent,
192+ # add_subdirectory): export sets can 't reference a
193+ # non-exported dependency .
239194 install (TARGETS ${_corosio_install_targets}
240195 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
241196 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
0 commit comments