Commit ff1d4cb1 authored by David Frank's avatar David Frank
Browse files

don't pull dependencies, if elsa is a subproject. This burdens other projects...

don't pull dependencies, if elsa is a subproject. This burdens other projects more, as they have to take care of the dependencies, but currently it seems like the better trade off, as we can stay cleaner in the project, that includes elsa
parent 2f14caf4
Pipeline #159096 failed with stages
in 15 seconds
cmake_minimum_required(VERSION 3.9)
# detect if elsa is being bundled, disable install and tests
if(NOT DEFINED PROJECT_NAME)
set(NOT_SUBPROJECT ON)
endif()
project(elsa VERSION 0.5
DESCRIPTION "elsa recon toolbox"
LANGUAGES CXX)
# ------------ elsa options ------------
# ------------
option(ELSA_TESTING "Enable the unit tests of elsa" ON)
option(GIT_SUBMODULE "Check submodules during build" ON)
option(BUILD_ELSA_PROJECTORS_CUDA "Attempts to build CUDA projectors if set" ON)
# ------------ general setup -----------
# ------------
# add our cmake modules under cmake/
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
# set default built type to "Debug" (if no other specified)
set(DEFAULT_BUILD_TYPE "Release")
include(SetDefaultBuildType)
# set where to install the exports/targets
set(INSTALL_CONFIG_DIR ${CMAKE_INSTALL_LIBDIR}/cmake)
# ------------ dependencies ------------
# ------------
# include the git submodule update
include(UpdateGitSubmodules)
# include the InstallElsaModule function
include(InstallElsaModule)
# setup the Eigen3 library
find_package(Eigen3 3.3 NO_MODULE QUIET) # first try if there is an installed version
if(NOT EIGEN3_INCLUDE_DIR) # if not found, try our submodule
set(EIGEN3_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/thirdparty/eigen3")
message(STATUS "Using eigen3 submodule at ${EIGEN3_INCLUDE_DIR}")
find_package(Eigen3 3.3 REQUIRED)
endif()
# ------------ setup testing -----------
# ------------
# reset ELSA_TESTING to only be active, if it's NOT a subproject
if(NOT NOT_SUBPROJECT)
set(ELSA_TESTING OFF)
endif()
if(ELSA_TESTING)
message(STATUS "elsa testing is enabled")
enable_testing()
add_subdirectory(thirdparty/Catch2)
# add the CMake modules for automatic test discovery
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/thirdparty/Catch2/contrib" ${CMAKE_MODULE_PATH})
else(ELSA_TESTING)
message(STATUS "elsa testing is disabled")
endif(ELSA_TESTING)
# ------------ add code/docs -----------
# ------------
# the elsa library
add_subdirectory(elsa)
# the documentation
add_subdirectory(docs EXCLUDE_FROM_ALL)
# the examples
add_subdirectory(examples EXCLUDE_FROM_ALL)
# ------------ setup installation ------
# ------------
# set up the target/library for make install
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
# setup the ElsaConfig*.cmake files
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/elsa/elsaConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
configure_package_config_file(
${CMAKE_CURRENT_LIST_DIR}/cmake/elsaConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/elsa/elsaConfig.cmake
INSTALL_DESTINATION ${INSTALL_CONFIG_DIR}
)
# install the config files
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/elsa/elsaConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/elsa/elsaConfigVersion.cmake
DESTINATION ${INSTALL_CONFIG_DIR}
)
# this puts the local build tree into the user package repository, but not the installed version...
# ...but we rely on the paths in the installed version. sigh. commented out for now.
#export(PACKAGE elsa)
cmake_minimum_required(VERSION 3.9)
# detect if elsa is being bundled, disable install and tests
if(NOT DEFINED PROJECT_NAME)
set(NOT_SUBPROJECT ON)
else()
set(SUBPROJECT ON)
message(STATUS "Including elsa as a subproject")
endif()
project(elsa VERSION 0.5
DESCRIPTION "elsa recon toolbox"
LANGUAGES CXX)
# ------------ elsa options ------------
# ------------
option(ELSA_TESTING "Enable the unit tests of elsa" ON)
option(GIT_SUBMODULE "Check submodules during build" ON)
option(BUILD_ELSA_PROJECTORS_CUDA "Attempts to build CUDA projectors if set" ON)
# ------------ general setup -----------
# ------------
# add our cmake modules under cmake/
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
# set default built type to "Debug" (if no other specified)
set(DEFAULT_BUILD_TYPE "Release")
include(SetDefaultBuildType)
# set where to install the exports/targets
set(INSTALL_CONFIG_DIR ${CMAKE_INSTALL_LIBDIR}/cmake)
# ------------ dependencies ------------
# ------------
# only populate the dependencies, iff it's a standalone project!
if(NOT_SUBPROJECT)
# include the git submodule update
include(UpdateGitSubmodules)
# setup the Eigen3 library
find_package(Eigen3 3.3 NO_MODULE QUIET) # first try if there is an installed version
if(NOT EIGEN3_INCLUDE_DIR) # if not found, try our submodule
set(EIGEN3_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/thirdparty/eigen3")
message(STATUS "Using eigen3 submodule at ${EIGEN3_INCLUDE_DIR}")
find_package(Eigen3 3.3 REQUIRED)
endif()
else()
message(STATUS " No dependencies added for elsa, as it's a subproject")
endif()
# include the In stallElsaModule function
include(InstallElsaModule)
# ------------ setup testing -----------
# ------------
# reset ELSA_TESTING to only be active, if it's a standlone project
if(SUBPROJECT)
set(ELSA_TESTING OFF)
endif()
if(ELSA_TESTING)
message(STATUS "elsa testing is enabled")
enable_testing()
add_subdirectory(thirdparty/Catch2)
# add the CMake modules for automatic test discovery
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/thirdparty/Catch2/contrib" ${CMAKE_MODULE_PATH})
else(ELSA_TESTING)
message(STATUS " elsa testing is disabled")
endif(ELSA_TESTING)
# ------------ add code/docs -----------
# ------------
# the elsa library
add_subdirectory(elsa)
# the documentation
add_subdirectory(docs EXCLUDE_FROM_ALL)
# the examples
add_subdirectory(examples EXCLUDE_FROM_ALL)
# ------------ setup installation ------
# ------------
# set up the target/library for make install
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
# setup the ElsaConfig*.cmake files
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/elsa/elsaConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
configure_package_config_file(
${CMAKE_CURRENT_LIST_DIR}/cmake/elsaConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/elsa/elsaConfig.cmake
INSTALL_DESTINATION ${INSTALL_CONFIG_DIR}
)
# install the config files
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/elsa/elsaConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/elsa/elsaConfigVersion.cmake
DESTINATION ${INSTALL_CONFIG_DIR}
)
# this puts the local build tree into the user package repository, but not the installed version...
# ...but we rely on the paths in the installed version. sigh. commented out for now.
#export(PACKAGE elsa)
==== BASE ====
......@@ -23,16 +23,14 @@ set(MODULE_SOURCES
add_library(${ELSA_MODULE_TARGET_NAME} ${MODULE_HEADERS} ${MODULE_SOURCES})
add_library(elsa::${ELSA_MODULE_NAME} ALIAS ${ELSA_MODULE_TARGET_NAME})
target_link_libraries(${ELSA_MODULE_TARGET_NAME} PUBLIC spdlog::spdlog)
target_include_directories(${ELSA_MODULE_TARGET_NAME}
PUBLIC
$<INSTALL_INTERFACE:include/${ELSA_MODULE_NAME}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
)
target_include_directories(${ELSA_MODULE_TARGET_NAME}
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/thirdparty/spdlog/include>
)
# require C++17
target_compile_features(${ELSA_MODULE_TARGET_NAME} PUBLIC cxx_std_17)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment