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)