CMakeLists.txt 2.1 KB
Newer Older
Nikola Dinev's avatar
Nikola Dinev committed
1
2
3
4
5
6
7
8
cmake_minimum_required(VERSION 3.10)

include(CheckLanguage)

check_language(CUDA)

if (CMAKE_CUDA_COMPILER)
    enable_language(CUDA)
9
    message(STATUS "CUDA support enabled")
Nikola Dinev's avatar
Nikola Dinev committed
10

11
    # build the kernels first
Nikola Dinev's avatar
Nikola Dinev committed
12
13
    add_subdirectory(projector_kernels)

Tobias Lasser's avatar
Tobias Lasser committed
14
15
16
    # necessary to be able to include <cuda_runtime.h>
    find_library(CUDART_LIBRARY cudart ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})

Nikola Dinev's avatar
Nikola Dinev committed
17
18
19
20
21
22
23
    # set the name of the module
    set(ELSA_MODULE_NAME projectors_cuda)
    set(ELSA_MODULE_TARGET_NAME elsa_${ELSA_MODULE_NAME})
    set(ELSA_MODULE_EXPORT_TARGET elsa_${ELSA_MODULE_NAME}Targets)

    # list all the headers of the module
    set(MODULE_HEADERS
24
25
            SiddonsMethodCUDA.h
            JosephsMethodCUDA.h)
Nikola Dinev's avatar
Nikola Dinev committed
26
27
28

    # list all the code files of the module
    set(MODULE_SOURCES
29
30
            SiddonsMethodCUDA.cpp
            JosephsMethodCUDA.cpp)
Nikola Dinev's avatar
Nikola Dinev committed
31
32
33
34

    # 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})
35
    add_dependencies(elsa ${ELSA_MODULE_TARGET_NAME})
Nikola Dinev's avatar
Nikola Dinev committed
36

37
    target_link_libraries(${ELSA_MODULE_TARGET_NAME} PUBLIC elsa_core elsa_logging elsa_projectors elsa_projector_kernels)
Nikola Dinev's avatar
Nikola Dinev committed
38
39
40

    target_include_directories(${ELSA_MODULE_TARGET_NAME}
            PUBLIC
41
            $<INSTALL_INTERFACE:include/elsa/${ELSA_MODULE_NAME}>
Nikola Dinev's avatar
Nikola Dinev committed
42
43
            $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
            )
Tobias Lasser's avatar
Tobias Lasser committed
44
45
    target_include_directories(${ELSA_MODULE_TARGET_NAME}
            PUBLIC ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
Nikola Dinev's avatar
Nikola Dinev committed
46
47
48

    # require C++17
    target_compile_features(${ELSA_MODULE_TARGET_NAME} PUBLIC cxx_std_17) 
49
50
    # set -fPIC
    set_target_properties(${ELSA_MODULE_TARGET_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
Nikola Dinev's avatar
Nikola Dinev committed
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66


    # 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})
else()
    message(STATUS "CUDA compiler NOT found! CUDA support disabled")
endif()