|
| 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 | +if(TARGET Boost::boost) |
| 13 | + return() |
| 14 | +endif() |
| 15 | + |
| 16 | +message(STATUS "Third-party: creating targets 'Boost::boost'...") |
| 17 | + |
| 18 | +set(PREVIOUS_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) |
| 19 | +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") |
| 20 | +set(OLD_CMAKE_POSITION_INDEPENDENT_CODE ${CMAKE_POSITION_INDEPENDENT_CODE}) |
| 21 | +set(CMAKE_POSITION_INDEPENDENT_CODE ON) |
| 22 | + |
| 23 | +set(BOOST_URL |
| 24 | + "https://archives.boost.io/release/1.83.0/source/boost_1_83_0.tar.bz2" |
| 25 | + CACHE STRING "Boost download URL") |
| 26 | +set(BOOST_URL_SHA256 "6478edfe2f3305127cffe8caf73ea0176c53769f4bf1585be237eb30798c3b8e" CACHE STRING "Boost download URL SHA256 checksum") |
| 27 | + |
| 28 | +include(CPM) |
| 29 | +CPMAddPackage( |
| 30 | + NAME boost |
| 31 | + URL ${BOOST_URL} |
| 32 | + URL_HASH SHA256=${BOOST_URL_SHA256} |
| 33 | + DOWNLOAD_ONLY ON |
| 34 | +) |
| 35 | +set(BOOST_SOURCE ${boost_SOURCE_DIR}) |
| 36 | +set(Boost_POPULATED ON) |
| 37 | + |
| 38 | +# Only build the following Boost libs |
| 39 | +set(BOOST_LIBS_OPTIONAL "" CACHE STRING "Boost libs to be compiled" FORCE) |
| 40 | + |
| 41 | +# File lcid.cpp from Boost_locale.cpp doesn't compile on MSVC, so we exclude them from the default |
| 42 | +# targets being built by the project (only targets explicitly used by other targets will be built). |
| 43 | +CPMAddPackage( |
| 44 | + NAME boost-cmake |
| 45 | + GITHUB_REPOSITORY Orphis/boost-cmake |
| 46 | + GIT_TAG 7f97a08b64bd5d2e53e932ddf80c40544cf45edf |
| 47 | + EXCLUDE_FROM_ALL |
| 48 | +) |
| 49 | + |
| 50 | +set(CMAKE_POSITION_INDEPENDENT_CODE ${OLD_CMAKE_POSITION_INDEPENDENT_CODE}) |
| 51 | +set(CMAKE_CXX_FLAGS "${PREVIOUS_CMAKE_CXX_FLAGS}") |
| 52 | + |
| 53 | +foreach(name IN ITEMS |
| 54 | + atomic |
| 55 | + chrono |
| 56 | + container |
| 57 | + date_time |
| 58 | + filesystem |
| 59 | + iostreams |
| 60 | + log |
| 61 | + system |
| 62 | + thread |
| 63 | + timer |
| 64 | + ) |
| 65 | + if(TARGET Boost_${name}) |
| 66 | + set_target_properties(Boost_${name} PROPERTIES FOLDER third_party/boost) |
| 67 | + endif() |
| 68 | +endforeach() |
0 commit comments