diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 880fa0bc..2ac12771 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -22,3 +22,20 @@ jobs: path: ~/.cache/pre-commit key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }} - uses: pre-commit/action@v1.0.0 + + cuda-build: + name: CUDA build only + runs-on: ubuntu-latest + container: nvidia/cuda:10.2-devel-ubuntu18.04 + steps: + - uses: actions/checkout@v1 + with: + submodules: true + - name: Add wget + run: apt-get update && apt-get install -y wget + - name: Install Modern CMake + run: wget -qO- "https://cmake.org/files/v3.16/cmake-3.16.0-Linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C /usr/local + - name: Configure + run: cmake -S . -B build -DCLI11_CUDA_TESTS=ON + - name: Build + run: cmake --build build diff --git a/CMakeLists.txt b/CMakeLists.txt index 24b49266..fa39a94b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,6 +45,14 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_STANDARD_REQUIRED ON) + option(CLI11_CUDA_TESTS "Build the tests with NVCC to check for warnings there - requires CMake 3.9+") + if(CLI11_CUDA_TESTS) + enable_language(CUDA) + + # Print out warning and error numbers + set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcudafe --display_error_number") + endif() + option(CLI11_WARNINGS_AS_ERRORS "Turn all warnings into errors (for CI)") # Be moderately paranoid with flags diff --git a/include/CLI/TypeTools.hpp b/include/CLI/TypeTools.hpp index cd4aabc5..11f14a31 100644 --- a/include/CLI/TypeTools.hpp +++ b/include/CLI/TypeTools.hpp @@ -140,7 +140,17 @@ struct pair_adaptor< // check for constructibility from a specific type and copy assignable used in the parse detection template class is_direct_constructible { template - static auto test(int, std::true_type) -> decltype(TT{std::declval()}, std::is_move_assignable()); + static auto test(int, std::true_type) -> decltype( +// NVCC warns about narrowing conversions here +#ifdef __CUDACC__ +#pragma diag_suppress 2361 +#endif + TT { std::declval() } +#ifdef __CUDACC__ +#pragma diag_default 2361 +#endif + , + std::is_move_assignable()); template static auto test(int, std::false_type) -> std::false_type; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9e021f74..48df0d29 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -52,10 +52,20 @@ set(CLI11_MULTIONLY_TESTS include_directories(${CMAKE_CURRENT_SOURCE_DIR}) foreach(T ${CLI11_TESTS}) + if(CLI11_CUDA_TESTS) + set_property( + SOURCE ${T}.cpp + PROPERTY + LANGUAGE CUDA + ) + endif() add_executable(${T} ${T}.cpp ${CLI11_headers}) add_sanitizers(${T}) - target_link_libraries(${T} PUBLIC CLI11 CLI11_warnings) + target_link_libraries(${T} PUBLIC CLI11) + if(NOT CLI11_CUDA_TESTS) + target_link_libraries(${T} PUBLIC CLI11_warnings) + endif() add_gtest(${T}) if(CLI11_SINGLE_FILE AND CLI11_SINGLE_FILE_TESTS) diff --git a/tests/SetTest.cpp b/tests/SetTest.cpp index 30d400b4..a49b9199 100644 --- a/tests/SetTest.cpp +++ b/tests/SetTest.cpp @@ -306,7 +306,7 @@ TEST_F(TApp, SimiShortcutSets) { } TEST_F(TApp, SetFromCharStarArrayVector) { - constexpr const char *names[] = {"one", "two", "three"}; + constexpr const char *names[3]{"one", "two", "three"}; std::string value; auto opt = app.add_option("-s,--set", value) ->check(CLI::IsMember{std::vector(std::begin(names), std::end(names))});