diff options
author | Zaba999 <qrwfw5rp> | 2012-09-29 23:53:57 +0200 |
---|---|---|
committer | Zaba999 <qrwfw5rp> | 2012-09-29 23:53:57 +0200 |
commit | 95e1d101c82e43396fd93abfaa522e3651613c4c (patch) | |
tree | 9d72f27e84a25c7a744b31eb7612698506ac5b68 /CMakeLists.txt | |
parent | aa9df8b1f0fbbad4c7be0214a19a90b8495a2067 (diff) | |
parent | c8f39a4c96ab63f9e3edc96845e1b70c89b95d2b (diff) | |
download | colobot-95e1d101c82e43396fd93abfaa522e3651613c4c.tar.gz colobot-95e1d101c82e43396fd93abfaa522e3651613c4c.tar.bz2 colobot-95e1d101c82e43396fd93abfaa522e3651613c4c.zip |
Merge branch 'dev' of https://github.com/colobot/colobot into dev
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 111 |
1 files changed, 98 insertions, 13 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index eee86fb..1353250 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,42 @@ -# CMake project file for compiling with GCC/MinGW +## +# Main CMake project file +# Contains global options and definitions +## cmake_minimum_required(VERSION 2.8) project(colobot C CXX) +# Include cmake directory with some additional scripts +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${colobot_SOURCE_DIR}/cmake") + + +## +# Build options +## + +# Global build type +set(CMAKE_BUILD_TYPE debug) + +# Global compile flags +# These are specific to GCC/MinGW; for other compilers, change as necessary +set(CMAKE_CXX_FLAGS_RELEASE "-O2 -Wall -Wold-style-cast -std=gnu++0x") +set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -Wold-style-cast -std=gnu++0x") + +# Asserts can be enabled/disabled regardless of build type +option(ASSERTS "Enable assert()s" ON) + +# Building tests can be enabled/disabled +option(TESTS "Enable tests" ON) + +# CBot can also be a static library +option(CBOT_STATIC "Build CBot as static libary" OFF) + + +## # Required packages +## + find_package(OpenGL 1.4 REQUIRED) find_package(SDL 1.2.10 REQUIRED) find_package(SDL_image 1.2 REQUIRED) @@ -18,7 +50,6 @@ set(Boost_USE_STATIC_RUNTIME OFF) set(Boost_ADDITIONALVERSION "1.51" "1.51.0") find_package(Boost COMPONENTS system filesystem regex REQUIRED) - # GLEW requirement depends on platform # By default it is auto detected # This setting may be used to override @@ -27,22 +58,76 @@ find_package(Boost COMPONENTS system filesystem regex REQUIRED) # - 1 -> always enable # - 0 -> always disable set(USE_GLEW auto) +# This is useful on Windows, if linking against standard GLEW dll fails +option(GLEW_STATIC "Link statically with GLEW" OFF) -# Build with debugging symbols -set(CMAKE_BUILD_TYPE debug) -# Global compile flags -set(CMAKE_CXX_FLAGS_RELEASE "-O2 -Wall -Wold-style-cast -std=gnu++0x") -set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -Wold-style-cast -std=gnu++0x") +## +# Additional settings to use when cross-compiling with MXE (http://mxe.cc/) +## + +include("${colobot_SOURCE_DIR}/cmake/mxe.cmake") + + +## +# Platform detection and some related checks +## + +if (${CMAKE_SYSTEM_NAME} MATCHES "Windows") + message(STATUS "Windows system detected") + set(PLATFORM_WINDOWS 1) + set(PLATFORM_LINUX 0) + set(PLATFORM_OTHER 0) + + # On Windows, GLEW is required + if (${USE_GLEW} MATCHES "auto") + set(USE_GLEW 1) + endif() +elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + message(STATUS "Linux system detected") + set(PLATFORM_WINDOWS 0) + set(PLATFORM_LINUX 1) + set(PLATFORM_OTHER 0) + + # On Linux, we should be fine without GLEW + if (${USE_GLEW} MATCHES "auto") + set(USE_GLEW 0) + endif() +else() + message(STATUS "Other system detected") + set(PLATFORM_WINDOWS 0) + set(PLATFORM_LINUX 0) + set(PLATFORM_OTHER 1) + + # Use GLEW to be safe + if (${USE_GLEW} MATCHES "auto") + set(USE_GLEW 1) + endif() +endif() + + +if(${USE_GLEW}) + find_package(GLEW REQUIRED) +endif() + +if(NOT ${ASSERTS}) + add_definitions(-DNDEBUG) +endif() + +if(${TESTS}) + enable_testing() +endif() -# Include cmake directory -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${colobot_SOURCE_DIR}/cmake") -enable_testing() +## +# Targets +## -# Google Test library -set(GTEST_DIR "${colobot_SOURCE_DIR}/lib/gtest") -add_subdirectory(lib/gtest bin/test) +if(${TESTS}) + # Google Test library + set(GTEST_DIR "${colobot_SOURCE_DIR}/lib/gtest") + add_subdirectory(lib/gtest bin/test) +endif() # Subdirectory with sources add_subdirectory(src bin) |