Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding option for downloading Boost using CMake FetchContent #6424

Merged
merged 11 commits into from
Apr 3, 2024
45 changes: 45 additions & 0 deletions .github/workflows/linux_debug_fetch_boost.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright (c) 2024 Vedant Nimje
#
# SPDX-License-Identifier: BSL-1.0
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

name: Linux CI (Debug) with Boost Fetch

on: [pull_request]

jobs:
build:
runs-on: ubuntu-latest
container: stellargroup/build_env:14

steps:
- uses: actions/checkout@v4
- name: Configure
shell: bash
run: |
cmake \
. \
-Bbuild \
-GNinja \
-DCMAKE_BUILD_TYPE=Debug \
-DHPX_WITH_MALLOC=system \
-DHPX_WITH_FETCH_ASIO=ON \
-DHPX_WITH_FETCH_BOOST=ON \
-DHPX_WITH_EXAMPLES=ON \
-DHPX_WITH_TESTS=ON \
-DHPX_WITH_TESTS_MAX_THREADS_PER_LOCALITY=2 \
-DHPX_WITH_CHECK_MODULE_DEPENDENCIES=On
- name: Build
shell: bash
run: |
cmake --build build --target all
cmake --build build --target examples
- name: Test
shell: bash
run: |
cd build
ctest \
--output-on-failure \
--tests-regex tests.examples \
--exclude-regex tests.examples.transpose.transpose_block_numa
81 changes: 81 additions & 0 deletions .github/workflows/macos_debug_fetch_boost.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Copyright (c) 2024 Vedant Nimje
#
# SPDX-License-Identifier: BSL-1.0
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

name: macOS CI (Debug) with Boost Fetch

on: [pull_request]

jobs:
build:
runs-on: macos-latest

steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
# Workaround for https://github.com/actions/virtual-environments/issues/2322
rm -rf /usr/local/bin/2to3*
rm -rf /usr/local/bin/idle3*
rm -rf /usr/local/bin/pydoc3*
rm -rf /usr/local/bin/python3*
brew upgrade
brew update && \
brew install --overwrite python-tk && \
brew install --overwrite hwloc gperftools ninja && \
brew upgrade cmake
- name: Configure
shell: bash
run: |
cmake \
-H. \
-Bbuild \
-GNinja \
-DCMAKE_BUILD_TYPE=Debug \
-DHPX_WITH_FETCH_ASIO=ON \
-DHPX_WITH_FETCH_BOOST=ON \
-DHPX_WITH_EXAMPLES=ON \
-DHPX_WITH_TESTS=ON \
-DHPX_WITH_TESTS_MAX_THREADS_PER_LOCALITY=2 \
-DHPX_WITH_CHECK_MODULE_DEPENDENCIES=On
- name: Build
shell: bash
run: |
cmake --build build --target all
cmake --build build --target tests
- name: Test
shell: bash
run: |
cd build
ctest --output-on-failure \
--exclude-regex \
"tests.examples.quickstart.1d_wave_equation|\
tests.examples.transpose.transpose_block_numa|\
tests.performance.local.wait_all_timings|\
tests.regressions.components.distributed.tcp.bulk_new_3054|\
tests.regressions.dynamic_counters_loaded_1508|\
tests.regressions.lcos.wait_all_hang_1946|\
tests.regressions.modules.async_combinators.wait_all_hang_1946|\
tests.regressions.modules.collectives.distributed.tcp.broadcast_apply|\
tests.regressions.modules.collectives.distributed.tcp.broadcast_unwrap_future_2885|\
tests.regressions.modules.collectives.distributed.tcp.remote_latch|\
tests.regressions.modules.compute_local.parallel_fill_4132|\
tests.regressions.util.distributed.tcp.zero_copy_parcels_1001_no_zero_copy_optimization|\
tests.regressions.modules.performance_counters.dynamic_counters_loaded_1508|\
tests.regressions.modules.performance_counters.statistics_2666|\
tests.unit.modules.runtime_components.distributed.tcp.migrate_component|\
tests.unit.modules.runtime_components.distributed.tcp.migrate_polymorphic_component|\
tests.unit.modules.algorithms.default_construct|\
tests.unit.modules.algorithms.destroy|\
tests.unit.modules.algorithms.foreach_executors|\
tests.unit.modules.algorithms.max_element|\
tests.unit.modules.algorithms.replace_copy_if|\
tests.unit.modules.compute_local.numa_allocator|\
tests.unit.modules.execution.standalone_thread_pool_executor|\
tests.unit.modules.resource_partitioner.used_pus|\
tests.unit.modules.segmented_algorithms.distributed.tcp.partitioned_vector|\
tests.unit.threads.distributed.tcp.thread_stacksize|\
tests.unit.topology.numa_allocator|\
tests.unit.modules.runtime_components.distributed.tcp.migrate_polymorphic_component"
61 changes: 61 additions & 0 deletions .github/workflows/windows_debug_vs2022_fetch_boost.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Copyright (c) 2024 Vedant Nimje
#
# SPDX-License-Identifier: BSL-1.0
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

