Skip to content

Commit

Permalink
Fix CMake warning flags and package versions (RobotLocomotion#7401)
Browse files Browse the repository at this point in the history
* Sync warning flags between Bazel and CMake
* Specify correct minimum versions for CMake packages on Mac
  • Loading branch information
jamiesnape authored and sherm1 committed Nov 3, 2017
1 parent 9eb22d4 commit 188b8c7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
3 changes: 3 additions & 0 deletions matlab/cmake/flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Keep CMAKE_CXX_FLAGS in sync with CXX_FLAGS, CLANG_FLAGS, and GCC_FLAGS in
# tools/skylark/drake_cc.bzl.
if(CMAKE_CXX_COMPILER_ID STREQUAL AppleClang OR CMAKE_CXX_COMPILER_ID STREQUAL Clang)
set(CXX_FLAGS
-Werror=all
Expand All @@ -18,6 +20,7 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
-Werror=all
-Werror=extra
-Werror=ignored-qualifiers
-Werror=logical-op
-Werror=non-virtual-dtor
-Werror=overloaded-virtual
-Werror=return-local-addr
Expand Down
15 changes: 13 additions & 2 deletions matlab/cmake/packages.cmake
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
set(CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY ON)
set(CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY ON)

if(APPLE)
set(MINIMUM_MATLAB_VERSION 9.2)
# TODO(jamiesnape): Change from 3.1 to 3.4.1 when #7278 merges.
set(MINIMUM_PROTOBUF_VERSION 3.1)
else()
# TODO(jamiesnape): Change from 9 to 9.2 when support for R2016a and R2016 is
# no longer needed.
set(MINIMUM_MATLAB_VERSION 9)
set(MINIMUM_PROTOBUF_VERSION 2.6.1)
endif()

find_package(drake CONFIG REQUIRED)
find_package(Eigen3 3.3.3 CONFIG REQUIRED)
find_package(Matlab 9 MODULE REQUIRED COMPONENTS
find_package(Matlab ${MINIMUM_MATLAB_VERSION} MODULE REQUIRED COMPONENTS
MAIN_PROGRAM MEX_COMPILER MX_LIBRARY
)
find_package(Protobuf 2.6 MODULE REQUIRED)
find_package(Protobuf ${MINIMUM_PROTOBUF_VERSION} MODULE REQUIRED)
3 changes: 3 additions & 0 deletions tools/skylark/drake_cc.bzl
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# -*- python -*-

# Keep CXX_FLAGS, CLANG_FLAGS, and GCC_FLAGS in sync with CMAKE_CXX_FLAGS in
# matlab/cmake/flags.cmake.

# The CXX_FLAGS will be enabled for all C++ rules in the project
# building with any compiler.
CXX_FLAGS = [
Expand Down

0 comments on commit 188b8c7

Please sign in to comment.