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...

This commit is contained in:
Pavel Krajcevski 2013-01-28 18:11:29 -05:00
parent 42e4e8d4aa
commit ff1c3658fb

View File

@ -43,6 +43,8 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR) CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
PROJECT(TexC) PROJECT(TexC)
OPTION(TREAT_WARNINGS_AS_ERRORS "Treat compiler warnings as errors. We use the highest warnings levels for compilers." OFF)
IF(MSVC) IF(MSVC)
SET(MSVC_INSTALL_PATH "${PROJECT_SOURCE_DIR}/Windows") SET(MSVC_INSTALL_PATH "${PROJECT_SOURCE_DIR}/Windows")
SET(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH};${MSVC_INSTALL_PATH}") 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(MSVC_LIB_DIR "${MSVC_INSTALL_PATH}/lib/${MSVC_ARCHITECTURE_STRING}/${MSVC_VERSION_STRING}")
SET(CMAKE_LIBRARY_PATH "${CMAKE_LIBRARY_PATH};${MSVC_LIB_DIR}") 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) ENDIF(MSVC)
IF(CMAKE_COMPILER_IS_GNUCC) IF(TREAT_WARNINGS_AS_ERRORS)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -fms-extensions") IF(MSVC)
ENDIF() SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
IF(CMAKE_COMPILER_IS_GNUCXX) ELSEIF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -fms-extensions") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
ENDIF() SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
ENDIF(MSVC)
ENDIF(TREAT_WARNINGS_AS_ERRORS)
ADD_SUBDIRECTORY(BPTCEncoder) ADD_SUBDIRECTORY(BPTCEncoder)
ADD_SUBDIRECTORY(IO) ADD_SUBDIRECTORY(IO)