Skip to content

Commit 473beba

Browse files
committed
Update Boost
1 parent d557bba commit 473beba

File tree

4 files changed

+111
-15
lines changed

4 files changed

+111
-15
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/rigid_ipc/")
5050
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/recipes/")
5151
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/find/")
5252

53+
include(rigid_ipc_cpm_cache)
54+
5355
# Color output
5456
include(rigid_ipc_use_colors)
5557

cmake/recipes/CPM.cmake

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
set(CPM_DOWNLOAD_VERSION 0.40.2)
2+
3+
if(CPM_SOURCE_CACHE)
4+
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
5+
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
6+
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
7+
else()
8+
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
9+
endif()
10+
11+
# Expand relative path. This is important if the provided path contains a tilde (~)
12+
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)
13+
14+
function(download_cpm)
15+
message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
16+
file(DOWNLOAD
17+
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
18+
${CPM_DOWNLOAD_LOCATION}
19+
)
20+
endfunction()
21+
22+
if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
23+
download_cpm()
24+
else()
25+
# resume download if it previously failed
26+
file(READ ${CPM_DOWNLOAD_LOCATION} check)
27+
if("${check}" STREQUAL "")
28+
download_cpm()
29+
endif()
30+
unset(check)
31+
endif()
32+
33+
include(${CPM_DOWNLOAD_LOCATION})

cmake/recipes/boost.cmake

Lines changed: 52 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,66 @@
1+
#
2+
# Copyright 2021 Adobe. All rights reserved.
3+
# This file is licensed to you under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License. You may obtain a copy
5+
# of the License at http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software distributed under
8+
# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9+
# OF ANY KIND, either express or implied. See the License for the specific language
10+
# governing permissions and limitations under the License.
11+
#
112
if(TARGET Boost::boost)
213
return()
314
endif()
415

516
message(STATUS "Third-party: creating targets 'Boost::boost'")
617

7-
include(FetchContent)
8-
FetchContent_Declare(
9-
boost-cmake
10-
GIT_REPOSITORY https://github.com/Orphis/boost-cmake.git
11-
GIT_TAG 7f97a08b64bd5d2e53e932ddf80c40544cf45edf
12-
)
13-
1418
set(PREVIOUS_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
1519
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
1620
set(OLD_CMAKE_POSITION_INDEPENDENT_CODE ${CMAKE_POSITION_INDEPENDENT_CODE})
1721
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
1822

19-
# This guy will download boost using FetchContent
20-
FetchContent_GetProperties(boost-cmake)
21-
if(NOT boost-cmake_POPULATED)
22-
FetchContent_Populate(boost-cmake)
23-
# File lcid.cpp from Boost_locale.cpp doesn't compile on MSVC, so we exclude them from the default
24-
# targets being built by the project (only targets explicitly used by other targets will be built).
25-
add_subdirectory(${boost-cmake_SOURCE_DIR} ${boost-cmake_BINARY_DIR} EXCLUDE_FROM_ALL)
26-
endif()
23+
set(BOOST_URL "https://boostorg.jfrog.io/artifactory/main/release/1.86.0/source/boost_1_86_0.tar.bz2" CACHE STRING "Boost download URL")
24+
set(BOOST_URL_SHA256 "1bed88e40401b2cb7a1f76d4bab499e352fa4d0c5f31c0dbae64e24d34d7513b" CACHE STRING "Boost download URL SHA256 checksum")
25+
26+
include(CPM)
27+
CPMAddPackage(
28+
NAME boost
29+
URL ${BOOST_URL}
30+
URL_HASH SHA256=${BOOST_URL_SHA256}
31+
DOWNLOAD_ONLY ON
32+
)
33+
set(BOOST_SOURCE ${boost_SOURCE_DIR})
34+
set(Boost_POPULATED ON)
35+
36+
# Only build the following Boost libs
37+
set(BOOST_LIBS_OPTIONAL "" CACHE STRING "Boost libs to be compiled" FORCE)
38+
39+
# File lcid.cpp from Boost_locale.cpp doesn't compile on MSVC, so we exclude them from the default
40+
# targets being built by the project (only targets explicitly used by other targets will be built).
41+
CPMAddPackage(
42+
NAME boost-cmake
43+
GITHUB_REPOSITORY Orphis/boost-cmake
44+
GIT_TAG 7f97a08b64bd5d2e53e932ddf80c40544cf45edf
45+
EXCLUDE_FROM_ALL
46+
)
2747

2848
set(CMAKE_POSITION_INDEPENDENT_CODE ${OLD_CMAKE_POSITION_INDEPENDENT_CODE})
2949
set(CMAKE_CXX_FLAGS "${PREVIOUS_CMAKE_CXX_FLAGS}")
50+
51+
foreach(name IN ITEMS
52+
atomic
53+
chrono
54+
container
55+
date_time
56+
filesystem
57+
iostreams
58+
log
59+
system
60+
thread
61+
timer
62+
)
63+
if(TARGET Boost_${name})
64+
set_target_properties(Boost_${name} PROPERTIES FOLDER third_party/boost)
65+
endif()
66+
endforeach()
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#
2+
# Copyright 2021 Adobe. All rights reserved.
3+
# This file is licensed to you under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License. You may obtain a copy
5+
# of the License at http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software distributed under
8+
# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9+
# OF ANY KIND, either express or implied. See the License for the specific language
10+
# governing permissions and limitations under the License.
11+
#
12+
13+
if(DEFINED ENV{CPM_SOURCE_CACHE})
14+
set(CPM_SOURCE_CACHE_DEFAULT $ENV{CPM_SOURCE_CACHE})
15+
else()
16+
# Set CPM cache folder if unset
17+
file(REAL_PATH "~/.cache/CPM" CPM_SOURCE_CACHE_DEFAULT EXPAND_TILDE)
18+
endif()
19+
20+
set(CPM_SOURCE_CACHE
21+
${CPM_SOURCE_CACHE_DEFAULT}
22+
CACHE PATH "Directory to download CPM dependencies"
23+
)
24+
message(STATUS "Using CPM cache folder: ${CPM_SOURCE_CACHE}")

0 commit comments

Comments
 (0)