1 | # |
---|
2 | # ORXONOX - the hottest 3D action shooter ever to exist |
---|
3 | # > www.orxonox.net < |
---|
4 | # |
---|
5 | # This program is free software; you can redistribute it and/or |
---|
6 | # modify it under the terms of the GNU General Public License |
---|
7 | # as published by the Free Software Foundation; either version 2 |
---|
8 | # of the License, or (at your option) any later version. |
---|
9 | # |
---|
10 | # This program is distributed in the hope that it will be useful, |
---|
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
13 | # GNU General Public License for more details. |
---|
14 | # |
---|
15 | # You should have received a copy of the GNU General Public License along |
---|
16 | # with this program; if not, write to the Free Software Foundation, |
---|
17 | # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
18 | # |
---|
19 | # |
---|
20 | # Author: |
---|
21 | # Reto Grieder |
---|
22 | # Description: |
---|
23 | # Configures the header files OrxonoxConfig.h and SpecialConfig.h |
---|
24 | # and sets some other options. All the build related options should be |
---|
25 | # found and set here if possible. |
---|
26 | # |
---|
27 | |
---|
28 | #################### Options #################### |
---|
29 | |
---|
30 | # Global switch to disable Precompiled Header Files |
---|
31 | # Note: PCH temporarily disabled on Mac because of severe problems |
---|
32 | IF(PCH_COMPILER_SUPPORT AND NOT APPLE) |
---|
33 | OPTION(PCH_ENABLE "Global PCH switch" TRUE) |
---|
34 | ENDIF() |
---|
35 | |
---|
36 | # Global option to steer building muliple files as a single one |
---|
37 | # off/false: Turn off completely |
---|
38 | # partial: Only combine files explicitly specified with BUILD_UNIT |
---|
39 | # full##: Use ## source files per orxonox library and use manual build units |
---|
40 | # for external dependencies. Example: full8 will in general use 8 |
---|
41 | # source files per library, but more specifically tries to occupy |
---|
42 | # 8 CPU threads. |
---|
43 | # This is configured manually in BuildUnitsConfig.cmake |
---|
44 | SET(ENABLE_BUILD_UNITS "partial" CACHE STRING "Enables building multiple source files as one.") |
---|
45 | IF(ENABLE_BUILD_UNITS) |
---|
46 | IF(NOT "${ENABLE_BUILD_UNITS}" STREQUAL "partial") |
---|
47 | STRING(REGEX REPLACE "^full([1-9][0-9]?)$" "\\1" _nr_of_units "${ENABLE_BUILD_UNITS}") |
---|
48 | IF("${_nr_of_units}" STREQUAL "${ENABLE_BUILD_UNITS}") # Regex match failed |
---|
49 | MESSAGE(FATAL_ERROR "Unrecognised option for ENABLE_BUILD_UNITS: ${ENABLE_BUILD_UNITS}") |
---|
50 | ELSE() |
---|
51 | SET(NR_OF_BUILD_UNITS ${_nr_of_units}) |
---|
52 | ENDIF() |
---|
53 | ENDIF() |
---|
54 | IF(CMAKE_COMPILER_IS_GNU) |
---|
55 | INCLUDE(BuildUnitsConfigGCC.cmake) |
---|
56 | ELSEIF(MSVC) |
---|
57 | INCLUDE(BuildUnitsConfigMSVC.cmake) |
---|
58 | ENDIF() |
---|
59 | ENDIF() |
---|
60 | |
---|
61 | # Use WinMain() or main()? |
---|
62 | IF(WIN32) |
---|
63 | OPTION(ORXONOX_USE_WINMAIN "Use WinMain (doesn't show console) or main" FALSE) |
---|
64 | ENDIF() |
---|
65 | |
---|
66 | ################ Platform Config ################ |
---|
67 | |
---|
68 | # Check endianness |
---|
69 | INCLUDE(TestBigEndian) |
---|
70 | TEST_BIG_ENDIAN(ORXONOX_BIG_ENDIAN) |
---|
71 | IF(NOT ORXONOX_BIG_ENDIAN) |
---|
72 | SET(ORXONOX_LITTLE_ENDIAN TRUE) |
---|
73 | ENDIF() |
---|
74 | |
---|
75 | # Platforms |
---|
76 | SET(ORXONOX_PLATFORM_WINDOWS ${WIN32}) |
---|
77 | SET(ORXONOX_PLATFORM_APPLE ${APPLE}) |
---|
78 | SET(ORXONOX_PLATFORM_UNIX ${UNIX}) |
---|
79 | SET(ORXONOX_PLATFORM_LINUX ${LINUX}) |
---|
80 | |
---|
81 | # Check __forceinline |
---|
82 | IF(MSVC) |
---|
83 | INCLUDE(CheckCXXSourceCompiles) |
---|
84 | SET(_source "int main() { return 0; } __forceinline void test() { return; }") |
---|
85 | CHECK_CXX_SOURCE_COMPILES("${_source}" HAVE_FORCEINLINE) |
---|
86 | ENDIF(MSVC) |
---|
87 | |
---|
88 | # Check some non standard system includes |
---|
89 | INCLUDE(CheckIncludeFileCXX) |
---|
90 | CHECK_INCLUDE_FILE_CXX(iso646.h HAVE_ISO646_H) |
---|
91 | CHECK_INCLUDE_FILE_CXX(stdint.h HAVE_STDINT_H) |
---|
92 | |
---|
93 | # Part of a woraround for OS X warnings. See OrxonoxConfig.h.in |
---|
94 | SET(ORX_HAVE_STDINT_H ${HAVE_STDINT_H}) |
---|
95 | |
---|
96 | # XCode and Visual Studio support multiple configurations. In order to tell |
---|
97 | # about the active one we have to define the macro for each configuration |
---|
98 | ADD_COMPILER_FLAGS("-DCMAKE_Debug_BUILD" Debug) |
---|
99 | ADD_COMPILER_FLAGS("-DCMAKE_RelForDevs_BUILD" RelForDevs) |
---|
100 | ADD_COMPILER_FLAGS("-DCMAKE_Release_BUILD" Release) |
---|
101 | ADD_COMPILER_FLAGS("-DCMAKE_RelWithDebInfo_BUILD" RelWithDebInfo) |
---|
102 | ADD_COMPILER_FLAGS("-DCMAKE_MinSizeRel_BUILD" MinSizeRel) |
---|
103 | |
---|
104 | ############## Configured Headers ############### |
---|
105 | |
---|
106 | SET(GENERATED_FILE_COMMENT |
---|
107 | "DO NOT EDIT THIS FILE! <br> |
---|
108 | It has been automatically generated by CMake from OrxonoxConfig.h.in") |
---|
109 | # Copy and configure OrxonoxConfig which gets included in every file |
---|
110 | CONFIGURE_FILE(OrxonoxConfig.h.in ${CMAKE_CURRENT_BINARY_DIR}/OrxonoxConfig.h) |
---|
111 | # This file only gets included by very few classes to avoid a large recompilation |
---|
112 | CONFIGURE_FILE(SpecialConfig.h.in ${CMAKE_CURRENT_BINARY_DIR}/SpecialConfig.h) |
---|
113 | |
---|
114 | SET(ORXONOX_CONFIG_FILES |
---|
115 | ${CMAKE_CURRENT_SOURCE_DIR}/OrxonoxConfig.h.in |
---|
116 | ${CMAKE_CURRENT_SOURCE_DIR}/SpecialConfig.h.in |
---|
117 | ) |
---|
118 | SET(ORXONOX_CONFIG_FILES_GENERATED |
---|
119 | ${CMAKE_CURRENT_BINARY_DIR}/OrxonoxConfig.h |
---|
120 | ${CMAKE_CURRENT_BINARY_DIR}/SpecialConfig.h |
---|
121 | ) |
---|
122 | |
---|
123 | # Make special target including the configured header files for Visual Studio |
---|
124 | IF(MSVC) |
---|
125 | ADD_CUSTOM_TARGET(config |
---|
126 | SOURCES |
---|
127 | ${ORXONOX_CONFIG_FILES} |
---|
128 | ${ORXONOX_CONFIG_FILES_GENERATED} |
---|
129 | ) |
---|
130 | ENDIF() |
---|