Skip to content

Commit

Permalink
Fixes #480: Compiling example executable for each supported C++ version
Browse files Browse the repository at this point in the history
* No longer requiring the compiler to support C++14
* Now compiling multiple executables (from the same source), one for each language standard version past C++11 until C++23
  • Loading branch information
eyalroz committed Mar 25, 2023
1 parent 4bc8ba2 commit b90b52d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
18 changes: 14 additions & 4 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,20 @@ target_link_libraries(vectorAdd_profiled cuda-api-wrappers::nvtx)
add_executable(manipulate_current_device other/manipulate_current_device.cu)
add_executable(inclusion_in_two_translation_units other/inclusion_in_two_translation_units/main.cpp other/inclusion_in_two_translation_units/second_tu.cpp)
target_link_libraries(inclusion_in_two_translation_units cuda-api-wrappers::rtc cuda-api-wrappers::nvtx)
add_executable(cpp_14 other/cpp_14/main.cpp)
target_link_libraries(cpp_14 cuda-api-wrappers::rtc cuda-api-wrappers::nvtx)
set_property(TARGET cpp_14 PROPERTY CXX_STANDARD 14)
set_property(TARGET cpp_14 PROPERTY CXX_STANDARD_REQUIRED ON)
foreach(std_version "14" "17" "20" "23")
if("cxx_std_${std_version}" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
set(tgt "cpp_${std_version}")
add_executable(${tgt} other/new_cpp_standard/main.cpp)
target_link_libraries(${tgt} cuda-api-wrappers::rtc cuda-api-wrappers::nvtx)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
target_link_libraries(${tgt} cstdc++fs)
endif()
set_target_properties(${tgt} PROPERTIES
CXX_STANDARD ${std_version}
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF)
endif()
endforeach()
add_executable(runtime_api_header_collection other/runtime_api_header_collection.cpp)
add_executable(jitify other/jitify/jitify.cpp)
set(jitify_headers_target_dir ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/example_headers)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/**
* @file
*
* @brief This is a simple program, which uses very little of the CUDA
* C++ API wrappers (but more than nothing); it is intended for checking
* whether the wrappers can be compiled using different values for the
* C++ language standard, beyond the library's minimum supported
* standard version.
*/
#include <cuda/api.hpp>
#include <cuda/nvtx.hpp>
#include <cuda/rtc.hpp>
Expand Down

0 comments on commit b90b52d

Please sign in to comment.