CMake: Add compiler checks and GCC version checks

develop
lethosor 2015-09-26 10:46:29 -04:00
parent d2a1a94368
commit ec17685041
2 changed files with 28 additions and 1 deletions

@ -14,6 +14,33 @@ endif(CMAKE_CONFIGURATION_TYPES)
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(dfhack)
macro(CHECK_GCC COMPILER_PATH)
execute_process(COMMAND ${COMPILER_PATH} -dumpversion OUTPUT_VARIABLE GCC_VERSION_OUT)
string(STRIP "${GCC_VERSION_OUT}" GCC_VERSION_OUT)
if (${GCC_VERSION_OUT} VERSION_LESS "4.5" OR ${GCC_VERSION_OUT} VERSION_GREATER "4.9.9")
message(SEND_ERROR "${COMPILER_PATH} version ${GCC_VERSION_OUT} cannot be used - use GCC 4.5 through 4.9")
endif()
endmacro()
if(UNIX)
if(CMAKE_COMPILER_IS_GNUCC)
CHECK_GCC(${CMAKE_C_COMPILER})
else()
message(SEND_ERROR "C compiler is not GCC")
endif()
if(CMAKE_COMPILER_IS_GNUCXX)
CHECK_GCC(${CMAKE_CXX_COMPILER})
else()
message(SEND_ERROR "C++ compiler is not GCC")
endif()
endif()
if(WIN32)
if(NOT MSVC)
message(SEND_ERROR "MSVC 2010 is required")
endif()
endif()
if(MSVC)
# disable C4819 code-page warning
add_definitions( "/wd4819" )

@ -298,7 +298,7 @@ SET_TARGET_PROPERTIES(dfhack PROPERTIES DEBUG_POSTFIX "-debug" )
IF(APPLE)
SET(SDL_LIBRARY ${CMAKE_INSTALL_PREFIX}/libs/SDL.framework)
IF(NOT EXISTS ${SDL_LIBRARY})
MESSAGE(FATAL_ERROR "SDL framework not found. Make sure CMAKE_INSTALL_PREFIX is specified and correct.")
MESSAGE(SEND_ERROR "SDL framework not found. Make sure CMAKE_INSTALL_PREFIX is specified and correct.")
ENDIF()
SET(CXX_LIBRARY ${CMAKE_INSTALL_PREFIX}/libs/libstdc++.6.dylib)
SET(ZIP_LIBRARY /usr/lib/libz.dylib)