CMakeLists.txt 2.49 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()

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# macro for the unit tests
MACRO (ELSA_TEST NAME)
    # 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})
        set(ELSA_JUNIT_ARGUMENTS "-r junit" "-o 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})
ENDMACRO (ELSA_TEST)
Tobias Lasser's avatar
Tobias Lasser committed
26
27
28
29
30
31

# add the elsa modules
add_subdirectory(core)
add_subdirectory(logging)
add_subdirectory(io)
add_subdirectory(operators)
Tobias Lasser's avatar
Tobias Lasser committed
32
33
34
add_subdirectory(functionals)
add_subdirectory(problems)
add_subdirectory(solvers)
35
add_subdirectory(projectors)
36
if(ELSA_BUILD_CUDA_PROJECTORS)
Nikola Dinev's avatar
Nikola Dinev committed
37
    add_subdirectory(projectors_cuda)
38
endif(ELSA_BUILD_CUDA_PROJECTORS)
39
add_subdirectory(generators)
Tobias Lasser's avatar
Tobias Lasser committed
40
41


42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#---------------------------------------------------------------------------------------
# Turn on compiler warnings and sanitizers for all components on, if wanted
#---------------------------------------------------------------------------------------
if(${ELSA_MASTER_PROJECT})
    foreach (_component ${ELSA_REGISTERED_COMPONENTS})
        # add warnings if enabled
        if(${ELSA_BUILD_WITH_MORE_WARNINGS})
            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()
        endif(${ELSA_BUILD_WITH_MORE_WARNINGS})
    endforeach (_component ELSA_REGISTERED_COMPONENTS)

    # add sanitizers if enabled
    if(${ELSA_BUILD_WITH_SANITIZERS})
        include(${PROJECT_SOURCE_DIR}/cmake/Sanitizers.cmake)
    endif(${ELSA_BUILD_WITH_SANITIZERS})
endif(${ELSA_MASTER_PROJECT})

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