CMakeLists.txt 1.37 KB
Newer Older
Tobias Lasser's avatar
Tobias Lasser committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
cmake_minimum_required(VERSION 3.9)

# set the name of the module
set(ELSA_MODULE_NAME solvers)
set(ELSA_MODULE_TARGET_NAME elsa_solvers)
set(ELSA_MODULE_EXPORT_TARGET elsa_${ELSA_MODULE_NAME}Targets)


# list all the headers of the module
set(MODULE_HEADERS
        Solver.h
        GradientDescent.h)

# list all the code files of the module
set(MODULE_SOURCES
        Solver.cpp
        GradientDescent.cpp)


# build the module library
add_library(${ELSA_MODULE_TARGET_NAME} ${MODULE_HEADERS} ${MODULE_SOURCES})
add_library(elsa::${ELSA_MODULE_NAME} ALIAS ${ELSA_MODULE_TARGET_NAME})
23
add_dependencies(elsa ${ELSA_MODULE_TARGET_NAME})
Tobias Lasser's avatar
Tobias Lasser committed
24

25
target_link_libraries(${ELSA_MODULE_TARGET_NAME} PUBLIC elsa_core elsa_logging elsa_problems)
Tobias Lasser's avatar
Tobias Lasser committed
26
27
28

target_include_directories(${ELSA_MODULE_TARGET_NAME}
        PUBLIC
29
        $<INSTALL_INTERFACE:include/elsa/${ELSA_MODULE_NAME}>
Tobias Lasser's avatar
Tobias Lasser committed
30
31
32
33
34
35
        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
        )


# require C++17
target_compile_features(${ELSA_MODULE_TARGET_NAME} PUBLIC cxx_std_17)
36
37
# set -fPIC
set_target_properties(${ELSA_MODULE_TARGET_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
Tobias Lasser's avatar
Tobias Lasser committed
38
39
40
41
42
43
44
45
46
47
48
49
50


# build the tests (if enabled)
if(ELSA_TESTING)
    add_subdirectory(tests)
endif(ELSA_TESTING)


# register the module
registerComponent(${ELSA_MODULE_NAME})

# install the module
InstallElsaModule(${ELSA_MODULE_NAME} ${ELSA_MODULE_TARGET_NAME} ${ELSA_MODULE_EXPORT_TARGET})