Skip to content

Commit

Permalink
Treat warnings as errors on release mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jslee02 committed Dec 18, 2021
1 parent 6f9feed commit bba2391
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
1 change: 0 additions & 1 deletion .ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ fi
cmake .. \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DDART_VERBOSE=ON \
-DDART_TREAT_WARNINGS_AS_ERRORS=ON \
-DDART_BUILD_EXTRAS=ON \
-DDART_CODECOV=$CODECOV \
${install_prefix_option}
Expand Down
32 changes: 18 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ option(DART_ENABLE_SIMD
option(DART_BUILD_GUI_OSG "Build osgDart library" ON)
option(DART_BUILD_EXTRAS "Build extra projects" OFF)
option(DART_CODECOV "Turn on codecov support" OFF)
option(DART_TREAT_WARNINGS_AS_ERRORS "Treat warnings as errors" OFF)
option(DART_FAST_DEBUG "Add -O1 option for DEBUG mode build" OFF)
# GCC and Clang add ANSI-formatted colors when they detect the output medium is a
# terminal. However, this doesn't work in some cases such as when the makefile is
Expand Down Expand Up @@ -176,9 +175,9 @@ if(MSVC)
)
endif()

if(DART_TREAT_WARNINGS_AS_ERRORS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
endif()
add_compile_options(
$<$<NOT:$<CONFIG:DEBUG>>:/WX>
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /permissive- /Zc:twoPhase-")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/LTCG /INCREMENTAL:NO")
if(NOT DART_MSVC_DEFAULT_OPTIONS)
Expand All @@ -199,10 +198,12 @@ if(MSVC)

elseif(CMAKE_COMPILER_IS_GNUCXX)

if(DART_TREAT_WARNINGS_AS_ERRORS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fPIC")
add_compile_options(
-Wall
-Wextra
$<$<NOT:$<CONFIG:DEBUG>>:-Werror>
-fPIC
)
execute_process(
COMMAND ${CMAKE_CXX_COMPILER} -dumpfullversion -dumpversion OUTPUT_VARIABLE GCC_VERSION)
if(GCC_VERSION VERSION_LESS 7.3.0)
Expand All @@ -224,12 +225,15 @@ elseif(CMAKE_COMPILER_IS_GNUCXX)

elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")

if(DART_TREAT_WARNINGS_AS_ERRORS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-error=deprecated-declarations")
# Turn warning "deprecated-declarations" into an warning even if -Werror is
# specified until we abandon glut.
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
add_compile_options(
-Wall
-Wextra
$<$<NOT:$<CONFIG:DEBUG>>:-Werror>
$<$<NOT:$<CONFIG:DEBUG>>:-Wno-error=deprecated-declarations>
-fPIC
)
# Turn warning "deprecated-declarations" into an warning even if -Werror is
# specified until we abandon glut.
execute_process(
COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE CLANG_VERSION)
if(CLANG_VERSION VERSION_LESS 6.0)
Expand Down
2 changes: 1 addition & 1 deletion dart/dynamics/detail/DegreeOfFreedomPtr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ class TemplateDegreeOfFreedomPtr
TemplateBodyNodePtr<BodyNodeT> mBodyNodePtr;

/// Local index of this DegreeOfFreedom within its Joint
std::size_t mIndex;
std::size_t mIndex = 0;
};

/// TemplateWeakDegreeOfFreedomPtr is a templated class that enables users to
Expand Down
2 changes: 1 addition & 1 deletion unittests/regression/test_Issue1231.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ TEST(Issue1231, NoContacts)
dart::simulation::WorldPtr world = dart::simulation::World::create();

double x = -0.25;
for (const std::string& name : {"1", "2"})
for (const auto& name : {"1", "2"})
{
const auto skeleton = dart::dynamics::Skeleton::create(name);
skeleton->setMobile(false);
Expand Down

0 comments on commit bba2391

Please sign in to comment.