Skip to content

Commit

Permalink
Adding CUDA build
Browse files Browse the repository at this point in the history
  • Loading branch information
henryiii committed Dec 10, 2019
1 parent d9379cc commit 8112274
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
15 changes: 15 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,18 @@ jobs:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
- uses: pre-commit/[email protected]

cuda-build:
name: CUDA build only
runs-on: ubuntu-latest
container: nvidia/cuda:10.2-devel-ubuntu18.04
steps:
- uses: actions/checkout@v1
- 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
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ 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)
set(CMAKE_CUDA_STANDARD 11)
endif()

option(CLI11_WARNINGS_AS_ERRORS "Turn all warnings into errors (for CI)")

# Be moderately paranoid with flags
Expand Down
12 changes: 11 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 8112274

Please sign in to comment.