Skip to content
1 change: 1 addition & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@
"libcudacxx.test.public_headers",
"libcudacxx.test.public_headers_host_only",
"libcudacxx.test.lit.precompile",
"libcudacxx.test.nvtarget",
"libcudacxx.test.atomics.ptx",
"libcudacxx.test.c2h_all"
]
Expand Down
1 change: 1 addition & 0 deletions libcudacxx/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,5 @@ if (LIBCUDACXX_TEST_WITH_NVRTC)
add_subdirectory(utils/nvidia/nvrtc)
endif()

add_subdirectory(nvtarget)
add_subdirectory(atomic_codegen)
41 changes: 41 additions & 0 deletions libcudacxx/test/nvtarget/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This unit just checks that nv/target can be used with the specified dialects.

set(
nvtarget_dialects
11
14
17
20
)

set_directory_properties(
PROPERTIES
INCLUDE_DIRECTORIES "${libcudacxx_SOURCE_DIR}/include"
)
Comment on lines +5 to +7
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heads up that this API is a bit of a footgun and will clobber any existing directories rather than append. Prefer set_property(DIRECTORY APPEND PROPERTY ...) or include_directories(...).

For consistency with the rest of CCCL, can we move this to a target property?

Suggested change
set_directory_properties(
PROPERTIES
INCLUDE_DIRECTORIES "${libcudacxx_SOURCE_DIR}/include"
)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was kind of hoping for the clobbering behavior.


add_custom_target(libcudacxx.test.nvtarget)

foreach(dialect ${nvtarget_dialects})
if ("cxx_std_${dialect}" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
add_library("nvtarget_cpp${dialect}" OBJECT nvtargettest.cpp)
# This is required to override CMAKE_CXX_STANDARD - target_compile_features is insufficient.
set_target_properties(
"nvtarget_cpp${dialect}" PROPERTIES
CXX_STANDARD "${dialect}"
CXX_STANDARD_REQUIRED ON
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
)
)
target_include_directories(nvtarget_cpp${dialect} PRIVATE "${libcudacxx_SOURCE_DIR}/include")

add_dependencies(libcudacxx.test.nvtarget "nvtarget_cpp${dialect}")
endif()

if ("cuda_std_${dialect}" IN_LIST CMAKE_CUDA_COMPILE_FEATURES AND "cxx_std_${dialect}" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
add_library("nvtarget_cuda${dialect}" OBJECT nvtargettest.cu)
# This is required to override CMAKE_CXX_STANDARD - target_compile_features is insufficient.
set_target_properties(
"nvtarget_cuda${dialect}" PROPERTIES
CUDA_STANDARD "${dialect}"
CUDA_STANDARD_REQUIRED ON
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
)
)
target_include_directories(nvtarget_cuda${dialect} PRIVATE "${libcudacxx_SOURCE_DIR}/include")

add_dependencies(libcudacxx.test.nvtarget "nvtarget_cuda${dialect}")
endif()

endforeach()
6 changes: 6 additions & 0 deletions libcudacxx/test/nvtarget/nvtargettest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <nv/target>

int main()
{
return 0;
}
6 changes: 6 additions & 0 deletions libcudacxx/test/nvtarget/nvtargettest.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <nv/target>

int main()
{
return 0;
}