name: Windows CI (Debug, VS2022 toolset) with Boost Fetch

on: [pull_request]

jobs:
build:
runs-on: windows-latest

steps:
- uses: actions/checkout@v4
- uses: jwlawson/[email protected]
with:
cmake-version: '3.22.x'
- name: Install dependencies
run: |
md C:\projects
$client = new-object System.Net.WebClient
$client.DownloadFile("https://rostam.cct.lsu.edu/download/builder/vcpkg-export-hpx-dependencies-2022.7z","C:\projects\vcpkg-export-hpx-dependencies.7z")
7z x C:\projects\vcpkg-export-hpx-dependencies.7z -y -oC:\projects\vcpkg
- name: Configure
shell: bash
run: |
cmake . -Bbuild -G'Visual Studio 17 2022' \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_TOOLCHAIN_FILE='C:/projects/vcpkg/scripts/buildsystems/vcpkg.cmake' \
-DHPX_WITH_FETCH_BOOST=ON \
-DHPX_WITH_FETCH_ASIO=ON \
-DHPX_WITH_EXAMPLES=ON \
-DHPX_WITH_TESTS=ON \
-DHPX_WITH_TESTS_UNIT=ON \
-DHPX_WITH_DEPRECATION_WARNINGS=OFF \
-DHPX_WITH_TESTS_MAX_THREADS_PER_LOCALITY=2 \
-DHPX_COROUTINES_WITH_SWAP_CONTEXT_EMULATION=ON \
-DHPX_WITH_CHECK_MODULE_DEPENDENCIES=On
- name: Build
shell: bash
run: |
cmake --build build --config Debug \
--target ALL_BUILD \
-- -maxcpucount:2 -verbosity:minimal -nologo
- name: Install
shell: bash
run: |
cmake --install build --config Debug
- name: Test
run: |
Set-Alias -Name grep -Value 'C:\Program Files\Git\usr\bin\grep.exe'
Set-Alias -Name sed -Value 'C:\Program Files\Git\usr\bin\sed.exe'
cd build
ctest `
--output-on-failure `
--build-config Debug `
--tests-regex tests.examples `
--exclude-regex `
$(grep -v -e ^# -e ^$ D:/a/hpx/hpx/.github/workflows/tests.examples.targets | sed ':b;N;$!bb;s/\n/|/g')
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,15 @@ if(HPX_WITH_APEX)
)
endif()

hpx_option(
HPX_WITH_FETCH_BOOST
BOOL
"Use FetchContent to fetch Asio. By default an installed Asio will be used. (default: OFF)"
Copy link
Contributor

Choose a reason for hiding this comment

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

Please change description

OFF
CATEGORY "Build Targets"
ADVANCED
)

# Options for automatically fetching Asio
hpx_option(
HPX_WITH_FETCH_ASIO
Expand Down
54 changes: 54 additions & 0 deletions cmake/HPX_SetupBoost.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,60 @@
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

if(HPX_WITH_FETCH_BOOST)
set(HPX_WITH_BOOST_VERSION "1.84.0")
hpx_info(
"HPX_WITH_FETCH_BOOST=${HPX_WITH_FETCH_BOOST}, Boost v${HPX_WITH_BOOST_VERSION} will be fetched using CMake's FetchContent"
)
include(FetchContent)
fetchcontent_declare(
Boost
URL https://github.com/boostorg/boost/releases/download/boost-${HPX_WITH_BOOST_VERSION}/boost-${HPX_WITH_BOOST_VERSION}.tar.gz
TLS_VERIFY true
)
fetchcontent_populate(Boost)

set(EX_PRC
"Execute process"
CACHE STRING "Used by command line tool."
)
set(EX_PRC_INTERNAL
""
CACHE INTERNAL "for internal use only; do not modify"
)

if(NOT EX_PRC STREQUAL EX_PRC_INTERNAL)
if(WIN32)
execute_process(
COMMAND
cmd /C
"cd ${CMAKE_BINARY_DIR}\\_deps\\boost-src && .\\bootstrap.bat && .\\b2 headers cxxflags=/std:c++20"
Copy link
Member

Choose a reason for hiding this comment

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

Should we compile with the C++ version that corresponds to what the user requested for HPX (HPX_CXX_STANDARD)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we could do that. Will make the changes

)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
hpx_info("Building fetched boost")
execute_process(
COMMAND
sh -c
"cd ${CMAKE_BINARY_DIR}/_deps/boost-src && ./bootstrap.sh --prefix=${CMAKE_BINARY_DIR}/_deps/boost-installed && ./b2 && ./b2 install --prefix=${CMAKE_BINARY_DIR}/_deps/boost-installed cxxflags=--std=c++20"
Copy link
Member

Choose a reason for hiding this comment

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

Same here (and in more places below). Should we use HPX_CXX_STANDARD?

)
else()
execute_process(
COMMAND
sh -c
"cd ${CMAKE_BINARY_DIR}/_deps/boost-src && ./bootstrap.sh && ./b2 headers cxxflags=--std=c++20"
)
endif()
set(EX_PRC_INTERNAL
Copy link
Member

Choose a reason for hiding this comment

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

What is this used for?

Copy link
Contributor Author

@vrnimje vrnimje Jan 25, 2024

Choose a reason for hiding this comment

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

It makes sure that the commands defined to build Boost are not executed again, if the project is reconfigured
But I noticed that I have mistakenly defined it as INTERNAL instead of STRING above. Will make the changes

Copy link
Member

@hkaiser hkaiser Jan 26, 2024

Choose a reason for hiding this comment

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

If this is something that is used outside of a CMake configuration step (e.g. needed for configuring dependent applications), please prefix the variable name with HPX_WITH_ for consistency and to avoid name clashes.

Copy link
Contributor Author

@vrnimje vrnimje Jan 26, 2024

Choose a reason for hiding this comment

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

Yes, it is used for configuring the building of fetched Boost, so will update with the variable naming you have mentioned.

${EX_PRC}
CACHE INTERNAL "for internal use only; do not modify"
)
endif()

set(Boost_DIR "${CMAKE_BINARY_DIR}/_deps/boost-src")
set(Boost_INCLUDE_DIR "${CMAKE_BINARY_DIR}/_deps/boost-src")
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we sure this should not be internal?

Copy link
Contributor Author

@vrnimje vrnimje Jan 23, 2024

Choose a reason for hiding this comment

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

I guess it makes sense to keep it Internal, as it is set when the option is used, so should not be visible
Will make the changes

endif()
endif()
Copy link
Contributor

Choose a reason for hiding this comment

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

There are two endifs, does it not cause errors?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nevermind, seems like you have fixed it

Copy link
Member

Choose a reason for hiding this comment

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

Should all of the above go into a separate file FindBoost.cmake or similar (just for consistency reasons)? OTOH, this may conflict with the file with the same name in the CMake distribution...


# In case find_package(HPX) is called multiple times
if(NOT TARGET hpx_dependencies_boost)
# We first try to find the required minimum set of Boost libraries. This will
Expand Down
Loading