Merge pull request #117 from OdyX/dev-C++11-fixes

C++11 fixes to get travis build
dev-ui
Piotr Dziwiński 2013-01-10 10:41:10 -08:00
commit 35faf628cf
2 changed files with 18 additions and 11 deletions

View File

@ -1,9 +1,11 @@
language: cpp language: cpp
compiler: compiler:
- gcc - gcc
script: cmake . -DCMAKE_VERBOSE_MAKEFILE=ON && make all doc test - clang
script: mkdir build; cd build; cmake .. -DCMAKE_VERBOSE_MAKEFILE=ON && make all doc test && DESTDIR=. make install
before_install: before_install:
- git submodule update --init --recursive - git submodule update --init --recursive
- sudo add-apt-repository ppa:mapnik/boost -y
- sudo apt-get update -qq - sudo apt-get update -qq
- sudo apt-get install -qq --no-install-recommends libgl1-mesa-dev libsdl1.2-dev libsdl-image1.2-dev libsdl-ttf2.0-dev libpng12-dev libglew-dev libboost-dev libboost-system-dev libboost-filesystem-dev libboost-regex-dev google-mock libgtest-dev doxygen graphviz po4a librsvg2-bin - sudo apt-get install -qq --no-install-recommends libgl1-mesa-dev libsdl1.2-dev libsdl-image1.2-dev libsdl-ttf2.0-dev libpng12-dev libglew-dev libboost-dev libboost-system-dev libboost-filesystem-dev libboost-regex-dev google-mock libgtest-dev doxygen graphviz po4a librsvg2-bin
notifications: notifications:

View File

@ -46,29 +46,34 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE debug) set(CMAKE_BUILD_TYPE debug)
endif() endif()
# Global compile flags
# 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 # Compiler detection
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
execute_process( execute_process(
COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION) COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
if (NOT (GCC_VERSION VERSION_GREATER 4.6 OR GCC_VERSION VERSION_EQUAL 4.6)) if (GCC_VERSION VERSION_GREATER 4.7 OR GCC_VERSION VERSION_EQUAL 4.7)
message(FATAL_ERROR "${PROJECT_NAME} requires GCC 4.6 or greater.") message(STATUS "Detected GCC version 4.7+")
else() set(CXX11_FLAGS "-std=c++11")
elseif (GCC_VERSION VERSION_GREATER 4.6 OR GCC_VERSION VERSION_EQUAL 4.6)
message(STATUS "Detected GCC version 4.6+") message(STATUS "Detected GCC version 4.6+")
set(CXX11_FLAGS "-std=c++0x")
else()
message(FATAL_ERROR "${PROJECT_NAME} requires GCC 4.6 or greater.")
endif() endif()
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
message(STATUS "Detected Clang compiler") message(STATUS "Detected Clang compiler")
set(CXX11_FLAGS "-std=c++11")
else() else()
message(FATAL_ERROR "Your C++ compiler doesn't seem to support C++11.\n" 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.") "Supported compilers at this time are GCC 4.6+ and clang.")
endif() endif()
# Global compile flags
# 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 ${CXX11_FLAGS}")
set(COLOBOT_CXX_FLAGS_RELEASE "-O2")
set(COLOBOT_CXX_FLAGS_DEBUG "-g -O0")
# Asserts can be enabled/disabled regardless of build type # Asserts can be enabled/disabled regardless of build type
option(ASSERTS "Enable assert()s" ON) option(ASSERTS "Enable assert()s" ON)