Back to home page

EIC code displayed by LXR

 
 

    


Warning, /acts/Traccc/cmake/traccc-alpaka-functions.cmake is written in an unsupported language. File is not indexed.

0001 # TRACCC library, part of the ACTS project (R&D line)
0002 #
0003 # (c) 2024-2026 CERN for the benefit of the ACTS project
0004 #
0005 # Mozilla Public License Version 2.0
0006 
0007 cmake_minimum_required(VERSION 3.16)
0008 
0009 # Guard against multiple includes.
0010 include_guard(GLOBAL)
0011 
0012 # Function for declaring the libraries of the project.
0013 # This version calls the alpaka_add_library() function to create the library,
0014 # which is setup to use the correct compiler flags depending on the build type.
0015 #
0016 # Usage: traccc_add_alpaka_library( traccc_core core
0017 #                                   [TYPE SHARED/INTERFACE/STATIC]
0018 #                                   include/source1.hpp source2.cpp )
0019 #
0020 function(traccc_add_alpaka_library fullname basename)
0021     # Parse the function's options.
0022     cmake_parse_arguments(ARG "" "TYPE" "" ${ARGN})
0023 
0024     # Decide what sources to give to the library.
0025     set(_sources ${ARG_UNPARSED_ARGUMENTS})
0026     if("${ARG_TYPE}" STREQUAL "INTERFACE")
0027         set(_sources)
0028     endif()
0029 
0030     # Create the library.
0031     alpaka_add_library( ${fullname} ${ARG_TYPE} ${_sources} )
0032 
0033     # Set up how clients should find its headers.
0034     if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/")
0035         set(_depType PUBLIC)
0036         if("${ARG_TYPE}" STREQUAL "INTERFACE")
0037             set(_depType INTERFACE)
0038         endif()
0039         target_include_directories(
0040             ${fullname}
0041             ${_depType}
0042             $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
0043             $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
0044         )
0045         unset(_depType)
0046     endif()
0047 
0048     # Make sure that the library is available as "traccc::${basename}" in every
0049     # situation.
0050     set_target_properties(${fullname} PROPERTIES EXPORT_NAME ${basename})
0051     add_library(traccc::${basename} ALIAS ${fullname})
0052 
0053     # Specify the (SO)VERSION of the library.
0054     if(NOT "${ARG_TYPE}" STREQUAL "INTERFACE")
0055         set_target_properties(
0056             ${fullname}
0057             PROPERTIES
0058                 VERSION ${PROJECT_VERSION}
0059                 SOVERSION ${PROJECT_VERSION_MAJOR}
0060         )
0061     endif()
0062 
0063     # Set up the installation of the library and its headers.
0064     install(
0065         TARGETS ${fullname}
0066         EXPORT traccc-exports
0067         LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
0068         ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
0069         RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
0070     )
0071     if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/")
0072         install(
0073             DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/"
0074             DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
0075         )
0076     endif()
0077 endfunction(traccc_add_alpaka_library)
0078 
0079 # Helper function for setting up the Alpaka traccc test(s).
0080 #
0081 # Usage: traccc_add_alpaka_test( core_containers source1.cpp source2.cpp
0082 #                                LINK_LIBRARIES traccc::core )
0083 #
0084 function(traccc_add_alpaka_test name)
0085     # Parse the function's options.
0086     cmake_parse_arguments(ARG "" "" "LINK_LIBRARIES" ${ARGN})
0087 
0088     # Create the test executable.
0089     set(test_exe_name "traccc_test_${name}")
0090     alpaka_add_executable( ${test_exe_name} ${ARG_UNPARSED_ARGUMENTS} )
0091     if(ARG_LINK_LIBRARIES)
0092         target_link_libraries(${test_exe_name} PRIVATE ${ARG_LINK_LIBRARIES})
0093     endif()
0094 
0095     # Discover all of the tests from the execuable, and set them up as individual
0096     # CTest tests. All the while ensuring that they would find their data files.
0097     gtest_discover_tests(
0098         ${test_exe_name}
0099         PROPERTIES ENVIRONMENT TRACCC_TEST_DATA_DIR=${PROJECT_SOURCE_DIR}/data
0100         DISCOVERY_TIMEOUT 20
0101     )
0102 endfunction(traccc_add_alpaka_test)
0103 
0104 macro(traccc_enable_language_alpaka)
0105     #enable_language cannot be called by a function: put it in a macro
0106     if(alpaka_ACC_GPU_CUDA_ENABLE)
0107         enable_language(CUDA)
0108         include(traccc-compiler-options-cuda)
0109     elseif(alpaka_ACC_GPU_HIP_ENABLE)
0110         enable_language(HIP)
0111         include(traccc-compiler-options-hip)
0112     elseif(alpaka_ACC_SYCL_ENABLE)
0113         include(vecmem-check-language)
0114         vecmem_check_language(SYCL)
0115         enable_language(SYCL)
0116         include(traccc-compiler-options-sycl)
0117     endif()
0118 endmacro(traccc_enable_language_alpaka)