Skip to content

Commit

Permalink
Fix nvcc warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
chillenzer committed Jan 22, 2025
1 parent 8a80fb1 commit 3ba2947
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
16 changes: 15 additions & 1 deletion test/multithreaded/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,21 @@ set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 20)
# enable compiler warnings
if(NOT mallocMC_TEST_INSTALLED_VERSION)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
target_compile_options(mallocMC INTERFACE -Wall -Wpedantic -Wextra -Werror "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:default-stream-launch>")
target_compile_options(
mallocMC
INTERFACE
-Wall
# nvcc generate C code which uses directives GCC complains about like this:
# warning: style of line directive is a GCC extension
# So we can't use -pedantic here.
$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:-Wpedantic>
-Wextra
# Somehow, with the commandline that CMake composes nvcc misinterprets the flag
# after -Werror as an argument to -Werror leading to errors like
# nvcc fatal : Value '-Wpedantic' is not defined for option 'Werror'
# So, we can't compile with -Werror for nvcc.
$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:-Werror>
)
elseif(MSVC)
target_compile_options(mallocMC INTERFACE /W4 /WX)
endif()
Expand Down
16 changes: 15 additions & 1 deletion test/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,21 @@ set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 20)
# enable compiler warnings
if(NOT mallocMC_TEST_INSTALLED_VERSION)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
target_compile_options(mallocMC INTERFACE -Wall -Wpedantic -Wextra -Werror "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:default-stream-launch>")
target_compile_options(
mallocMC
INTERFACE
-Wall
# nvcc generate C code which uses directives GCC complains about like this:
# warning: style of line directive is a GCC extension
# So we can't use -pedantic here.
$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:-Wpedantic>
-Wextra
# Somehow, with the commandline that CMake composes nvcc misinterprets the flag
# after -Werror as an argument to -Werror leading to errors like
# nvcc fatal : Value '-Wpedantic' is not defined for option 'Werror'
# So, we can't compile with -Werror for nvcc.
$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:-Werror>
)
elseif(MSVC)
target_compile_options(mallocMC INTERFACE /W4 /WX)
endif()
Expand Down

0 comments on commit 3ba2947

Please sign in to comment.