Skip to content

Commit c0f2af9

Browse files
authored
Add MSVC warnings (#134)
* Add MSVC warnings * Update filib * Enable IPC_TOOLKIT_WITH_CUDA if CUDA is available * Move check_language(CUDA)
1 parent 33e5dd3 commit c0f2af9

File tree

4 files changed

+171
-162
lines changed

4 files changed

+171
-162
lines changed

CMakeLists.txt

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,16 @@ project(IPCToolkit
6161
LANGUAGES CXX
6262
VERSION "1.4.0")
6363

64-
option(IPC_TOOLKIT_BUILD_TESTS "Build unit-tests" ${IPC_TOOLKIT_TOPLEVEL_PROJECT})
65-
option(IPC_TOOLKIT_BUILD_PYTHON "Build Python bindings" OFF)
66-
option(IPC_TOOLKIT_WITH_CUDA "Enable CUDA CCD" OFF)
64+
include(CheckLanguage)
65+
check_language(CUDA)
66+
67+
option(IPC_TOOLKIT_BUILD_TESTS "Build unit-tests" ${IPC_TOOLKIT_TOPLEVEL_PROJECT})
68+
option(IPC_TOOLKIT_BUILD_PYTHON "Build Python bindings" OFF)
69+
if(CMAKE_CUDA_COMPILER)
70+
option(IPC_TOOLKIT_WITH_CUDA "Enable CUDA CCD" ON)
71+
else()
72+
option(IPC_TOOLKIT_WITH_CUDA "Enable CUDA CCD" OFF)
73+
endif()
6774
option(IPC_TOOLKIT_WITH_RATIONAL_INTERSECTION "Use rational edge-triangle intersection check" OFF)
6875
option(IPC_TOOLKIT_WITH_ROBIN_MAP "Use Tessil's robin-map rather than std maps" ON)
6976
option(IPC_TOOLKIT_WITH_ABSEIL "Use Abseil's hash functions" ON)
@@ -118,13 +125,6 @@ add_subdirectory("${IPC_TOOLKIT_SOURCE_DIR}")
118125
# Public include directory for IPC Toolkit
119126
target_include_directories(ipc_toolkit PUBLIC "${IPC_TOOLKIT_INCLUDE_DIR}")
120127

121-
################################################################################
122-
# Optional Definitions
123-
################################################################################
124-
125-
# For MSVC, do not use the min and max macros.
126-
target_compile_definitions(ipc_toolkit PUBLIC NOMINMAX)
127-
128128
################################################################################
129129
# Dependencies
130130
################################################################################
@@ -208,6 +208,11 @@ else()
208208
message(STATUS "SIMD support disabled")
209209
endif()
210210

211+
# For MSVC, do not use the min and max macros.
212+
if(MSVC)
213+
target_compile_definitions(ipc_toolkit PRIVATE NOMINMAX)
214+
endif()
215+
211216
# Use C++17
212217
target_compile_features(ipc_toolkit PUBLIC cxx_std_17)
213218

@@ -216,15 +221,13 @@ target_compile_features(ipc_toolkit PUBLIC cxx_std_17)
216221
################################################################################
217222

218223
if(IPC_TOOLKIT_WITH_CUDA)
219-
include(CheckLanguage)
220-
check_language(CUDA)
221-
222-
if(CMAKE_CUDA_COMPILER)
223-
enable_language(CUDA)
224-
else()
225-
message(FATAL_ERROR "No CUDA support found!")
224+
if(NOT CMAKE_CUDA_COMPILER)
225+
message(FATAL_ERROR "CUDA support requested but no CUDA compiler found!")
226226
endif()
227227

228+
# Enable CUDA support
229+
enable_language(CUDA)
230+
228231
# We need to explicitly state that we need all CUDA files in the particle
229232
# library to be built with -dc as the member functions could be called by
230233
# other libraries and executables.

cmake/ipc_toolkit/ipc_toolkit_warnings.cmake

Lines changed: 145 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -7,150 +7,153 @@ if(TARGET ipc::toolkit::warnings)
77
return()
88
endif()
99

10-
set(IPC_TOOLKIT_WARNING_FLAGS
11-
-Wall
12-
-Wextra
13-
-Wpedantic
14-
# -Werror
15-
16-
# -Wconversion
17-
-Werror=enum-conversion
18-
-Wfloat-conversion
19-
# Disable these errors for now, because they are too noisy
20-
# -Wno-sign-conversion
21-
# -Wno-shorten-64-to-32
22-
# -Wunsafe-loop-optimizations # broken with C++11 loops
23-
-Wunused
24-
25-
-Wno-long-long # disable warnings about using long long
26-
-Wpointer-arith
27-
-Wformat=2
28-
-Wuninitialized
29-
-Wcast-qual
30-
-Wmissing-noreturn
31-
-Wmissing-format-attribute
32-
-Wredundant-decls
33-
34-
-Werror=implicit
35-
-Werror=nonnull
36-
-Werror=init-self
37-
-Werror=main
38-
-Werror=missing-braces
39-
-Werror=sequence-point
40-
-Werror=return-type
41-
-Werror=trigraphs
42-
-Warray-bounds
43-
-Werror=write-strings
44-
-Werror=address
45-
-Werror=int-to-pointer-cast
46-
-Werror=pointer-to-int-cast
47-
-Werror=inconsistent-missing-override
48-
-Werror=return-stack-address
49-
50-
-Wunused-variable
51-
-Wunused-but-set-variable
52-
-Wno-unused-parameter
53-
54-
# -Weffc++
55-
-Wold-style-cast
56-
57-
-Wshadow
58-
59-
-Wstrict-null-sentinel
60-
-Woverloaded-virtual
61-
-Wsign-promo
62-
-Wstack-protector
63-
-Wstrict-aliasing
64-
-Wstrict-aliasing=2
65-
66-
# Warn whenever a switch statement has an index of enumerated type and
67-
# lacks a case for one or more of the named codes of that enumeration.
68-
-Wswitch
69-
# This is annoying if all cases are already covered.
70-
-Wswitch-default
71-
# This is annoying if there is a default that covers the rest.
72-
# -Wswitch-enum
73-
-Wswitch-unreachable
74-
# -Wcovered-switch-default # Annoying warnings from nlohmann::json
75-
76-
-Wcast-align
77-
-Wdisabled-optimization
78-
# -Winline # produces warning on default implicit destructor
79-
-Winvalid-pch
80-
-Wmissing-include-dirs
81-
-Wpacked
82-
-Wno-padded
83-
-Wstrict-overflow
84-
-Wstrict-overflow=2
85-
86-
-Wctor-dtor-privacy
87-
-Wlogical-op
88-
-Woverloaded-virtual
89-
# -Wundef
90-
91-
-Werror=non-virtual-dtor
92-
-Werror=delete-non-virtual-dtor
93-
94-
-Wno-sign-compare
95-
96-
###########
97-
# GCC 6.1 #
98-
###########
99-
100-
-Wnull-dereference
101-
-fdelete-null-pointer-checks
102-
-Wduplicated-cond
103-
-Wmisleading-indentation
104-
105-
#-Weverything
106-
107-
###########################
108-
# Enabled by -Weverything #
109-
###########################
110-
111-
#-Wdocumentation
112-
#-Wdocumentation-unknown-command
113-
#-Wfloat-equal
114-
115-
#-Wglobal-constructors
116-
#-Wexit-time-destructors
117-
#-Wmissing-variable-declarations
118-
#-Wextra-semi
119-
#-Wweak-vtables
120-
#-Wno-source-uses-openmp
121-
#-Wdeprecated
122-
#-Wnewline-eof
123-
#-Wmissing-prototypes
124-
125-
#-Wno-c++98-compat
126-
#-Wno-c++98-compat-pedantic
127-
128-
################################################
129-
# Need to check if those are still valid today #
130-
################################################
131-
132-
#-Wimplicit-atomic-properties
133-
#-Wmissing-declarations
134-
#-Wmissing-prototypes
135-
#-Wstrict-selector-match
136-
#-Wundeclared-selector
137-
#-Wunreachable-code
138-
139-
# Not a warning, but enable link-time-optimization
140-
# TODO: Check out modern CMake version of setting this flag
141-
# https://cmake.org/cmake/help/latest/module/CheckIPOSupported.html
142-
#-flto
143-
144-
# Gives meaningful stack traces
145-
-fno-omit-frame-pointer
146-
-fno-optimize-sibling-calls
147-
148-
-Wno-redundant-decls
149-
)
150-
15110
# Flags above don't make sense for MSVC
15211
if(MSVC)
153-
set(IPC_TOOLKIT_WARNING_FLAGS)
12+
set(IPC_TOOLKIT_WARNING_FLAGS
13+
/Wall # Display all warnings
14+
/MP # Multi-processor compilation
15+
)
16+
else()
17+
set(IPC_TOOLKIT_WARNING_FLAGS
18+
-Wall
19+
-Wextra
20+
-Wpedantic
21+
# -Werror
22+
23+
# -Wconversion
24+
-Werror=enum-conversion
25+
-Wfloat-conversion
26+
# Disable these errors for now, because they are too noisy
27+
# -Wno-sign-conversion
28+
# -Wno-shorten-64-to-32
29+
# -Wunsafe-loop-optimizations # broken with C++11 loops
30+
-Wunused
31+
32+
-Wno-long-long # disable warnings about using long long
33+
-Wpointer-arith
34+
-Wformat=2
35+
-Wuninitialized
36+
-Wcast-qual
37+
-Wmissing-noreturn
38+
-Wmissing-format-attribute
39+
-Wredundant-decls
40+
41+
-Werror=implicit
42+
-Werror=nonnull
43+
-Werror=init-self
44+
-Werror=main
45+
-Werror=missing-braces
46+
-Werror=sequence-point
47+
-Werror=return-type
48+
-Werror=trigraphs
49+
-Warray-bounds
50+
-Werror=write-strings
51+
-Werror=address
52+
-Werror=int-to-pointer-cast
53+
-Werror=pointer-to-int-cast
54+
-Werror=inconsistent-missing-override
55+
-Werror=return-stack-address
56+
57+
-Wunused-variable
58+
-Wunused-but-set-variable
59+
-Wno-unused-parameter
60+
61+
# -Weffc++
62+
-Wold-style-cast
63+
64+
-Wshadow
65+
66+
-Wstrict-null-sentinel
67+
-Woverloaded-virtual
68+
-Wsign-promo
69+
-Wstack-protector
70+
-Wstrict-aliasing
71+
-Wstrict-aliasing=2
72+
73+
# Warn whenever a switch statement has an index of enumerated type and
74+
# lacks a case for one or more of the named codes of that enumeration.
75+
-Wswitch
76+
# This is annoying if all cases are already covered.
77+
-Wswitch-default
78+
# This is annoying if there is a default that covers the rest.
79+
# -Wswitch-enum
80+
-Wswitch-unreachable
81+
# -Wcovered-switch-default # Annoying warnings from nlohmann::json
82+
83+
-Wcast-align
84+
-Wdisabled-optimization
85+
# -Winline # produces warning on default implicit destructor
86+
-Winvalid-pch
87+
-Wmissing-include-dirs
88+
-Wpacked
89+
-Wno-padded
90+
-Wstrict-overflow
91+
-Wstrict-overflow=2
92+
93+
-Wctor-dtor-privacy
94+
-Wlogical-op
95+
-Woverloaded-virtual
96+
# -Wundef
97+
98+
-Werror=non-virtual-dtor
99+
-Werror=delete-non-virtual-dtor
100+
101+
-Wno-sign-compare
102+
103+
###########
104+
# GCC 6.1 #
105+
###########
106+
107+
-Wnull-dereference
108+
-fdelete-null-pointer-checks
109+
-Wduplicated-cond
110+
-Wmisleading-indentation
111+
112+
#-Weverything
113+
114+
###########################
115+
# Enabled by -Weverything #
116+
###########################
117+
118+
#-Wdocumentation
119+
#-Wdocumentation-unknown-command
120+
#-Wfloat-equal
121+
122+
#-Wglobal-constructors
123+
#-Wexit-time-destructors
124+
#-Wmissing-variable-declarations
125+
#-Wextra-semi
126+
#-Wweak-vtables
127+
#-Wno-source-uses-openmp
128+
#-Wdeprecated
129+
#-Wnewline-eof
130+
#-Wmissing-prototypes
131+
132+
#-Wno-c++98-compat
133+
#-Wno-c++98-compat-pedantic
134+
135+
################################################
136+
# Need to check if those are still valid today #
137+
################################################
138+
139+
#-Wimplicit-atomic-properties
140+
#-Wmissing-declarations
141+
#-Wmissing-prototypes
142+
#-Wstrict-selector-match
143+
#-Wundeclared-selector
144+
#-Wunreachable-code
145+
146+
# Not a warning, but enable link-time-optimization
147+
# TODO: Check out modern CMake version of setting this flag
148+
# https://cmake.org/cmake/help/latest/module/CheckIPOSupported.html
149+
#-flto
150+
151+
# Gives meaningful stack traces
152+
-fno-omit-frame-pointer
153+
-fno-optimize-sibling-calls
154+
155+
-Wno-redundant-decls
156+
)
154157
endif()
155158

156159
add_library(ipc_toolkit_warnings INTERFACE)

cmake/recipes/filib.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ message(STATUS "Third-party: creating target 'filib::filib'")
1212
option(FILIB_BUILD_SHARED_LIB "Build shared library" OFF)
1313

1414
include(CPM)
15-
CPMAddPackage("gh:zfergus/filib#03e4eb0fc59399bd0003f8efd3179078195df49f")
15+
CPMAddPackage("gh:zfergus/filib#7cf13519b0db72df2493c9c8997a8bef9e372848")

tests/src/tests/broad_phase/test_stq.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@
77
#include <ipc/broad_phase/sweep_and_tiniest_queue.hpp>
88

99
using namespace ipc;
10-
10+
#ifdef IPC_TOOLKIT_WITH_CUDA
11+
TEST_CASE("STQ All Cases", "[broad_phase][stq][cuda]")
12+
#else
1113
TEST_CASE("STQ All Cases", "[broad_phase][stq]")
14+
#endif
1215
{
1316
Eigen::MatrixXd V0, V1;
1417
Eigen::MatrixXi E, F;
@@ -58,7 +61,7 @@ TEST_CASE("STQ All Cases", "[broad_phase][stq]")
5861
}
5962

6063
#ifdef IPC_TOOLKIT_WITH_CUDA
61-
TEST_CASE("Puffer-Ball", "[ccd][broad_phase][stq]")
64+
TEST_CASE("Puffer-Ball", "[ccd][broad_phase][stq][cuda]")
6265
{
6366
Eigen::MatrixXd V0, V1;
6467
Eigen::MatrixXi E, F;

0 commit comments

Comments
 (0)