Spaces:
Runtime error
Runtime error
File size: 3,911 Bytes
be11144 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# For every public header, build a translation unit containing `#include <header>`
# to let the compiler try to figure out warnings in that header if it is not otherwise
# included in tests, and also to verify if the headers are modular enough.
# .inl files are not globbed for, because they are not supposed to be used as public
# entrypoints.
foreach(thrust_target IN LISTS THRUST_TARGETS)
thrust_get_target_property(config_host ${thrust_target} HOST)
thrust_get_target_property(config_device ${thrust_target} DEVICE)
thrust_get_target_property(config_prefix ${thrust_target} PREFIX)
string(TOLOWER "${config_host}" host_lower)
string(TOLOWER "${config_device}" device_lower)
# GLOB ALL THE THINGS
set(headers_globs thrust/*.h)
set(headers_exclude_systems_globs thrust/system/*/*)
set(headers_systems_globs
thrust/system/${host_lower}/*
thrust/system/${device_lower}/*
)
set(headers_exclude_details_globs
thrust/detail/*
thrust/*/detail/*
thrust/*/*/detail/*
)
# Get all .h files...
file(GLOB_RECURSE headers
RELATIVE "${Thrust_SOURCE_DIR}/thrust"
CONFIGURE_DEPENDS
${headers_globs}
)
# ...then remove all system specific headers...
file(GLOB_RECURSE headers_exclude_systems
RELATIVE "${Thrust_SOURCE_DIR}/thrust"
CONFIGURE_DEPENDS
${headers_exclude_systems_globs}
)
list(REMOVE_ITEM headers ${headers_exclude_systems})
# ...then add all headers specific to the selected host and device systems back again...
file(GLOB_RECURSE headers_systems
RELATIVE ${Thrust_SOURCE_DIR}/thrust
CONFIGURE_DEPENDS
${headers_systems_globs}
)
list(APPEND headers ${headers_systems})
# ...and remove all the detail headers (also removing the detail headers from the selected systems).
file(GLOB_RECURSE headers_exclude_details
RELATIVE "${Thrust_SOURCE_DIR}/thrust"
CONFIGURE_DEPENDS
${headers_exclude_details_globs}
)
list(REMOVE_ITEM headers ${headers_exclude_details})
# List of headers that aren't implemented for all backends, but are implemented for CUDA.
set(partially_implemented_CUDA
async/copy.h
async/for_each.h
async/reduce.h
async/sort.h
async/transform.h
event.h
future.h
)
# List of headers that aren't implemented for all backends, but are implemented for CPP.
set(partially_implemented_CPP
)
# List of headers that aren't implemented for all backends, but are implemented for TBB.
set(partially_implemented_TBB
)
# List of headers that aren't implemented for all backends, but are implemented for OMP.
set(partially_implemented_OMP
)
# List of all partially implemented headers.
set(partially_implemented
${partially_implemented_CUDA}
${partially_implemented_CPP}
${partially_implemented_TBB}
${partially_implemented_OMP}
)
list(REMOVE_DUPLICATES partially_implemented)
set(headertest_srcs)
foreach (header IN LISTS headers)
if ("${header}" IN_LIST partially_implemented)
# This header is partially implemented on _some_ backends...
if (NOT "${header}" IN_LIST partially_implemented_${config_device})
# ...but not on the selected one.
continue()
endif()
endif()
set(headertest_src_ext .cpp)
if ("CUDA" STREQUAL "${config_device}")
set(headertest_src_ext .cu)
endif()
set(headertest_src "headers/${config_prefix}/${header}${headertest_src_ext}")
configure_file("${Thrust_SOURCE_DIR}/cmake/header_test.in" "${headertest_src}")
list(APPEND headertest_srcs "${headertest_src}")
endforeach()
set(headertest_target ${config_prefix}.headers)
add_library(${headertest_target} OBJECT ${headertest_srcs})
target_link_libraries(${headertest_target} PUBLIC ${thrust_target})
thrust_clone_target_properties(${headertest_target} ${thrust_target})
add_dependencies(${config_prefix}.all ${headertest_target})
endforeach()
|