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