unset(where)
endmacro()
-function(do_build_boost version)
+function(do_build_boost root_dir version)
cmake_parse_arguments(Boost_BUILD "" "" COMPONENTS ${ARGN})
set(boost_features "variant=release")
if(Boost_USE_MULTITHREADED)
${boost_features})
set(install_command
${b2} install)
- set(boost_root_dir "${CMAKE_BINARY_DIR}/boost")
if(EXISTS "${PROJECT_SOURCE_DIR}/src/boost/bootstrap.sh")
check_boost_version("${PROJECT_SOURCE_DIR}/src/boost" ${version})
set(source_dir
CONFIGURE_COMMAND CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} ${configure_command}
BUILD_COMMAND CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} ${build_command}
BUILD_IN_SOURCE 1
+ BUILD_BYPRODUCTS ${Boost_LIBRARIES}
INSTALL_COMMAND ${install_command}
- PREFIX "${boost_root_dir}")
+ PREFIX "${root_dir}")
endfunction()
set(Boost_context_DEPENDENCIES thread chrono system date_time)
set(Boost_iostreams_DEPENDENCIES regex)
set(Boost_thread_DEPENDENCIES chrono system date_time atomic)
+# define a macro, so the Boost_* variables are visible by its caller
macro(build_boost version)
- do_build_boost(${version} ${ARGN})
- ExternalProject_Get_Property(Boost install_dir)
+ # add the Boost::${component} libraries, do this before adding the "Boost"
+ # target, so we can collect "Boost_LIBRARIES" which is then used by
+ # ExternalProject_Add(Boost ...)
+ set(install_dir "${CMAKE_BINARY_DIR}/boost")
set(Boost_INCLUDE_DIRS ${install_dir}/include)
set(Boost_INCLUDE_DIR ${install_dir}/include)
set(Boost_VERSION ${version})
else()
add_library(Boost::${c} SHARED IMPORTED)
endif()
- add_dependencies(Boost::${c} Boost)
if(c MATCHES "^python")
set(c "python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}")
endif()
IMPORTED_LOCATION "${Boost_${upper_c}_LIBRARY}")
if((c MATCHES "coroutine|context") AND (WITH_BOOST_VALGRIND))
set_target_properties(Boost::${c} PROPERTIES
- INTERFACE_COMPILE_DEFINITIONS "BOOST_USE_VALGRIND")
+ INTERFACE_COMPILE_DEFINITIONS "BOOST_USE_VALGRIND")
endif()
list(APPEND Boost_LIBRARIES ${Boost_${upper_c}_LIBRARY})
endforeach()
set(Boost_${c}_FOUND "TRUE")
endforeach()
+ # download, bootstrap and build Boost
+ do_build_boost(${install_dir} ${version} ${ARGN})
+
+ # add dependencies from Boost::${component} to Boost
+ foreach(c ${Boost_BUILD_COMPONENTS})
+ add_dependencies(Boost::${c} Boost)
+ endforeach()
+
# for header-only libraries
add_library(Boost::boost INTERFACE IMPORTED)
set_target_properties(Boost::boost PROPERTIES