File tree Expand file tree Collapse file tree 10 files changed +98
-34
lines changed Expand file tree Collapse file tree 10 files changed +98
-34
lines changed Original file line number Diff line number Diff line change @@ -2,16 +2,28 @@ cmake_minimum_required(VERSION 3.12)
22project (Boost-CMake)
33
44option (BOOST_DISABLE_TESTS "Do not build test targets, even if building standalone" OFF )
5+ option (BOOST_GIT "Get Boost from Git source" OFF )
56
67set (BOOST_URL "https://dl.bintray.com/boostorg/release/1.69.0/source/boost_1_69_0.tar.bz2" CACHE STRING "Boost download URL" )
78set (BOOST_URL_SHA256 "8f32d4617390d1c2d16f26a27ab60d97807b35440d45891fa340fc2648b04406" CACHE STRING "Boost download URL SHA256 checksum" )
9+ set (BOOST_GIT_URL "https://github.com/boostorg/boost.git" CACHE STRING "Boost Git URL to top-level repository" )
10+ set (BOOST_GIT_TAG "boost-1.69.0" CACHE STRING "Boost Git tag or branch name" )
811
912include (FetchContent)
10- FetchContent_Declare(
11- Boost
12- URL ${BOOST_URL}
13- URL_HASH SHA256=${BOOST_URL_SHA256}
14- )
13+
14+ if (BOOST_GIT)
15+ FetchContent_Declare(
16+ Boost
17+ GIT_REPOSITORY "${BOOST_GIT_URL} "
18+ GIT_TAG "${BOOST_GIT_TAG} "
19+ )
20+ else ()
21+ FetchContent_Declare(
22+ Boost
23+ URL ${BOOST_URL}
24+ URL_HASH SHA256=${BOOST_URL_SHA256}
25+ )
26+ endif ()
1527FetchContent_GetProperties(Boost)
1628
1729if (NOT Boost_POPULATED)
Original file line number Diff line number Diff line change @@ -30,9 +30,23 @@ set(BOOST_URL_SHA256 foobar)
3030add_subdirectory(boost-cmake)
3131```
3232
33+ If you prefer using Boost from Git, you can use the following:
34+ ```
35+ set(BOOST_GIT ON)
36+ add_subdirectory(boost-cmake)
37+ ```
38+
39+ For more advanced configuration, you can override the way to download the sources using [ FetchContent_Declare] ( https://cmake.org/cmake/help/latest/module/FetchContent.html ) :
40+ ```
41+ FetchContent_Declare(
42+ Boost
43+ SVN_REPOSITORY "svn+ssh://svn.company.com/boost"
44+ )
45+ ```
46+
3347If you have Boost sources already available and want to point to them, you can use the following:
3448```
35- set(BOOST_SOURCE /path/to/boost)
49+ set(FETCHCONTENT_SOURCE_DIR_boost /path/to/boost)
3650add_subdirectory(boost-cmake)
3751```
3852
Original file line number Diff line number Diff line change @@ -13,6 +13,11 @@ strategy:
1313 imageName : ' ubuntu-16.04'
1414 BUILD_TARGET : ' Linux'
1515 BUILD_COMPILER : ' Clang'
16+ Linux-Clang-Git :
17+ imageName : ' ubuntu-16.04'
18+ BUILD_TARGET : ' Linux'
19+ BUILD_COMPILER : ' Clang'
20+ BUILD_GIT : ' ON'
1621 Android-arm64 :
1722 imageName : ' ubuntu-16.04'
1823 BUILD_TARGET : ' Android'
6368 BUILD_COMPILER : $(BUILD_COMPILER)
6469 BUILD_ARCH : $(BUILD_ARCH)
6570 BUILD_TOOLCHAIN : $(BUILD_TOOLCHAIN)
71+ BUILD_GIT : $(BUILD_GIT)
6672 CCACHE_DISABLE : 1
Original file line number Diff line number Diff line change @@ -59,6 +59,10 @@ build_script() {
5959 mkdir build
6060 pushd build
6161
62+ if [[ " $BUILD_GIT " == " ON" ]]; then
63+ CMAKE_OPTIONS=" ${CMAKE_OPTIONS} -DCMAKE_GIT=ON"
64+ fi
65+
6266 if [[ " $BUILD_TARGET " == " Linux" ]]; then
6367 if [[ " $BUILD_COMPILER " == " GCC" ]]; then
6468 CC=gcc-5
@@ -69,21 +73,24 @@ build_script() {
6973 fi
7074 cmake .. -GNinja \
7175 -DCMAKE_C_COMPILER=$CC \
72- -DCMAKE_CXX_COMPILER=$CXX
76+ -DCMAKE_CXX_COMPILER=$CXX \
77+ $CMAKE_OPTIONS
7378 elif [[ " $BUILD_TARGET " == " Android" ]]; then
7479 cmake .. -GNinja \
7580 -DCMAKE_SYSTEM_NAME=Android \
7681 -DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=clang \
77- -DCMAKE_ANDROID_ARCH_ABI=${BUILD_ARCH}
82+ -DCMAKE_ANDROID_ARCH_ABI=${BUILD_ARCH} \
83+ $CMAKE_OPTIONS
7884 elif [[ " $BUILD_TARGET " == " macOS" ]]; then
79- cmake .. -GNinja
85+ cmake .. -GNinja $CMAKE_OPTIONS
8086 elif [[ " $BUILD_TARGET " == " iOS" ]]; then
8187 cmake .. -GNinja \
82- -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchains/ios.cmake
88+ -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchains/ios.cmake \
89+ $CMAKE_OPTIONS
8390 elif [[ " $BUILD_TARGET " == " Windows" ]]; then
8491 vcpath=$( vswhere.exe -latest -property installationPath)
8592 vcscript=" \" $vcpath \\ VC\\ Auxiliary\\ Build\\ vcvarsall.bat\" $BUILD_TOOLCHAIN "
86- cmd.exe /c " $vcscript & cmake .. -GNinja -DCMAKE_C_COMPILER=cl.exe -DCMAKE_CXX_COMPILER=cl.exe & ninja -v"
93+ cmd.exe /c " $vcscript & cmake .. -GNinja -DCMAKE_C_COMPILER=cl.exe -DCMAKE_CXX_COMPILER=cl.exe $CMAKE_OPTIONS & ninja -v"
8794 exit 0
8895 fi
8996
Original file line number Diff line number Diff line change 11# Detect Boost version
2- file (STRINGS "${BOOST_SOURCE} /boost/version.hpp" boost_version_raw
2+ if (EXISTS "${BOOST_SOURCE} /boost/version.hpp" )
3+ set (BOOST_MODULARIZED FALSE )
4+ set (boost_version_file "${BOOST_SOURCE} /boost/version.hpp" )
5+ message (STATUS "Boost format: archive" )
6+ elseif (EXISTS "${BOOST_SOURCE} /libs/config/include/boost/version.hpp" )
7+ set (BOOST_MODULARIZED TRUE )
8+ set (boost_version_file "${BOOST_SOURCE} /libs/config/include/boost/version.hpp" )
9+ message (STATUS "Boost format: modularized" )
10+ endif ()
11+
12+ file (STRINGS "${boost_version_file} " boost_version_raw
313 REGEX "define BOOST_VERSION "
414)
515string (REGEX MATCH "[0-9]+" boost_version_raw "${boost_version_raw} " )
616math (EXPR BOOST_VERSION_MAJOR "${boost_version_raw} / 100000" )
717math (EXPR BOOST_VERSION_MINOR "${boost_version_raw} / 100 % 1000" )
818math (EXPR BOOST_VERSION_PATCH "${boost_version_raw} % 100" )
919set (BOOST_VERSION "${BOOST_VERSION_MAJOR} .${BOOST_VERSION_MINOR} .${BOOST_VERSION_PATCH} " )
20+
21+ unset (boost_version_raw)
22+ unset (boost_version_file)
Original file line number Diff line number Diff line change @@ -41,6 +41,8 @@ _add_boost_lib(
4141 DEFINE_PRIVATE
4242 BOOST_CONTEXT_SOURCE=1
4343 BOOST_CONTEXT_EXPORT
44+ INCLUDE_PRIVATE
45+ ${BOOST_SOURCE} /libs/context/src/asm
4446 LINK
4547 Boost::thread
4648)
Original file line number Diff line number Diff line change 11#if defined(__APPLE__)
22 #if defined(__arm__)
3- #include "libs/context/src/asm/ jump_arm_aapcs_macho_gas.S"
3+ #include "jump_arm_aapcs_macho_gas.S"
44 #elif defined(__arm64__)
5- #include "libs/context/src/asm/ jump_arm64_aapcs_macho_gas.S"
5+ #include "jump_arm64_aapcs_macho_gas.S"
66 #else
77 // Other kinds of macOS or iOS Simulator
8- #include "libs/context/src/asm/ jump_combined_sysv_macho_gas.S"
8+ #include "jump_combined_sysv_macho_gas.S"
99 #endif
1010#elif defined(__linux__) || defined(__FreeBSD__)
1111 #if defined(__arm__)
12- #include "libs/context/src/asm/ jump_arm_aapcs_elf_gas.S"
12+ #include "jump_arm_aapcs_elf_gas.S"
1313 #elif defined(__aarch64__)
14- #include "libs/context/src/asm/ jump_arm64_aapcs_elf_gas.S"
14+ #include "jump_arm64_aapcs_elf_gas.S"
1515 #elif defined(__i386__)
16- #include "libs/context/src/asm/ jump_i386_sysv_elf_gas.S"
16+ #include "jump_i386_sysv_elf_gas.S"
1717 #elif defined(__x86_64__)
18- #include "libs/context/src/asm/ jump_x86_64_sysv_elf_gas.S"
18+ #include "jump_x86_64_sysv_elf_gas.S"
1919 #else
2020 #error "Unknown platform"
2121 #endif
Original file line number Diff line number Diff line change 11#if defined(__APPLE__)
22 #if defined(__arm__)
3- #include "libs/context/src/asm/ make_arm_aapcs_macho_gas.S"
3+ #include "make_arm_aapcs_macho_gas.S"
44 #elif defined(__arm64__)
5- #include "libs/context/src/asm/ make_arm64_aapcs_macho_gas.S"
5+ #include "make_arm64_aapcs_macho_gas.S"
66 #else
77 // Other kinds of macOS or iOS Simulator
8- #include "libs/context/src/asm/ make_combined_sysv_macho_gas.S"
8+ #include "make_combined_sysv_macho_gas.S"
99 #endif
1010#elif defined(__linux__) || defined(__FreeBSD__)
1111 #if defined(__arm__)
12- #include "libs/context/src/asm/ make_arm_aapcs_elf_gas.S"
12+ #include "make_arm_aapcs_elf_gas.S"
1313 #elif defined(__aarch64__)
14- #include "libs/context/src/asm/ make_arm64_aapcs_elf_gas.S"
14+ #include "make_arm64_aapcs_elf_gas.S"
1515 #elif defined(__i386__)
16- #include "libs/context/src/asm/ make_i386_sysv_elf_gas.S"
16+ #include "make_i386_sysv_elf_gas.S"
1717 #elif defined(__x86_64__)
18- #include "libs/context/src/asm/ make_x86_64_sysv_elf_gas.S"
18+ #include "make_x86_64_sysv_elf_gas.S"
1919 #else
2020 #error "Unknown platform"
2121 #endif
Original file line number Diff line number Diff line change 11#if defined(__APPLE__)
22 #if defined(__arm__)
3- #include "libs/context/src/asm/ ontop_arm_aapcs_macho_gas.S"
3+ #include "ontop_arm_aapcs_macho_gas.S"
44 #elif defined(__arm64__)
5- #include "libs/context/src/asm/ ontop_arm64_aapcs_macho_gas.S"
5+ #include "ontop_arm64_aapcs_macho_gas.S"
66 #else
77 // Other kinds of macOS or iOS Simulator
8- #include "libs/context/src/asm/ ontop_combined_sysv_macho_gas.S"
8+ #include "ontop_combined_sysv_macho_gas.S"
99 #endif
1010#elif defined(__linux__) || defined(__FreeBSD__)
1111 #if defined(__arm__)
12- #include "libs/context/src/asm/ ontop_arm_aapcs_elf_gas.S"
12+ #include "ontop_arm_aapcs_elf_gas.S"
1313 #elif defined(__aarch64__)
14- #include "libs/context/src/asm/ ontop_arm64_aapcs_elf_gas.S"
14+ #include "ontop_arm64_aapcs_elf_gas.S"
1515 #elif defined(__i386__)
16- #include "libs/context/src/asm/ ontop_i386_sysv_elf_gas.S"
16+ #include "ontop_i386_sysv_elf_gas.S"
1717 #elif defined(__x86_64__)
18- #include "libs/context/src/asm/ ontop_x86_64_sysv_elf_gas.S"
18+ #include "ontop_x86_64_sysv_elf_gas.S"
1919 #else
2020 #error "Unknown platform"
2121 #endif
Original file line number Diff line number Diff line change 11# Define the header-only Boost target
22add_library (Boost::boost INTERFACE IMPORTED GLOBAL )
3- target_include_directories (Boost::boost SYSTEM INTERFACE ${BOOST_SOURCE} )
43
54# Disable autolink
65target_compile_definitions (Boost::boost INTERFACE BOOST_ALL_NO_LIB=1)
6+
7+ if (BOOST_MODULARIZED)
8+ file (GLOB alllibs "${BOOST_SOURCE} /libs/*" "${BOOST_SOURCE} /libs/numeric/*" )
9+ foreach (lib IN LISTS alllibs)
10+ if (IS_DIRECTORY "${lib} /include" )
11+ target_include_directories (Boost::boost SYSTEM INTERFACE "${lib} /include" )
12+ endif ()
13+ endforeach ()
14+ else ()
15+ target_include_directories (Boost::boost SYSTEM INTERFACE ${BOOST_SOURCE} )
16+ endif ()
You can’t perform that action at this time.
0 commit comments