diff --git a/algo/CMakeLists.txt b/algo/CMakeLists.txt index 60d0bd9993f917ededef158ace472798e6d8043e..def6ea41efc2d18d249eda2fadc87a8d36fcf610 100644 --- a/algo/CMakeLists.txt +++ b/algo/CMakeLists.txt @@ -1,11 +1,13 @@ cmake_minimum_required(VERSION 3.14.0 FATAL_ERROR) cmake_policy(VERSION 3.14...3.23) -if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) - set(CBM_ONLINE_STANDALONE ON) - project(CbmOnline) -else() - set(CBM_ONLINE_STANDALONE OFF) +if (NOT DEFINED CBM_ONLINE_STANDALONE) + if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) + set(CBM_ONLINE_STANDALONE ON) + project(CbmOnline) + else() + set(CBM_ONLINE_STANDALONE OFF) + endif() endif() if (CBM_ONLINE_STANDALONE) @@ -46,7 +48,6 @@ if (CBM_ONLINE_STANDALONE) set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") list(PREPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules") include(CbmMacros) # for 'download_project_if_needed', 'Gen_Exe_Script' macro - include(../external/InstallGtest.cmake) add_subdirectory(../external external) endif() diff --git a/external/InstallFlesnet.cmake b/external/InstallFlesnet.cmake index 56470c49d7186c12e5d0213ac8b234927844f282..9b01cafdb3c88ed06d948f670b62630657a8fd72 100644 --- a/external/InstallFlesnet.cmake +++ b/external/InstallFlesnet.cmake @@ -7,7 +7,7 @@ set(FLESNET_VERSION cdc7893481aa10d51070d965ae9fc6eebfe91ac2) # 2024-01-23 set(FLESNET_SRC_URL "https://github.com/cbm-fles/flesnet") -set(FLESNET_DESTDIR "${PROJECT_BINARY_DIR}/external/flesnet-prefix") +set(FLESNET_DESTDIR "${CMAKE_CURRENT_BINARY_DIR}/flesnet-prefix") set(FLESNET_BIN_PREFIX "${FLESNET_DESTDIR}/src/flesnet-build") download_project_if_needed( diff --git a/external/InstallYamlCpp.cmake b/external/InstallYamlCpp.cmake index 5666fc175b7dbb0fa57b4b7e876eba8d7542b6a3..fb111639066b736a364916d5926cb1f102c39555 100644 --- a/external/InstallYamlCpp.cmake +++ b/external/InstallYamlCpp.cmake @@ -1,14 +1,15 @@ set(YAMLCPP_VERSION 0579ae3d976091d7d664aa9d2527e0d0cff25763) # version 0.7.0 set(YAMLCPP_SRC_URL "https://github.com/jbeder/yaml-cpp") -set(YAMLCPP_DESTDIR "${CMAKE_BINARY_DIR}/external/YAMLCPP-prefix") - -#set(YAMLCPP_BYPRODUCT "${PROJECT_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}yaml-cpp${CMAKE_SHARED_LIBRARY_SUFFIX}") +set(YAMLCPP_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/yaml-cpp") +set(YAMLCPP_INCLUDE_DIR "${YAMLCPP_SRC_DIR}/include") +set(YAMLCPP_DESTDIR "${CMAKE_CURRENT_BINARY_DIR}/yaml-cpp-prefix") +set(YAMLCPP_BYPRODUCT "${YAMLCPP_DESTDIR}/src/yaml-cpp-build/${CMAKE_STATIC_LIBRARY_PREFIX}yaml-cpp${CMAKE_STATIC_LIBRARY_SUFFIX}") download_project_if_needed(PROJECT yaml-cpp GIT_REPOSITORY ${YAMLCPP_SRC_URL} GIT_TAG ${YAMLCPP_VERSION} - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/yaml-cpp + SOURCE_DIR ${YAMLCPP_SRC_DIR} TEST_FILE CMakeLists.txt ) @@ -25,7 +26,7 @@ endif() ExternalProject_Add( yaml-cpp - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/yaml-cpp + SOURCE_DIR ${YAMLCPP_SRC_DIR} GIT_CONFIG advice.detachedHead=false BUILD_IN_SOURCE 0 LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 @@ -35,16 +36,16 @@ ExternalProject_Add( -DYAML_BUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON BUILD_COMMAND ${YAMLCPP_BUILD_COMMAND} yaml-cpp - BUILD_BYPRODUCTS ${PROJECT_BINARY_DIR}/external/yaml-cpp-prefix/src/yaml-cpp-build/${CMAKE_STATIC_LIBRARY_PREFIX}yaml-cpp${CMAKE_STATIC_LIBRARY_SUFFIX} + BUILD_BYPRODUCTS ${YAMLCPP_BYPRODUCT} INSTALL_COMMAND "" ) # pre-create empty directory to make INTERFACE_INCLUDE_DIRECTORIES happy -file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/external/yaml-cpp/include) +file(MAKE_DIRECTORY ${YAMLCPP_INCLUDE_DIR}) add_library(external::yaml-cpp STATIC IMPORTED GLOBAL) add_dependencies(external::yaml-cpp yaml-cpp) set_target_properties(external::yaml-cpp PROPERTIES - IMPORTED_LOCATION ${PROJECT_BINARY_DIR}/external/yaml-cpp-prefix/src/yaml-cpp-build/${CMAKE_STATIC_LIBRARY_PREFIX}yaml-cpp${CMAKE_STATIC_LIBRARY_SUFFIX} - INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_SOURCE_DIR}/external/yaml-cpp/include + IMPORTED_LOCATION ${YAMLCPP_BYPRODUCT} + INTERFACE_INCLUDE_DIRECTORIES ${YAMLCPP_INCLUDE_DIR} )