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

CMakeLists.txt 4.19 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
        Descriptors/DataDescriptor.h
        Descriptors/DescriptorUtils.h
        Descriptors/VolumeDescriptor.h
16 17
        Descriptors/DetectorDescriptor.h
        Descriptors/PlanarDetectorDescriptor.h
18 19 20 21
        Descriptors/BlockDescriptor.h
        Descriptors/IdenticalBlocksDescriptor.h
        Descriptors/PartitionDescriptor.h
        Descriptors/RandomBlocksDescriptor.h
Tobias Lasser's avatar
Tobias Lasser committed
22
        DataContainer.h
23
        DataContainerIterator.h
24 25 26
        Handlers/DataHandler.h
        Handlers/DataHandlerCPU.h
        Handlers/DataHandlerMapCPU.h
Jens Petit's avatar
Jens Petit committed
27 28
        LinearOperator.h
        Expression.h
29 30 31
        ExpressionPredicates.h
        Geometry.h
        StrongTypes.h)
Tobias Lasser's avatar
Tobias Lasser committed
32 33 34

# list all the code files of the module
set(MODULE_SOURCES
35 36
        Descriptors/DataDescriptor.cpp
        Descriptors/VolumeDescriptor.cpp
37
        Descriptors/PlanarDetectorDescriptor.cpp
38 39 40
        Descriptors/RandomBlocksDescriptor.cpp
        Descriptors/DescriptorUtils.cpp
        Descriptors/IdenticalBlocksDescriptor.cpp
41
        Descriptors/DetectorDescriptor.cpp
42
        Descriptors/PartitionDescriptor.cpp
Tobias Lasser's avatar
Tobias Lasser committed
43
        DataContainer.cpp
44 45
        Handlers/DataHandlerCPU.cpp
        Handlers/DataHandlerMapCPU.cpp
46 47 48
        LinearOperator.cpp
        Geometry.cpp
        StrongTypes.cpp)
Tobias Lasser's avatar
Tobias Lasser committed
49

50 51 52
if(${ELSA_CUDA_VECTOR})
    set(MODULE_HEADERS
        ${MODULE_HEADERS}
53 54
        Handlers/DataHandlerGPU.h
        Handlers/DataHandlerMapGPU.h)
55 56 57

    set(MODULE_SOURCES
        ${MODULE_SOURCES}
58 59
        Handlers/DataHandlerGPU.cpp
        Handlers/DataHandlerMapGPU.cpp)
60
endif()
Tobias Lasser's avatar
Tobias Lasser committed
61 62 63 64

# 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})
65 66

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

Jens Petit's avatar
Jens Petit committed
68
# use OpenMP is available
69
find_package(OpenMP)
Jens Petit's avatar
Jens Petit committed
70 71 72 73
if(OpenMP_CXX_FOUND)
    target_link_libraries(${ELSA_MODULE_TARGET_NAME} PRIVATE OpenMP::OpenMP_CXX)
endif()

74 75 76
# link Quickvec for DataHandlerGPU
if(ELSA_CUDA_VECTOR AND Quickvec_FOUND)
    target_link_libraries(${ELSA_MODULE_TARGET_NAME} PUBLIC Quickvec::quickvec)
77
    target_compile_definitions(${ELSA_MODULE_TARGET_NAME} PUBLIC ELSA_ENABLE_CUDA_VECTOR)
78
endif()
79

Tobias Lasser's avatar
Tobias Lasser committed
80 81
target_include_directories(${ELSA_MODULE_TARGET_NAME}
        PUBLIC
82
        $<INSTALL_INTERFACE:include/elsa/${ELSA_MODULE_NAME}>
83 84
        $<INSTALL_INTERFACE:include/elsa/${ELSA_MODULE_NAME}/Descriptors>
        $<INSTALL_INTERFACE:include/elsa/${ELSA_MODULE_NAME}/Handlers>
Tobias Lasser's avatar
Tobias Lasser committed
85
        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
86 87
        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Descriptors>
        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Handlers>
Tobias Lasser's avatar
Tobias Lasser committed
88 89 90 91 92
        )


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

Nikola Dinev's avatar
Nikola Dinev committed
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
if (ELSA_BUILD_PYTHON_BINDINGS)
    set(BINDINGS_SOURCES ${MODULE_SOURCES}
        Descriptors/DataDescriptor.h
        Descriptors/DescriptorUtils.h
        Descriptors/VolumeDescriptor.h
        Descriptors/BlockDescriptor.h
        Descriptors/IdenticalBlocksDescriptor.h
        Descriptors/PartitionDescriptor.h
        Descriptors/RandomBlocksDescriptor.h
        Geometry.h)
        
    list(FILTER BINDINGS_SOURCES EXCLUDE REGEX DataHandler.*.cpp)
    list(FILTER BINDINGS_SOURCES EXCLUDE REGEX .*Descriptor.*.cpp)
    list(FILTER BINDINGS_SOURCES EXCLUDE REGEX Geometry.cpp)
    list(FILTER BINDINGS_SOURCES EXCLUDE REGEX StrongTypes.cpp)
    

    GENERATE_BINDINGS(${ELSA_MODULE_TARGET_NAME}
            ${CMAKE_CURRENT_BINARY_DIR}/bind_${ELSA_MODULE_NAME}.cpp
            bindings_hints.hpp
            ${BINDINGS_SOURCES})
endif()
118

Tobias Lasser's avatar
Tobias Lasser committed
119 120 121 122 123 124 125 126 127 128
# build the tests (if enabled)
if(ELSA_TESTING)
    add_subdirectory(tests)
endif(ELSA_TESTING)


# register the module
registerComponent(${ELSA_MODULE_NAME})

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