mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-04-30 04:33:53 +00:00
Adding CUDA NVCC build (#365)
* Adding CUDA build * Filter NVCC warning * Constexpr reword
This commit is contained in:
parent
d9379cccf5
commit
3bdbbd7875
17
.github/workflows/tests.yml
vendored
17
.github/workflows/tests.yml
vendored
@ -22,3 +22,20 @@ jobs:
|
|||||||
path: ~/.cache/pre-commit
|
path: ~/.cache/pre-commit
|
||||||
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
|
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
|
||||||
- uses: pre-commit/action@v1.0.0
|
- 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
|
||||||
|
@ -45,6 +45,14 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
|||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
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)")
|
option(CLI11_WARNINGS_AS_ERRORS "Turn all warnings into errors (for CI)")
|
||||||
|
|
||||||
# Be moderately paranoid with flags
|
# Be moderately paranoid with flags
|
||||||
|
@ -140,7 +140,17 @@ struct pair_adaptor<
|
|||||||
// check for constructibility from a specific type and copy assignable used in the parse detection
|
// check for constructibility from a specific type and copy assignable used in the parse detection
|
||||||
template <typename T, typename C> class is_direct_constructible {
|
template <typename T, typename C> class is_direct_constructible {
|
||||||
template <typename TT, typename CC>
|
template <typename TT, typename CC>
|
||||||
static auto test(int, std::true_type) -> decltype(TT{std::declval<CC>()}, std::is_move_assignable<TT>());
|
static auto test(int, std::true_type) -> decltype(
|
||||||
|
// NVCC warns about narrowing conversions here
|
||||||
|
#ifdef __CUDACC__
|
||||||
|
#pragma diag_suppress 2361
|
||||||
|
#endif
|
||||||
|
TT { std::declval<CC>() }
|
||||||
|
#ifdef __CUDACC__
|
||||||
|
#pragma diag_default 2361
|
||||||
|
#endif
|
||||||
|
,
|
||||||
|
std::is_move_assignable<TT>());
|
||||||
|
|
||||||
template <typename TT, typename CC> static auto test(int, std::false_type) -> std::false_type;
|
template <typename TT, typename CC> static auto test(int, std::false_type) -> std::false_type;
|
||||||
|
|
||||||
|
@ -52,10 +52,20 @@ set(CLI11_MULTIONLY_TESTS
|
|||||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
foreach(T ${CLI11_TESTS})
|
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_executable(${T} ${T}.cpp ${CLI11_headers})
|
||||||
add_sanitizers(${T})
|
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})
|
add_gtest(${T})
|
||||||
|
|
||||||
if(CLI11_SINGLE_FILE AND CLI11_SINGLE_FILE_TESTS)
|
if(CLI11_SINGLE_FILE AND CLI11_SINGLE_FILE_TESTS)
|
||||||
|
@ -306,7 +306,7 @@ TEST_F(TApp, SimiShortcutSets) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TApp, SetFromCharStarArrayVector) {
|
TEST_F(TApp, SetFromCharStarArrayVector) {
|
||||||
constexpr const char *names[] = {"one", "two", "three"};
|
constexpr const char *names[3]{"one", "two", "three"};
|
||||||
std::string value;
|
std::string value;
|
||||||
auto opt = app.add_option("-s,--set", value)
|
auto opt = app.add_option("-s,--set", value)
|
||||||
->check(CLI::IsMember{std::vector<std::string>(std::begin(names), std::end(names))});
|
->check(CLI::IsMember{std::vector<std::string>(std::begin(names), std::end(names))});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user