From ff1c3658fbeaf245aef34b2d445f4e15ac95f651 Mon Sep 17 00:00:00 2001 From: Pavel Krajcevski Date: Mon, 28 Jan 2013 18:11:29 -0500 Subject: [PATCH] Always set all of the compiler warnings on and make sure to include the MSFT extensions if we're on gcc. Furthermore, include an option to treat warnings as errors. I will probably always have this on, but other people who decide to use the library probably won't want it... --- CMakeLists.txt | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0de5020..16b24e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,6 +43,8 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR) PROJECT(TexC) +OPTION(TREAT_WARNINGS_AS_ERRORS "Treat compiler warnings as errors. We use the highest warnings levels for compilers." OFF) + IF(MSVC) SET(MSVC_INSTALL_PATH "${PROJECT_SOURCE_DIR}/Windows") SET(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH};${MSVC_INSTALL_PATH}") @@ -66,15 +68,20 @@ IF(MSVC) SET(MSVC_LIB_DIR "${MSVC_INSTALL_PATH}/lib/${MSVC_ARCHITECTURE_STRING}/${MSVC_VERSION_STRING}") SET(CMAKE_LIBRARY_PATH "${CMAKE_LIBRARY_PATH};${MSVC_LIB_DIR}") +ELSEIF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fms-extensions") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fms-extensions") ENDIF(MSVC) -IF(CMAKE_COMPILER_IS_GNUCC) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -fms-extensions") -ENDIF() - -IF(CMAKE_COMPILER_IS_GNUCXX) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -fms-extensions") -ENDIF() +IF(TREAT_WARNINGS_AS_ERRORS) + IF(MSVC) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX") + ELSEIF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") + ENDIF(MSVC) +ENDIF(TREAT_WARNINGS_AS_ERRORS) ADD_SUBDIRECTORY(BPTCEncoder) ADD_SUBDIRECTORY(IO)