forked from Orphis/boost-cmake
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1abb90e
commit e1e89c4
Showing
14 changed files
with
215 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,15 +2,16 @@ cmake_minimum_required(VERSION 3.21...3.28) | |
|
||
project(Boost-CMake LANGUAGES C CXX VERSION 1.81.0) | ||
|
||
if(NOT PROJECT_IS_TOP_LEVEL) | ||
if(PROJECT_IS_TOP_LEVEL) | ||
message(STATUS "PROJECT_IS_TOP_LEVEL") | ||
else() | ||
option(BOOST_DISABLE_TESTS "Do not build test targets, even if building standalone" ON) | ||
endif() | ||
option(BOOST_USE_ALL_OPTIONAL_LIBS "Prepare all optional libs" ON) | ||
|
||
# ---- Add dependencies via CPM ---- | ||
# ---- Add/prepare dependency handling via CPM ---- | ||
# see https://github.com/TheLartians/CPM.cmake for more info | ||
|
||
include(cmake/CPM.cmake) | ||
|
||
if(EXISTS "$ENV{CPM_SOURCE_CACHE}/boost_1_81_0") | ||
set(FETCHCONTENT_SOURCE_DIR_BOOST "$ENV{CPM_SOURCE_CACHE}/boost_1_81_0" CACHE PATH "Boost source DIR") | ||
set(CPM_Boost_SOURCE ${FETCHCONTENT_SOURCE_DIR_BOOST} CACHE PATH "Manual override") | ||
|
@@ -23,6 +24,7 @@ set(BOOST_URL_SHA256 "71feeed900fbccca04a3b4f2f84a7c217186f28a940ed8b7ed4725986b | |
CACHE STRING "Boost download URL SHA256 checksum" | ||
) | ||
|
||
# ---- Add Boost source tar archive via FetchContent ---- | ||
include(FetchContent) | ||
FetchContent_Declare(Boost URL ${BOOST_URL} URL_HASH SHA256=${BOOST_URL_SHA256}) | ||
|
||
|
@@ -38,6 +40,13 @@ if(NOT Boost_POPULATED) | |
if(Patch_FOUND) | ||
message("Patch found: ${Patch_EXECUTABLE}") | ||
message("Patching Boost") | ||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/patches/${PROJECT_VERSION}/thread_future-01.patch) | ||
execute_process( | ||
COMMAND ${Patch_EXECUTABLE} -N -p1 -i | ||
${CMAKE_CURRENT_SOURCE_DIR}/patches/${PROJECT_VERSION}/thread_future-01.patch | ||
WORKING_DIRECTORY ${BOOST_SOURCE}/boost COMMAND_ECHO STDOUT | ||
) | ||
endif() | ||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/patches/${PROJECT_VERSION}/filesystem-01.patch) | ||
execute_process( | ||
COMMAND ${Patch_EXECUTABLE} -N -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/patches/${PROJECT_VERSION}/filesystem-01.patch | ||
|
@@ -74,7 +83,7 @@ include(AddBoostLib) | |
include(AddBoostTest) | ||
|
||
# NOTE: Install the missing CMakeList.txt file, but it will not yet used! CK | ||
# If the tar achive contains one, it will not overridden. | ||
# If the tar archive contains one, it will not overridden. | ||
configure_file(cmake/CMakeLists.txt.in ${BOOST_SOURCE}/CMakeLists.txt @ONLY) | ||
configure_file(cmake/Modules/ccache.cmake ${BOOST_SOURCE}/tools/cmake/include/ccache.cmake COPYONLY) | ||
|
||
|
@@ -91,40 +100,45 @@ if(USE_ANDROID) | |
set(CMAKE_ASM_COMPILER_TARGET "${CMAKE_CXX_COMPILER_TARGET}") | ||
endif() | ||
|
||
set(BOOST_LIBS_REQUIRED # Header only libs | ||
header | ||
serialization | ||
system | ||
thread | ||
chrono | ||
# TODO(CK): atomic filesystem | ||
) | ||
set(BOOST_LIBS_REQUIRED header) | ||
if(NOT BOOST_USE_ALL_OPTIONAL_LIBS) | ||
list(APPEND | ||
BOOST_LIBS_REQUIRED | ||
serialization | ||
system | ||
thread | ||
chrono | ||
atomic | ||
filesystem | ||
) | ||
endif() | ||
|
||
set(BOOST_LIBS_OPTIONAL | ||
# Compiled libs | ||
atomic | ||
chrono | ||
container | ||
container # warnings | ||
context | ||
coroutine | ||
date_time | ||
exception | ||
fiber | ||
fiber # warnings | ||
filesystem | ||
graph | ||
graph # warnings | ||
iostreams | ||
json | ||
# FIXME: locale # TODO(CK) to complex, refactory needed! | ||
log | ||
json # depends on container | ||
# FIXME: locale # NOTE: to complex, refactory needed! | ||
# TODO(CK) log # errors | ||
math | ||
mpi | ||
graph_parallel # TODO(CK) does this realy depends on mpi? | ||
mpi # warnings | ||
graph_parallel # TODO(CK): depends on graph; does this really depends on mpi? | ||
program_options | ||
# XXX python # NOTE: not supported, to complex module! | ||
random | ||
random # warnings | ||
regex | ||
serialization | ||
system | ||
test | ||
test # warnings | ||
thread | ||
timer | ||
type_erasure | ||
|
@@ -136,42 +150,42 @@ foreach(lib ${BOOST_LIBS_REQUIRED}) | |
include("libs/${lib}.cmake") | ||
endforeach() | ||
|
||
# FIXME: disabled for now! CK | ||
# foreach(lib ${BOOST_LIBS_OPTIONAL}) | ||
# # In case only a subset of modules is available (eg. after using bcp) | ||
# if(EXISTS "${BOOST_SOURCE}/libs/${lib}") | ||
# include("libs/${lib}.cmake") | ||
# endif() | ||
# endforeach() | ||
if(BOOST_USE_ALL_OPTIONAL_LIBS) | ||
foreach(lib ${BOOST_LIBS_OPTIONAL}) | ||
# In case only a subset of modules is available | ||
if(EXISTS "${BOOST_SOURCE}/libs/${lib}") | ||
include("libs/${lib}.cmake") | ||
endif() | ||
endforeach() | ||
endif() | ||
|
||
# TODO: Move those to option() calls in the right file | ||
############################################################# | ||
# TODO(CK): Move this to libs/header.cmake in the right file | ||
find_package(Threads) | ||
|
||
# Compilation options required by all platforms | ||
target_compile_definitions( | ||
boost | ||
INTERFACE $<$<CONFIG:Release>:BOOST_DISABLE_ASSERT> | ||
BOOST_ASIO_NO_DEPRECATED | ||
BOOST_SYSTEM_NO_DEPRECATED | ||
BOOST_THREAD_VERSION=5 | ||
BOOST_THREAD_USES_CHRONO | ||
BOOST_THREAD_PROVIDES_EXECUTORS | ||
) | ||
target_link_libraries(boost INTERFACE Threads::Threads) | ||
target_compile_definitions(boost INTERFACE BOOST_BIND_GLOBAL_PLACEHOLDERS) | ||
|
||
if(PROJECT_IS_TOP_LEVEL) | ||
message(STATUS "PROJECT_IS_TOP_LEVEL") | ||
else() | ||
if(NOT PROJECT_IS_TOP_LEVEL) | ||
add_library(Boost::asio ALIAS boost) | ||
endif() | ||
############################################################# | ||
|
||
if(UNIX) | ||
if(USE_APPLE) | ||
# TODO(CK): too many deprectated warnings! | ||
# TODO(CK): too many deprecated warnings! | ||
# intrusive/pointer_rebind.hpp:81:35: warning: 'rebind<std::pair<const int, int>>' is deprecated | ||
# fiber/future/async.hpp:57 'result_of<void (*())()>' is deprecated | ||
target_compile_options(boost INTERFACE -Wno-deprecated-declarations) | ||
target_compile_options(boost INTERFACE -Wno-deprecated-declarations -Wno-deprecated-copy-with-user-provided-copy) | ||
else() | ||
target_compile_definitions(boost INTERFACE BOOST_NO_AUTO_PTR) | ||
endif() | ||
|
@@ -191,6 +205,7 @@ endif() | |
# PackageProject.cmake will be used to make our target installable | ||
|
||
if(BOOST_USE_ORIGINAL_PackageProject) | ||
include(cmake/CPM.cmake) | ||
CPMAddPackage("gh:TheLartians/[email protected]") | ||
|
||
set(BOOST_LIBS ${BOOST_LIBS_OPTIONAL}) | ||
|
@@ -218,15 +233,18 @@ else() | |
endif() | ||
|
||
packageProject( | ||
NAME Boost TARGETS ${BOOST_LIBS} | ||
NAME Boost | ||
TARGETS ${BOOST_LIBS} | ||
VERSION ${BOOST_VERSION} | ||
NAMESPACE Boost | ||
BINARY_DIR ${PROJECT_BINARY_DIR} ARCH_INDEPENDENT NO | ||
INCLUDE_DIR ${BOOST_SOURCE}/boost | ||
INCLUDE_DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/boost | ||
DISABLE_VERSION_SUFFIX YES | ||
COMPATIBILITY SameMajorVersion | ||
CPACK NO | ||
DEPENDENCIES "Threads" # TODO(CK): variable list needed for: BZIP2; Iconf; ICU; MPI; ZLIB | ||
) | ||
|
||
include(cmake/AddUninstallTarget.cmake) | ||
include(CPack) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
.PHONY: all fresh configure build test install format | ||
all: build | ||
|
||
fresh: | ||
cmake --workflow --preset Release --fresh | ||
|
||
configure: | ||
cmake --preset Release | ||
|
||
build: configure | ||
cmake --build --preset Release | ||
|
||
test: build | ||
ctest --build --preset Release | ||
|
||
install: test | ||
cmake --build --preset Release --target install | ||
|
||
format: | ||
git clang-format | ||
find . \( -type d -name build -o -name stagedir \) -prune -o \( -name '*.cmake' -o -name CMakeLists.txt \) -print > .cmakefiles.log | ||
#NO! cmake-format -i `cat .cmakefiles.log` | ||
ls -1 *.json >> .cmakefiles.log | ||
cmake-format -i CMakeLists.txt cmake/*.cmake cmake/*/*.cmake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.