Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/OrxonoxConfig.cmake @ 8411

Last change on this file since 8411 was 8409, checked in by rgrieder, 14 years ago

Found a better solution to make the Visual Leak Detector (MSVC specific) work so that it doesn't need to be included in every single source file.

  • Property svn:eol-style set to native
File size: 4.5 KB
Line 
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
32IF(PCH_COMPILER_SUPPORT AND NOT APPLE)
33  OPTION(PCH_ENABLE "Global PCH switch" TRUE)
34ENDIF()
35
36# Global switch to disable multiple file compilations
37OPTION(DISABLE_COMPILATIONS "Global multi-file compilation switch" FALSE)
38
39# Use WinMain() or main()?
40IF(WIN32)
41  OPTION(ORXONOX_USE_WINMAIN "Use WinMain (doesn't show console) or main" FALSE)
42ENDIF()
43
44################ Platform Config ################
45
46# Check endianness
47INCLUDE(TestBigEndian)
48TEST_BIG_ENDIAN(ORXONOX_BIG_ENDIAN)
49IF(NOT ORXONOX_BIG_ENDIAN)
50  SET(ORXONOX_LITTLE_ENDIAN TRUE)
51ENDIF()
52
53# Platforms
54SET(ORXONOX_PLATFORM_WINDOWS ${WIN32})
55SET(ORXONOX_PLATFORM_APPLE   ${APPLE})
56SET(ORXONOX_PLATFORM_UNIX    ${UNIX})
57SET(ORXONOX_PLATFORM_LINUX   ${LINUX})
58
59# Check __forceinline
60IF(MSVC)
61  INCLUDE(CheckCXXSourceCompiles)
62  SET(_source "int main() { return 0; } __forceinline void test() { return; }")
63  CHECK_CXX_SOURCE_COMPILES("${_source}" HAVE_FORCEINLINE)
64ENDIF(MSVC)
65
66# Check some non standard system includes
67INCLUDE(CheckIncludeFileCXX)
68CHECK_INCLUDE_FILE_CXX(iso646.h HAVE_ISO646_H)
69CHECK_INCLUDE_FILE_CXX(stdint.h HAVE_STDINT_H)
70
71# Part of a woraround for OS X warnings. See OrxonoxConfig.h.in
72SET(ORX_HAVE_STDINT_H ${HAVE_STDINT_H})
73
74# XCode and Visual Studio support multiple configurations. In order to tell
75# about the active one we have to define the macro for each configuration
76ADD_COMPILER_FLAGS("-DCMAKE_Debug_BUILD"          Debug)
77ADD_COMPILER_FLAGS("-DCMAKE_RelForDevs_BUILD"     RelForDevs)
78ADD_COMPILER_FLAGS("-DCMAKE_Release_BUILD"        Release)
79ADD_COMPILER_FLAGS("-DCMAKE_RelWithDebInfo_BUILD" RelWithDebInfo)
80ADD_COMPILER_FLAGS("-DCMAKE_MinSizeRel_BUILD"     MinSizeRel)
81
82IF(MSVC)
83  # Check whether we can use Visual Leak Detector
84  FIND_FILE(VLD_DLL vld_x86.dll)
85  IF(VLD_DLL)
86    SET(HAVE_VLD TRUE)
87    OPTION(VISUAL_LEAK_DETECTOR_ENABLE "Memory leak detector" off)
88    # Make sure the value is "on" or "off" for vld.ini
89    IF(VISUAL_LEAK_DETECTOR_ENABLE)
90      SET(VISUAL_LEAK_DETECTOR_ENABLE on)
91    ELSE()
92      SET(VISUAL_LEAK_DETECTOR_ENABLE off)
93    ENDIF()
94    SET(VLD_LIBRARY vld.lib)
95    # Force symbol reference
96    # The alternative would be to include vld.h everywhere (includes windows.h)
97    ADD_LINKER_FLAGS("-INCLUDE:__imp_?vld@@3VVisualLeakDetector@@A" Debug)
98  ENDIF()
99  MARK_AS_ADVANCED(VLD_DLL)
100ENDIF()
101
102############## Configured Headers ###############
103
104SET(GENERATED_FILE_COMMENT
105   "DO NOT EDIT THIS FILE! <br>
106    It has been automatically generated by CMake from OrxonoxConfig.h.in")
107# Copy and configure OrxonoxConfig which gets included in every file
108CONFIGURE_FILE(OrxonoxConfig.h.in ${CMAKE_CURRENT_BINARY_DIR}/OrxonoxConfig.h)
109# This file only gets included by very few classes to avoid a large recompilation
110CONFIGURE_FILE(SpecialConfig.h.in ${CMAKE_CURRENT_BINARY_DIR}/SpecialConfig.h)
111
112SET(ORXONOX_CONFIG_FILES
113  ${CMAKE_CURRENT_SOURCE_DIR}/OrxonoxConfig.h.in
114  ${CMAKE_CURRENT_SOURCE_DIR}/SpecialConfig.h.in
115)
116SET(ORXONOX_CONFIG_FILES_GENERATED
117  ${CMAKE_CURRENT_BINARY_DIR}/OrxonoxConfig.h
118  ${CMAKE_CURRENT_BINARY_DIR}/SpecialConfig.h
119)
120
121# Make special target including the configured header files for Visual Studio
122IF(MSVC)
123  ADD_CUSTOM_TARGET(config
124    SOURCES
125      ${ORXONOX_CONFIG_FILES}
126      ${ORXONOX_CONFIG_FILES_GENERATED}
127  )
128ENDIF()
Note: See TracBrowser for help on using the repository browser.