In January 2021 we will introduce a 10 GB quota for project repositories. Higher limits for individual projects will be available on request. Please see https://doku.lrz.de/display/PUBLIC/GitLab for more information.

CMakeLists.txt 2.42 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 35

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

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

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

    # require C++17
    target_compile_features(${ELSA_MODULE_TARGET_NAME} PUBLIC cxx_std_17) 
48 49
    # set -fPIC
    set_target_properties(${ELSA_MODULE_TARGET_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
50 51
    # set define to check cuda projectors in projects
    target_compile_definitions(${ELSA_MODULE_TARGET_NAME} PUBLIC ELSA_CUDA_PROJECTORS)
Nikola Dinev's avatar
Nikola Dinev committed
52 53 54 55 56 57

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

Nikola Dinev's avatar
Nikola Dinev committed
58 59 60 61 62 63 64
    if (ELSA_BUILD_PYTHON_BINDINGS)
        GENERATE_BINDINGS(${ELSA_MODULE_TARGET_NAME}
                ${CMAKE_CURRENT_BINARY_DIR}/bind_${ELSA_MODULE_NAME}.cpp
                ""
                ${MODULE_SOURCES})
    endif()
    
Nikola Dinev's avatar
Nikola Dinev committed
65 66 67 68 69 70 71 72
    # 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()