CMakeLists.txt 3.29 KB
Newer Older
Tobias Lasser's avatar
Tobias Lasser committed
1
cmake_minimum_required(VERSION 3.9)
Tobias Lasser's avatar
Tobias Lasser committed
2
project(elsa VERSION 0.5
Tobias Lasser's avatar
Tobias Lasser committed
3
4
5
6
7
8
9
10
11
        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)
Nikola Dinev's avatar
Nikola Dinev committed
12
option(BUILD_ELSA_PROJECTORS_CUDA "Attempts to build CUDA projectors if set" ON)
Jens Petit's avatar
Jens Petit committed
13
option(ELSA_COVERAGE "Enables test coverage reporting" OFF)
Tobias Lasser's avatar
Tobias Lasser committed
14
15
16
17
18
19
20
21


# ------------ general setup -----------
# ------------

# add our cmake modules under cmake/
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})

22
23
# set default built type to "Release" (if no other specified)
set(DEFAULT_BUILD_TYPE "Release")
Tobias Lasser's avatar
Tobias Lasser committed
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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 -----------
# ------------

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)


Jens Petit's avatar
Jens Petit committed
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# ------------ setup coverage test -----------
# ------------

if(ELSA_COVERAGE)
    message(STATUS "elsa coverage is enabled")

    include(CodeCoverage)
    APPEND_COVERAGE_COMPILER_FLAGS()
    set(COVERAGE_LCOV_EXCLUDES '${PROJECT_SOURCE_DIR}/thirdparty/*' '/usr/*')
    SETUP_TARGET_FOR_COVERAGE_LCOV(NAME test_coverage EXECUTABLE ctest)
endif(ELSA_COVERAGE)



Tobias Lasser's avatar
Tobias Lasser committed
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# ------------ 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)