diff --git a/.github/workflows/macos_debug_fetch_boost.yml b/.github/workflows/macos_debug_fetch_boost.yml index 81d15d8eeb1..fb71c9b483c 100644 --- a/.github/workflows/macos_debug_fetch_boost.yml +++ b/.github/workflows/macos_debug_fetch_boost.yml @@ -73,4 +73,5 @@ jobs: tests.unit.threads.distributed.tcp.thread_stacksize|\ tests.unit.topology.numa_allocator|\ tests.unit.modules.runtime_components.distributed.tcp.migrate_polymorphic_component|\ - tests.unit.modules.executors.limiting_executor" + tests.unit.modules.executors.limiting_executor|" + "build_dir_targets_test" diff --git a/CMakeLists.txt b/CMakeLists.txt index 519c3292152..923f9f3e722 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2324,7 +2324,7 @@ endif() if(HPX_WITH_GENERIC_CONTEXT_COROUTINES) # Check if we can use generic coroutine contexts without any problems - if(NOT Boost_CONTEXT_FOUND) + if(NOT (Boost_CONTEXT_FOUND OR TARGET Boost::context)) hpx_error( "The usage of Boost.Context was selected but Boost.Context was not found." ) diff --git a/cmake/HPX_GeneratePackage.cmake b/cmake/HPX_GeneratePackage.cmake index d0f473945c7..5ff7f382769 100644 --- a/cmake/HPX_GeneratePackage.cmake +++ b/cmake/HPX_GeneratePackage.cmake @@ -61,6 +61,7 @@ install( ) # Install dir +set(HPX_CONFIG_IS_INSTALL ON) configure_file( cmake/templates/${HPX_PACKAGE_NAME}Config.cmake.in "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${HPX_PACKAGE_NAME}Config.cmake" @@ -76,6 +77,7 @@ if(HPX_WITH_PKGCONFIG) endif() # Build dir +set(HPX_CONFIG_IS_INSTALL OFF) configure_file( cmake/templates/${HPX_PACKAGE_NAME}Config.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/${HPX_PACKAGE_NAME}/${HPX_PACKAGE_NAME}Config.cmake" @@ -88,6 +90,7 @@ if(HPX_WITH_PKGCONFIG) cmake/templates/hpxcxx.in "${CMAKE_CURRENT_BINARY_DIR}/bin/hpxcxx" @ONLY ) endif() +unset(HPX_CONFIG_IS_INSTALL) # Configure macros for the install dir ... set(HPX_CMAKE_MODULE_PATH "\${CMAKE_CURRENT_LIST_DIR}") diff --git a/cmake/HPX_SetupBoost.cmake b/cmake/HPX_SetupBoost.cmake index 7f2a124a3fa..b62099f5d22 100644 --- a/cmake/HPX_SetupBoost.cmake +++ b/cmake/HPX_SetupBoost.cmake @@ -15,21 +15,11 @@ if(NOT TARGET hpx_dependencies_boost) set(__boost_libraries "") - if(HPX_PARCELPORT_LIBFABRIC_WITH_LOGGING - OR HPX_PARCELPORT_LIBFABRIC_WITH_DEV_MODE - ) - set(__boost_libraries ${__boost_libraries} log log_setup date_time chrono - thread - ) - endif() - if(HPX_WITH_GENERIC_CONTEXT_COROUTINES) # if context is needed, we should still link with boost thread and chrono set(__boost_libraries ${__boost_libraries} context thread chrono) endif() - list(REMOVE_DUPLICATES __boost_libraries) - # compatibility with older CMake versions if(BOOST_ROOT AND NOT Boost_ROOT) set(Boost_ROOT @@ -39,7 +29,7 @@ if(NOT TARGET hpx_dependencies_boost) unset(BOOST_ROOT CACHE) endif() - if((NOT HPX_WITH_FETCH_BOOST) OR HPX_FIND_PACKAGE) + if(NOT HPX_WITH_FETCH_BOOST OR HPX_FIND_PACKAGE) set(Boost_MINIMUM_VERSION "1.71" @@ -63,7 +53,6 @@ if(NOT TARGET hpx_dependencies_boost) elseif(NOT TARGET Boost::boost AND NOT HPX_FIND_PACKAGE) # Fetch Boost using CMake's FetchContent - if(NOT HPX_WITH_BOOST_VERSION) set(HPX_WITH_BOOST_VERSION "1.86.0") endif() @@ -81,7 +70,7 @@ if(NOT TARGET hpx_dependencies_boost) ) # Also need to explicitly list header-only dependencies, since Cmake-Boost - # has installs each library's headers individually, as opposed to b2-built + # installs each library's headers individually, as opposed to b2-built # Boost. set(__boost_libraries ${__boost_libraries} @@ -89,19 +78,27 @@ if(NOT TARGET hpx_dependencies_boost) bind config exception - filesystem functional fusion - iostreams - log optional parameter phoenix - regex spirit variant ) + if(HPX_FILESYSTEM_WITH_BOOST_FILESYSTEM_COMPATIBILITY) + set(__boost_libraries ${__boost_libraries} filesystem) + endif() + + if(HPX_WITH_TOOLS) + set(__boost_libraries ${__boost_libraries} regex) + endif() + + if(HPX_WITH_DISTRIBUTED_RUNTIME) + set(__boost_libraries ${__boost_libraries} iostreams) + endif() + set(BOOST_INCLUDE_LIBRARIES ${__boost_libraries}) set(BOOST_SKIP_INSTALL_RULES OFF) @@ -110,7 +107,7 @@ if(NOT TARGET hpx_dependencies_boost) add_library(hpx_dependencies_boost INTERFACE) list(TRANSFORM __boost_libraries - PREPEND "boost_" OUTPUT_VARIABLE __boost_libraries_prefixed + PREPEND "Boost::" OUTPUT_VARIABLE __boost_libraries_prefixed ) target_link_libraries( diff --git a/cmake/HPX_SetupBoostFilesystem.cmake b/cmake/HPX_SetupBoostFilesystem.cmake index 65b69a14392..ea0fdec588b 100644 --- a/cmake/HPX_SetupBoostFilesystem.cmake +++ b/cmake/HPX_SetupBoostFilesystem.cmake @@ -7,7 +7,6 @@ if(HPX_FILESYSTEM_WITH_BOOST_FILESYSTEM_COMPATIBILITY) # In case find_package(HPX) is called multiple times if(NOT TARGET Boost::filesystem) - hpx_set_cmake_policy(CMP0167 OLD) # use CMake's FindBoost for now find_package( Boost ${Boost_MINIMUM_VERSION} NO_POLICY_SCOPE MODULE diff --git a/cmake/HPX_SetupBoostIostreams.cmake b/cmake/HPX_SetupBoostIostreams.cmake index 92c68bf44f7..b664b080722 100644 --- a/cmake/HPX_SetupBoostIostreams.cmake +++ b/cmake/HPX_SetupBoostIostreams.cmake @@ -9,7 +9,6 @@ if((HPX_WITH_COMPRESSION_BZIP2 OR HPX_WITH_COMPRESSION_ZLIB) AND NOT TARGET Boost::iostreams ) - hpx_set_cmake_policy(CMP0167 OLD) # use CMake's FindBoost for now find_package( Boost ${Boost_MINIMUM_VERSION} NO_POLICY_SCOPE MODULE COMPONENTS iostreams diff --git a/cmake/HPX_SetupBoostRegex.cmake b/cmake/HPX_SetupBoostRegex.cmake index c3ab0448dbd..f7cab85531a 100644 --- a/cmake/HPX_SetupBoostRegex.cmake +++ b/cmake/HPX_SetupBoostRegex.cmake @@ -5,7 +5,6 @@ # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) if(NOT TARGET Boost::regex) - hpx_set_cmake_policy(CMP0167 OLD) # use CMake's FindBoost for now find_package( Boost ${Boost_MINIMUM_VERSION} NO_POLICY_SCOPE MODULE COMPONENTS regex diff --git a/cmake/templates/HPXConfig.cmake.in b/cmake/templates/HPXConfig.cmake.in index 8689d13785b..a83a19f9f91 100644 --- a/cmake/templates/HPXConfig.cmake.in +++ b/cmake/templates/HPXConfig.cmake.in @@ -28,9 +28,8 @@ else() include(HPX_SetupAsio) endif() - -# Stdexec can be installed by HPX or externally installed. In the first case we use -# exported targets, in the second we find Stdexec again using find_package. +# Stdexec can be installed by HPX or externally installed. In the first case we +# use exported targets, in the second we find Stdexec again using find_package. if(HPX_WITH_STDEXEC) if(HPX_WITH_FETCH_STDEXEC) include("${CMAKE_CURRENT_LIST_DIR}/HPXStdexecTarget.cmake") @@ -40,8 +39,6 @@ if(HPX_WITH_STDEXEC) endif() endif() - - # NLohnmann JSON can be installed by HPX or externally installed. In the first # case we use exported targets, in the second we find JSON again using # find_package. @@ -93,8 +90,14 @@ if("${HPX_WITH_DATAPAR_BACKEND}" STREQUAL "SVE") endif() if(HPX_WITH_FETCH_BOOST) - # Boost has been installed alongside HPX - # Let HPX_SetupBoost find it + # Boost has been installed alongside HPX, let HPX_SetupBoost find it + if(NOT HPX_CONFIG_IS_INSTALL) + hpx_error( + "HPX_WITH_FETCH_BOOST=ON requires HPX to be installed after it is built. + Please execute the CMake install step (cmake --install) on your HPX build + directory, and link your project against the installed instance of HPX." + ) + endif() set(HPX_BOOST_ROOT "${CMAKE_CURRENT_LIST_DIR}/../") include(HPX_SetupBoost) include(HPX_SetupBoostFilesystem) @@ -105,7 +108,7 @@ else() # By default Boost_ROOT is set to HPX_BOOST_ROOT (not necessary for PAPI or # HWLOC cause we are specifying HPX__ROOT as an HINT to find_package) if(NOT Boost_ROOT AND NOT "$ENV{BOOST_ROOT}") - set(Boost_ROOT ${HPX_BOOST_ROOT}) + set(Boost_ROOT ${HPX_BOOST_ROOT}) endif() include(HPX_SetupBoost) include(HPX_SetupBoostFilesystem)