From 4c614126120c1c254db30c404ef9d61582b8e72a Mon Sep 17 00:00:00 2001 From: TeoGiane Date: Mon, 12 Jun 2023 11:16:54 +0200 Subject: [PATCH] Use FetchContent to make math availlable --- CMakeLists.txt | 56 +++++++++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ba6d3e9c9..57f1c3709 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}") @@ -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 " ") @@ -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