summaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorPiotr Dziwinski <piotrdz@gmail.com>2013-01-08 22:12:09 +0100
committerPiotr Dziwinski <piotrdz@gmail.com>2013-01-08 22:12:09 +0100
commit1285712aa22382a1a0d943aa29b310ecf6ebd365 (patch)
treed3e621fe3309b6ea11877cd1ec3f8ca857d251bd /CMakeLists.txt
parent5a6b3f005a83363d323e00b499756d6ecc277574 (diff)
downloadcolobot-1285712aa22382a1a0d943aa29b310ecf6ebd365.tar.gz
colobot-1285712aa22382a1a0d943aa29b310ecf6ebd365.tar.bz2
colobot-1285712aa22382a1a0d943aa29b310ecf6ebd365.zip
CMakeLists enhancements
- compiler detection (clang and gcc version check) - compile flags only for src/ subdir - system and local include paths - fix for clang compilation
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt25
1 files changed, 21 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 339e633..7e19ba0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -47,10 +47,27 @@ if(NOT CMAKE_BUILD_TYPE)
endif()
# Global compile flags
-# These are specific to GCC/MinGW; for other compilers, change as necessary
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wold-style-cast -std=c++11")
-set(CMAKE_CXX_FLAGS_RELEASE "-O2")
-set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
+# These are specific to GCC/MinGW/clang; for other compilers, change as necessary
+# The flags are used throughout src/ subdir
+set(COLOBOT_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wold-style-cast -std=c++11")
+set(COLOBOT_CXX_FLAGS_RELEASE "-O2")
+set(COLOBOT_CXX_FLAGS_DEBUG "-g -O0")
+
+# Compiler detection
+if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
+ execute_process(
+ COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
+ if (NOT (GCC_VERSION VERSION_GREATER 4.6 OR GCC_VERSION VERSION_EQUAL 4.6))
+ message(FATAL_ERROR "${PROJECT_NAME} requires GCC 4.6 or greater.")
+ else()
+ message(STATUS "Detected GCC version 4.6+")
+ endif()
+elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
+ message(STATUS "Detected Clang compiler")
+else()
+ message(FATAL_ERROR "Your C++ compiler doesn't seem to support C++11.\n"
+ "Supported compilers at this time are GCC 4.6+ and clang.")
+endif()
# Asserts can be enabled/disabled regardless of build type
option(ASSERTS "Enable assert()s" ON)