Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ SET(CMAKE_CXX_STANDARD 17)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
SET(CMAKE_CXX_EXTENSIONS OFF)

FIND_PACKAGE(Boost 1.67.0 REQUIRED)
OPTION(GET_BOOST "Get boost lib." OFF)

IF(${GET_BOOST})
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/IntegrateBoost.cmake)
integrate_boost()
ELSE()
FIND_PACKAGE(Boost 1.67.0 REQUIRED)
ENDIF()

#disable the search for boost-cmake.
SET(Boost_NO_BOOST_CMAKE ON)
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ $ mkdir Debug
$ cd Debug
$ cmake -DCMAKE_BUILD_TYPE=Debug .. -G "Unix Makefiles"
$ make -j4 install
####### Automatic integrate Boost library
$ mkdir build && cd build
$ cmake -DGET_BOOST=ON -DCMAKE_BUILD_TYPE=Release ../ -G "Unix Makefiles"
$ make -j4 install
```

### Windows \:
Expand Down
53 changes: 53 additions & 0 deletions cmake/IntegrateBoost.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# file: IntegrateBoost.cmake
# date: 2022-09-02


set(
BOOST_URL
"https://boostorg.jfrog.io/artifactory/main/release/1.67.0/source/boost_1_67_0.tar.gz"
)

set(BOOST_ROOT_DIR ${CMAKE_SOURCE_DIR}/build/_boost)
set(BOOST_SRC_DIR ${BOOST_ROOT_DIR}/boost)
set(BOOST_INSTALL_DIR ${BOOST_ROOT_DIR}/installation)


macro(download_boost)
message(STATUS "Downloading boost...")
message(STATUS "Target boost URL: ${BOOST_URL}")
execute_process(COMMAND mkdir -p ${BOOST_ROOT_DIR})
execute_process(COMMAND bash -c "cd ${BOOST_ROOT_DIR} && wget ${BOOST_URL}")
execute_process(COMMAND bash -c "cd ${BOOST_ROOT_DIR} && tar -xvzf ./*.tar.gz")
execute_process(COMMAND bash -c "cd ${BOOST_ROOT_DIR} && rm ./*.tar.gz")
execute_process(COMMAND bash -c "cd ${BOOST_ROOT_DIR} && mv boost* boost")
endmacro()


macro(install_boost)
message(STATUS "Installing boost...")
execute_process(COMMAND mkdir -p ${BOOST_INSTALL_DIR})
execute_process(
COMMAND
bash -c "cd ${BOOST_SRC_DIR} && ./bootstrap.sh --prefix=${BOOST_INSTALL_DIR}")
execute_process(COMMAND bash -c "cd ${BOOST_SRC_DIR} && ./b2 install")
endmacro()


macro(config_boost)
message(STATUS "Config boost lib...")
set(BOOST_ROOT ${BOOST_INSTALL_DIR})
set(Boost_INCLUDE_DIR ${BOOST_INSTALL_DIR}/include)
set(Boost_LIBRARY_DIRS ${BOOST_INSTALL_DIR}/lib)
find_package(Boost 1.67.0 REQUIRED)
endmacro()


macro(integrate_boost)
if(Boost_FOUND)
message(STATUS "Boost lib already exists")
else()
download_boost()
install_boost()
config_boost()
endif()
endmacro()