1212# Resolve all build dependencies: sibling Boost libraries when inside a
1313# boost tree, Capy via find_package / FetchContent, and Threads.
1414#
15- # Must be a macro so find_package results (e.g. boost_capy_FOUND) propagate
16- # to the caller's scope for install logic.
15+ # Must be a macro so find_package results propagate to the caller's scope.
1716macro (corosio_resolve_deps )
1817 # Sibling Boost libraries when building standalone inside a boost tree.
1918 # The Boost::asio reference must stay out of CMakeLists.txt because the
@@ -187,9 +186,8 @@ function(corosio_install)
187186 TARGETS ${_corosio_install_targets}
188187 VERSION ${BOOST_SUPERPROJECT_VERSION}
189188 HEADER_DIRECTORY include )
190- elseif (boost_capy_FOUND )
189+ elseif (BOOST_COROSIO_IS_ROOT )
191190 include (GNUInstallDirs )
192- include (CMakePackageConfigHelpers )
193191
194192 # Set INSTALL_INTERFACE for standalone installs (boost_install handles
195193 # this for superproject builds, including versioned-layout paths)
@@ -198,36 +196,52 @@ function(corosio_install)
198196 $<INSTALL_INTERFACE :${CMAKE_INSTALL_INCLUDEDIR} >)
199197 endforeach ()
200198
201- set (BOOST_COROSIO_INSTALL_CMAKEDIR
202- ${CMAKE_INSTALL_LIBDIR} /cmake/boost_corosio)
203-
204- install (TARGETS ${_corosio_install_targets}
205- EXPORT boost_corosio-targets
206- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
207- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
208- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} )
209- install (DIRECTORY include/
210- DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} )
211- install (EXPORT boost_corosio-targets
212- NAMESPACE Boost::
213- DESTINATION ${BOOST_COROSIO_INSTALL_CMAKEDIR} )
214-
215- configure_package_config_file (
216- cmake/boost_corosio-config.cmake.in
217- ${CMAKE_CURRENT_BINARY_DIR } /boost_corosio-config.cmake
218- INSTALL_DESTINATION ${BOOST_COROSIO_INSTALL_CMAKEDIR} )
219- write_basic_package_version_file (
220- ${CMAKE_CURRENT_BINARY_DIR } /boost_corosio-config-version.cmake
221- COMPATIBILITY SameMajorVersion )
222-
223- set (_corosio_config_files
224- ${CMAKE_CURRENT_BINARY_DIR } /boost_corosio-config.cmake
225- ${CMAKE_CURRENT_BINARY_DIR } /boost_corosio-config-version.cmake)
226- if (WolfSSL_FOUND)
227- list (APPEND _corosio_config_files
228- ${CMAKE_CURRENT_SOURCE_DIR } /cmake/FindWolfSSL.cmake)
199+ if (boost_capy_FOUND)
200+ # Capy from find_package (imported target): full install with
201+ # CMake package config and export sets.
202+ include (CMakePackageConfigHelpers )
203+
204+ set (BOOST_COROSIO_INSTALL_CMAKEDIR
205+ ${CMAKE_INSTALL_LIBDIR} /cmake/boost_corosio)
206+
207+ install (TARGETS ${_corosio_install_targets}
208+ EXPORT boost_corosio-targets
209+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
210+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
211+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} )
212+ install (DIRECTORY include/
213+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} )
214+ install (EXPORT boost_corosio-targets
215+ NAMESPACE Boost::
216+ DESTINATION ${BOOST_COROSIO_INSTALL_CMAKEDIR} )
217+
218+ configure_package_config_file (
219+ cmake/boost_corosio-config.cmake.in
220+ ${CMAKE_CURRENT_BINARY_DIR } /boost_corosio-config.cmake
221+ INSTALL_DESTINATION ${BOOST_COROSIO_INSTALL_CMAKEDIR} )
222+ write_basic_package_version_file (
223+ ${CMAKE_CURRENT_BINARY_DIR } /boost_corosio-config-version.cmake
224+ COMPATIBILITY SameMajorVersion )
225+
226+ set (_corosio_config_files
227+ ${CMAKE_CURRENT_BINARY_DIR } /boost_corosio-config.cmake
228+ ${CMAKE_CURRENT_BINARY_DIR } /boost_corosio-config-version.cmake)
229+ if (WolfSSL_FOUND)
230+ list (APPEND _corosio_config_files
231+ ${CMAKE_CURRENT_SOURCE_DIR } /cmake/FindWolfSSL.cmake)
232+ endif ()
233+ install (FILES ${_corosio_config_files}
234+ DESTINATION ${BOOST_COROSIO_INSTALL_CMAKEDIR} )
235+ 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.
239+ install (TARGETS ${_corosio_install_targets}
240+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
241+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
242+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} )
243+ install (DIRECTORY include/
244+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} )
229245 endif ()
230- install (FILES ${_corosio_config_files}
231- DESTINATION ${BOOST_COROSIO_INSTALL_CMAKEDIR} )
232246 endif ()
233247endfunction ()
0 commit comments