# HG changeset patch # User Alpar Juttner # Date 2010-09-09 15:55:00 # Node ID 659ba4805a48df7caed64a21861195c5b79ce1d5 # Parent 7d166b8b8018ad5eb9b2852dd851439ebfbfab55 Make CMAKE config more consistent with configure.ac (#390) - CMAKE_BUILD_TYPE is Release by deafult - The same set of warnings are used when compiling with gcc diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,37 @@ FIND_PACKAGE(CPLEX) FIND_PACKAGE(COIN) +IF(DEFINED ENV{LEMON_CXX_WARNING}) + SET(CXX_WARNING $ENV{LEMON_CXX_WARNING}) +ELSE() + IF(CMAKE_COMPILER_IS_GNUCXX) + SET(CXX_WARNING "-Wall -W -Wunused -Wformat=2 -Wctor-dtor-privacy -Wnon-virtual-dtor -Wno-char-subscripts -Wwrite-strings -Wno-char-subscripts -Wreturn-type -Wcast-qual -Wcast-align -Wsign-promo -Woverloaded-virtual -ansi -fno-strict-aliasing -Wold-style-cast -Wno-unknown-pragmas") + SET(CMAKE_CXX_FLAGS_DEBUG CACHE STRING "-ggdb") + SET(CMAKE_C_FLAGS_DEBUG CACHE STRING "-ggdb") + ELSEIF(MSVC) + # This part is unnecessary 'casue the same is set by the lemon/core.h. + # Still keep it as an example. + SET(CXX_WARNING "/wd4250 /wd4355 /wd4503 /wd4800 /wd4996") + # Suppressed warnings: + # C4250: 'class1' : inherits 'class2::member' via dominance + # C4355: 'this' : used in base member initializer list + # C4503: 'function' : decorated name length exceeded, name was truncated + # C4800: 'type' : forcing value to bool 'true' or 'false' + # (performance warning) + # C4996: 'function': was declared deprecated + ELSE() + SET(CXX_WARNING "-Wall -W") + ENDIF() +ENDIF() +SET(LEMON_CXX_WARNING_FLAGS ${CXX_WARNING} CACHE STRING "LEMON warning flags.") + +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LEMON_CXX_WARNING_FLAGS}") + +IF(NOT CMAKE_BUILD_TYPE) + SET(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE) +ENDIF() + + INCLUDE(CheckTypeSize) CHECK_TYPE_SIZE("long long" LONG_LONG) SET(LEMON_HAVE_LONG_LONG ${HAVE_LONG_LONG})