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
+ #
1
12
if (TARGET Boost::boost)
2
13
return ()
3
14
endif ()
4
15
5
16
message (STATUS "Third-party: creating targets 'Boost::boost'" )
6
17
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
-
14
18
set (PREVIOUS_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} )
15
19
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC" )
16
20
set (OLD_CMAKE_POSITION_INDEPENDENT_CODE ${CMAKE_POSITION_INDEPENDENT_CODE} )
17
21
set (CMAKE_POSITION_INDEPENDENT_CODE ON )
18
22
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
+ )
27
47
28
48
set (CMAKE_POSITION_INDEPENDENT_CODE ${OLD_CMAKE_POSITION_INDEPENDENT_CODE} )
29
49
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 ()
0 commit comments