Skip to content

Commit

Permalink
Use FetchContent to make math availlable
Browse files Browse the repository at this point in the history
  • Loading branch information
TeoGiane committed Jun 12, 2023
1 parent d768c11 commit 4c61412
Showing 1 changed file with 35 additions and 21 deletions.
56 changes: 35 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,44 @@ set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL TRUE)

# Require PkgConfig
find_package(PkgConfig REQUIRED)

# Require OpenMP
find_package(OpenMP REQUIRED)

# Clone bayesmix-dev/math into lib/math
include(cmake/GitUtils.cmake)
git_clone(
PROJECT_NAME math
GIT_URL https://github.com/bayesmix-dev/math.git
GIT_BRANCH develop
DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/lib
# Include FetchContent
include(FetchContent)

# Set up FetchContent options
set(FETCHCONTENT_BASE_DIR ${CMAKE_CURRENT_LIST_DIR}/lib/_deps)
set(FETCHCONTENT_QUIET OFF)
set(FETCHCONTENT_UPDATES_DISCONNECTED ON)
set(BUILD_SHARED_LIBS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(BUILD_TESTING OFF)

# Make bayesmix-dev/math available
FetchContent_Declare(math
GIT_REPOSITORY "https://github.com/bayesmix-dev/math.git"
GIT_TAG "develop"
)
FetchContent_MakeAvailable(math)

# Clone bayesmix-dev/math into lib/math
# include(cmake/GitUtils.cmake)
# git_clone(
# PROJECT_NAME math
# GIT_URL https://github.com/bayesmix-dev/math.git
# GIT_BRANCH develop
# DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/lib
# )

# TBB CMake integration
message(STATUS "Using math TBB")
# Define TBB_ROOT Folder
set(TBB_ROOT ${CMAKE_CURRENT_LIST_DIR}/lib/math/lib/tbb)
file(COPY ${CMAKE_CURRENT_LIST_DIR}/lib/math/lib/tbb_2020.3/ DESTINATION ${TBB_ROOT})
# set(TBB_ROOT ${CMAKE_CURRENT_LIST_DIR}/lib/math/lib/tbb)
# file(COPY ${CMAKE_CURRENT_LIST_DIR}/lib/math/lib/tbb_2020.3/ DESTINATION ${TBB_ROOT})
set(TBB_ROOT ${math_SOURCE_DIR}/lib/tbb)
file(COPY ${math_SOURCE_DIR}/lib/tbb_2020.3/ DESTINATION ${TBB_ROOT})
# Build TBB Library with CMake Integration
include(${TBB_ROOT}/cmake/TBBBuild.cmake)
list(APPEND MAKE_ARGS "tbb_build_dir=${TBB_ROOT}")
Expand All @@ -53,13 +75,6 @@ if (NOT Protobuf_FOUND AND NOT PROTOBUF_FOUND AND NOT TARGET protobuf::libprotob
" or install google's protocol buffer (protobuf) library by hand.")
endif()

include(FetchContent)
set(FETCHCONTENT_QUIET OFF)
set(FETCHCONTENT_UPDATES_DISCONNECTED ON)
set(BUILD_SHARED_LIBS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(BUILD_TESTING OFF)

message(CHECK_START "Fetching Protobuf")
list(APPEND CMAKE_MESSAGE_INDENT " ")

Expand Down Expand Up @@ -97,16 +112,15 @@ set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(BASEPATH "${CMAKE_CURRENT_LIST_DIR}")
set(INCLUDE_PATHS
${BASEPATH}
${CMAKE_CURRENT_LIST_DIR}/lib/math
${CMAKE_CURRENT_LIST_DIR}/lib/math/lib/boost_1.78.0
${CMAKE_CURRENT_LIST_DIR}/lib/math/lib/eigen_3.4.0
${math_SOURCE_DIR}
${math_SOURCE_DIR}/lib/boost_1.78.0
${math_SOURCE_DIR}/lib/eigen_3.4.0
${math_SOURCE_DIR}/lib/sundials_6.1.1/include
${TBB_ROOT}/include
${CMAKE_CURRENT_LIST_DIR}/lib/math/lib/sundials_6.1.1/include
${CMAKE_CURRENT_BINARY_DIR}
${protobuf_SOURCE_DIR}/src
)


set(LINK_LIBRARIES
pthread
protobuf::libprotobuf
Expand Down

0 comments on commit 4c61412

Please sign in to comment.