Files
nvbench/cmake/NVBenchHeaderTesting.cmake
Allison Piper a0f2fab72b Squashed commit of the following:
commit c5b2fc0a8b
Author: Allison Piper <alliepiper16@gmail.com>
Date:   Sat Apr 6 21:48:20 2024 +0000

    Add supported compilers and tools in README.md.

commit 92fe366da5
Author: Allison Piper <alliepiper16@gmail.com>
Date:   Sat Apr 6 20:45:30 2024 +0000

    Fix issues discovered by header tests.

commit f7f6c92143
Author: Allison Piper <alliepiper16@gmail.com>
Date:   Sat Apr 6 20:45:06 2024 +0000

    Setup header tests, add C++20 header tests + examples.

    The core library will always be built with C++17, but
    we test our headers / examples under 17 and 20.

commit 4b24f26b66
Author: Allison Piper <alliepiper16@gmail.com>
Date:   Sat Apr 6 16:21:42 2024 +0000

    Pass CUDA FLAGS to install tests.

commit 4fb672ae91
Author: Allison Piper <alliepiper16@gmail.com>
Date:   Sat Apr 6 15:43:41 2024 +0000

    Add newer GCC (13) and Clang (17, 18).
2024-04-06 22:05:40 +00:00

41 lines
1.4 KiB
CMake

# For every public header, build a translation unit containing `#include <header>`
# with some various checks.
set(excluded_headers_regexes
# Should never be used externally.
"^detail"
"^internal"
)
# Meta target for all configs' header builds:
add_custom_target(nvbench.headers.all)
add_dependencies(nvbench.all nvbench.headers.all)
file(GLOB_RECURSE header_files
RELATIVE "${NVBench_SOURCE_DIR}/nvbench/"
CONFIGURE_DEPENDS
"${NVBench_SOURCE_DIR}/nvbench/*.cuh"
)
foreach (exclusion IN LISTS excluded_headers_regexes)
list(FILTER header_files EXCLUDE REGEX "${exclusion}")
endforeach()
function (nvbench_add_header_target target_name cuda_std)
foreach (header IN LISTS header_files)
set(headertest_src "headers/${target_name}/${header}.cu")
set(header_str "nvbench/${header}") # Substitution used by configure_file:
configure_file("${NVBench_SOURCE_DIR}/cmake/header_test.in.cxx" "${headertest_src}")
list(APPEND headertest_srcs "${headertest_src}")
endforeach()
add_library(${target_name} OBJECT ${headertest_srcs})
target_link_libraries(${target_name} PUBLIC nvbench::nvbench)
set_target_properties(${target_name} PROPERTIES COMPILE_FEATURES cuda_std_${cuda_std})
add_dependencies(nvbench.headers.all ${target_name})
endfunction()
foreach (std IN LISTS NVBench_DETECTED_CUDA_STANDARDS)
nvbench_add_header_target(nvbench.headers.cpp${std} ${std})
endforeach()