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

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


# list all the headers of the module
set(MODULE_HEADERS
11
        elsaDefines.h
Tobias Lasser's avatar
Tobias Lasser committed
12
        Cloneable.h
13 14 15 16 17 18 19
        Descriptors/DataDescriptor.h
        Descriptors/DescriptorUtils.h
        Descriptors/VolumeDescriptor.h
        Descriptors/BlockDescriptor.h
        Descriptors/IdenticalBlocksDescriptor.h
        Descriptors/PartitionDescriptor.h
        Descriptors/RandomBlocksDescriptor.h
Tobias Lasser's avatar
Tobias Lasser committed
20
        DataContainer.h
21
        DataContainerIterator.h
22 23 24
        Handlers/DataHandler.h
        Handlers/DataHandlerCPU.h
        Handlers/DataHandlerMapCPU.h
Jens Petit's avatar
Jens Petit committed
25 26 27
        LinearOperator.h
        Expression.h
        ExpressionPredicates.h)
Tobias Lasser's avatar
Tobias Lasser committed
28 29 30

# list all the code files of the module
set(MODULE_SOURCES
31 32 33 34 35 36
        Descriptors/DataDescriptor.cpp
        Descriptors/VolumeDescriptor.cpp
        Descriptors/RandomBlocksDescriptor.cpp
        Descriptors/DescriptorUtils.cpp
        Descriptors/IdenticalBlocksDescriptor.cpp
        Descriptors/PartitionDescriptor.cpp
Tobias Lasser's avatar
Tobias Lasser committed
37
        DataContainer.cpp
38 39
        Handlers/DataHandlerCPU.cpp
        Handlers/DataHandlerMapCPU.cpp
Tobias Lasser's avatar
Tobias Lasser committed
40 41
        LinearOperator.cpp)

42 43 44
if(${ELSA_CUDA_VECTOR})
    set(MODULE_HEADERS
        ${MODULE_HEADERS}
45 46
        Handlers/DataHandlerGPU.h
        Handlers/DataHandlerMapGPU.h)
47 48 49

    set(MODULE_SOURCES
        ${MODULE_SOURCES}
50 51
        Handlers/DataHandlerGPU.cpp
        Handlers/DataHandlerMapGPU.cpp)
52
endif()
Tobias Lasser's avatar
Tobias Lasser committed
53 54 55 56

# 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})
57 58

target_link_libraries(${ELSA_MODULE_TARGET_NAME} PUBLIC Eigen3::Eigen)
Tobias Lasser's avatar
Tobias Lasser committed
59

Jens Petit's avatar
Jens Petit committed
60
# use OpenMP is available
61
find_package(OpenMP)
Jens Petit's avatar
Jens Petit committed
62 63 64 65
if(OpenMP_CXX_FOUND)
    target_link_libraries(${ELSA_MODULE_TARGET_NAME} PRIVATE OpenMP::OpenMP_CXX)
endif()

66 67 68
# link Quickvec for DataHandlerGPU
if(ELSA_CUDA_VECTOR AND Quickvec_FOUND)
    target_link_libraries(${ELSA_MODULE_TARGET_NAME} PUBLIC Quickvec::quickvec)
69
    target_compile_definitions(${ELSA_MODULE_TARGET_NAME} PUBLIC ELSA_ENABLE_CUDA_VECTOR)
70
endif()
71

Tobias Lasser's avatar
Tobias Lasser committed
72 73
target_include_directories(${ELSA_MODULE_TARGET_NAME}
        PUBLIC
74
        $<INSTALL_INTERFACE:include/elsa/${ELSA_MODULE_NAME}>
75 76
        $<INSTALL_INTERFACE:include/elsa/${ELSA_MODULE_NAME}/Descriptors>
        $<INSTALL_INTERFACE:include/elsa/${ELSA_MODULE_NAME}/Handlers>
Tobias Lasser's avatar
Tobias Lasser committed
77
        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
78 79
        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Descriptors>
        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Handlers>
Tobias Lasser's avatar
Tobias Lasser committed
80 81 82 83 84
        )


# require C++17
target_compile_features(${ELSA_MODULE_TARGET_NAME} PUBLIC cxx_std_17)
85 86
# set -fPIC
set_target_properties(${ELSA_MODULE_TARGET_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
Tobias Lasser's avatar
Tobias Lasser committed
87

88

Tobias Lasser's avatar
Tobias Lasser committed
89 90 91 92 93 94 95 96 97 98
# build the tests (if enabled)
if(ELSA_TESTING)
    add_subdirectory(tests)
endif(ELSA_TESTING)


# register the module
registerComponent(${ELSA_MODULE_NAME})

# install the module
99
InstallElsaModuleDir(${ELSA_MODULE_NAME} ${ELSA_MODULE_TARGET_NAME} ${ELSA_MODULE_EXPORT_TARGET} "${CMAKE_CURRENT_SOURCE_DIR}/")