Notice to GitKraken users: A vulnerability has been found in the SSH key generation of GitKraken versions 7.6.0 to 8.0.0 (https://www.gitkraken.com/blog/weak-ssh-key-fix). If you use GitKraken and have generated a SSH key using one of these versions, please remove it both from your local workstation and from your LRZ GitLab profile.

21.10.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

CMakeLists.txt 3.03 KB
Newer Older
Tobias Lasser's avatar
Tobias Lasser committed
1
2
cmake_minimum_required(VERSION 3.9)

3
4
# setup macro for component registration, so you can use find_package(elsa COMPONENT name)
# also sets all target names
Tobias Lasser's avatar
Tobias Lasser committed
5
6
macro(registerComponent name)
    set(ELSA_REGISTERED_COMPONENTS "${ELSA_REGISTERED_COMPONENTS};${name}" PARENT_SCOPE)
7
    set(ELSA_REGISTERED_TARGETS "${ELSA_REGISTERED_TARGETS};elsa_${name}" PARENT_SCOPE)
Tobias Lasser's avatar
Tobias Lasser committed
8
9
endmacro()

10

David Frank's avatar
David Frank committed
11
# macro for the unit tests
12
macro(ELSA_TEST NAME)
David Frank's avatar
David Frank committed
13
    # create the test executable
14
    add_executable(test_${NAME} EXCLUDE_FROM_ALL test_${NAME}.cpp test_main.cpp)
David Frank's avatar
David Frank committed
15
16
17
18
19
20
21
22
23
24
    # add catch and the corresponding elsa library
    target_link_libraries(test_${NAME} PRIVATE Catch2::Catch2 ${ELSA_MODULE_TARGET_NAME})
    # enable C++17
    target_compile_features(test_${NAME} PUBLIC cxx_std_17)

    # if we use JUnit reporter handle arguments
    if(${ELSA_CREATE_JUNIT_REPORTS})
        file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/test_reports)
        set(ELSA_JUNIT_ARGUMENTS "-r junit" "-o ${PROJECT_BINARY_DIR}/test_reports/test_${NAME}.xml")
    endif(${ELSA_CREATE_JUNIT_REPORTS})
25
    add_dependencies(tests test_${NAME})
David Frank's avatar
David Frank committed
26
27
28

    # let Catch discover and register all the test cases
    catch_discover_tests(test_${NAME} TEST_SPEC ${ELSA_JUNIT_ARGUMENTS})
29
endmacro(ELSA_TEST)
David Frank's avatar
David Frank committed
30

31

David Frank's avatar
David Frank committed
32
33
34
35
36
# add sanitizers if in debug mode
if(${CMAKE_BUILD_TYPE} MATCHES "Debug")
    include(${PROJECT_SOURCE_DIR}/cmake/Sanitizers.cmake)
endif()

37

Tobias Lasser's avatar
Tobias Lasser committed
38
39
40
41
42
# add the elsa modules
add_subdirectory(core)
add_subdirectory(logging)
add_subdirectory(io)
add_subdirectory(operators)
Tobias Lasser's avatar
Tobias Lasser committed
43
44
45
add_subdirectory(functionals)
add_subdirectory(problems)
add_subdirectory(solvers)
46
add_subdirectory(projectors)
David Frank's avatar
David Frank committed
47
if(ELSA_BUILD_CUDA_PROJECTORS)
Nikola Dinev's avatar
Nikola Dinev committed
48
    add_subdirectory(projectors_cuda)
David Frank's avatar
David Frank committed
49
endif(ELSA_BUILD_CUDA_PROJECTORS)
50
add_subdirectory(generators)
Tobias Lasser's avatar
Tobias Lasser committed
51
52


53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# library to build and add all registered components of the library
add_library(elsa_all INTERFACE)
add_library(elsa::all ALIAS elsa_all)

# link against all modules
target_link_libraries(elsa_all INTERFACE ${ELSA_REGISTERED_TARGETS})
target_include_directories(elsa_all INTERFACE
        $<INSTALL_INTERFACE:include/elsa/>
        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
        )

# register the all "module"
registerComponent(all)

# install the all module and the elsa.h file
InstallElsaModule(all elsa_all elsa_allTargets)
install(FILES elsa.h
        DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/elsa/)


73
74
# if stand-alone and option set, turn on all warnings for all components
if(${ELSA_MASTER_PROJECT} AND ${ELSA_BUILD_WITH_MORE_WARNINGS})
75
    list(REMOVE_ITEM ELSA_REGISTERED_COMPONENTS "")
76
    foreach(_component ${ELSA_REGISTERED_COMPONENTS})
77
78
79
80
81
82
83
        if (NOT(_component MATCHES "projector_kernels"))
            if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang")
                target_compile_options(elsa_${_component} PUBLIC -Wall -Wextra -Wconversion -pedantic -Wfatal-errors)
            endif()
            if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
                target_compile_options(elsa_${_component} PUBLIC /W3 /WX)
            endif()
84
85
86
        endif()
    endforeach(_component ELSA_REGISTERED_COMPONENTS)
endif()