CMakeLists.txt 2.32 KB
Newer Older
Tobias Lasser's avatar
Tobias Lasser committed
1
2
3
4
5
6
7
8
cmake_minimum_required(VERSION 3.9)

# setup macro for component registration
# so you can use find_package(elsa COMPONENT name)
macro(registerComponent name)
    set(ELSA_REGISTERED_COMPONENTS "${ELSA_REGISTERED_COMPONENTS};${name}" PARENT_SCOPE)
endmacro()

David Frank's avatar
David Frank committed
9
# macro for the unit tests
10
macro(ELSA_TEST NAME)
David Frank's avatar
David Frank committed
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
    # create the test executable
    add_executable(test_${NAME} test_${NAME}.cpp test_main.cpp)
    # 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})

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

# add sanitizers if in debug mode
if(${CMAKE_BUILD_TYPE} MATCHES "Debug")
    include(${PROJECT_SOURCE_DIR}/cmake/Sanitizers.cmake)
endif()

33
34
35
# add a general custom target "elsa" that includes everything
add_custom_target(elsa)

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


51
52
53
54
55
56
57
58
59
60
61
# if stand-alone and option set, turn on all warnings for all components
if(${ELSA_MASTER_PROJECT} AND ${ELSA_BUILD_WITH_MORE_WARNINGS})
    foreach(_component ${ELSA_REGISTERED_COMPONENTS})
        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()
    endforeach(_component ELSA_REGISTERED_COMPONENTS)
endif()
David Frank's avatar
David Frank committed
62

Tobias Lasser's avatar
Tobias Lasser committed
63
64
# propogate the variable to the parent scope
set(ELSA_REGISTERED_COMPONENTS "${ELSA_REGISTERED_COMPONENTS};" PARENT_SCOPE)