Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/pch/cmake/BuildConfigMSVC.cmake @ 3116

Last change on this file since 3116 was 3116, checked in by rgrieder, 15 years ago

Added new CMake functions: ORXONOX_ADD_LIBRARY and ORXONOX_ADD_EXECUTABLE.
They replace the current functions ADD_LIBRARY and ADD_EXECUTABLE to allow for clearer and easier declaration.
And it allows for GCC precompiled header file support in the first place ;)
More information can be found in TargetUtilities.cmake

  • Property svn:eol-style set to native
File size: 5.2 KB
RevLine 
[2579]1 #
[2626]2 #             ORXONOX - the hottest 3D action shooter ever to exist
3 #                             > www.orxonox.net <
[2579]4 #
[2626]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.
[2579]9 #
[2626]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.
[2579]14 #
[2626]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.
[2579]18 #
19 #
[2626]20 #  Author:
21 #    Reto Grieder
22 #  Description:
23 #    Sets the right compiler and linker flags for the Microsoft Compiler.
[2579]24 #
25
[3116]26################### Compiler Version ####################
27
28# We make use of variadic macros, which is only supported by MSVC 8 and above
29IF(MSVC_VERSION LESS 1400)
30  MESSAGE(FATAL_ERROR "Microsoft Visual Studio versions below 8 (2005) are not supported because of missing compiler extensions.")
31ENDIF()
32
33
[2639]34######################## Options ########################
35
[3116]36IF(MSVC80)
37  OPTION(VISUAL_LEAK_DETECTOR_ENABLE "Memory leak detector" FALSE)
38ENDIF(MSVC80)
[2639]39
[2621]40#################### Compiler Flags #####################
[2582]41
[2621]42# -MD    Minimal Rebuild
43# -RTC1  Both basic runtime checks
44# -MD[d] Multithreaded [debug] DLL
45# -Zi    Program Database
46# -ZI    Program Database for Edit & Continue
47# -WX    General warning Level X
48# -wdX   Disable specific warning X
49# -wnX   Set warning level of specific warning X to level n
[2582]50
[2621]51# Overwrite CMake default flags first. Be careful with this
52# Only add (not set) the general compiler flags.
53# CMake default flags : -DWIN32 -D_WINDOWS -W3 -Zm1000
54# additionally for CXX: -EHsc -GR
55ADD_COMPILER_FLAGS("-D__WIN32__ -D_WIN32"      CACHE)
56ADD_COMPILER_FLAGS("-D_CRT_SECURE_NO_WARNINGS" CACHE)
[2582]57
[2639]58# Overwrite CMake default flags here.
59SET_COMPILER_FLAGS("-MDd -Od -ZI -D_DEBUG -Gm -RTC1" Debug          CACHE)
60SET_COMPILER_FLAGS("-MD  -O2     -DNDEBUG -MP2"      Release        CACHE)
[2668]61SET_COMPILER_FLAGS("-MD  -O2 -Zi -DNDEBUG -MP2"      RelWithDebInfo CACHE)
[2639]62SET_COMPILER_FLAGS("-MD  -O1     -DNDEBUG -MP2"      MinSizeRel     CACHE)
63
[2668]64# Microsoft unfortunately couldn't integrate a fix issued while VS 2008 beta 2
65# was being tested into the final release even though a fix existed...
66# And it's actually quite a big issue, you simple can't compile anything.
67# Fortunately for us, disabling Minimal Rebuild solves the problem.
68REMOVE_COMPILER_FLAGS("-Gm" Debug MSVC09 CACHE)
69# And since we have to remove /Gm, let's add /MP2 to speed things up
70ADD_COMPILER_FLAGS("-MP2" Debug MSVC09 CACHE)
[2639]71
[2668]72
[2639]73####################### Warnings ########################
74
[2621]75# Increase warning level if requested
[2673]76IF(EXTRA_COMPILER_WARNINGS)
[2621]77  REMOVE_COMPILER_FLAGS("-W1 -W2 -W3" CACHE)
78  ADD_COMPILER_FLAGS   ("-W4" CACHE)
[2624]79ELSE()
[2621]80  REMOVE_COMPILER_FLAGS("-W1 -W2 -W4" CACHE)
81  ADD_COMPILER_FLAGS   ("-W3" CACHE)
[2624]82ENDIF()
[2583]83
[2639]84# "<type> needs to have dll-interface to be used by clients'
85# Happens on STL member variables which are not public
86ADD_COMPILER_FLAGS("-w44251" CACHE)
[2588]87
[2639]88# Multiple assignment operators specified
89ADD_COMPILER_FLAGS("-w44522" CACHE)
[2626]90
[2639]91# Forcing values to bool
92ADD_COMPILER_FLAGS("-w44800" CACHE)
93
94# This warns about truncation to 255 characters in debug/browse info
95# ADD_COMPILER_FLAGS("-w44786 -w44503" CACHE)
96
97# conversion from 'double' to 'float', possible loss of data
98# conversion from 'ogg_int64_t' to 'long', possible loss of data
99# ADD_COMPILER_FLAGS("-w44244" CACHE)
100
101# "conversion from 'size_t' to 'unsigned int', possible loss of data
102# ADD_COMPILER_FLAGS("-w44267" CACHE)
103
104# "truncation from 'double' to 'float'
105# ADD_COMPILER_FLAGS("-w44305" CACHE)
106
107# "non dll-interface class used as base for dll-interface class"
108# ADD_COMPILER_FLAGS("-w44275" CACHE)
109
110# "C++ Exception Specification ignored"
111# This is because MSVC 6 did not implement all the C++ exception
112# specifications in the ANSI C++ draft.
113# ADD_COMPILER_FLAGS("-w44290" CACHE)
114
115# "no suitable definition provided for explicit template
116# instantiation request" Occurs in VC7 for no justifiable reason.
117# ADD_COMPILER_FLAGS("-w44661" CACHE)
118
119# Deprecation warnings when using CRT calls in VC8
120# These show up on all C runtime lib code in VC8, disable since they clutter
121# the warnings with things we may not be able to do anything about (e.g.
122# generated code from nvparse etc). I doubt very much that these calls
123# will ever be actually removed from VC anyway, it would break too much code.
124# Note: Probably handled by "-DCRT_SECURE_NO_WARNINGS"
125# ADD_COMPILER_FLAGS("-w44996" CACHE)
126
127# "conditional expression constant"
128# ADD_COMPILER_FLAGS("-w4201" CACHE)
129
130
[2621]131##################### Linker Flags ######################
[2588]132
[2621]133# CMake default flags: -MANIFEST -STACK:10000000 -machine:I386
134# and INCREMENTAL and DEBUG for debug versions
[2643]135ADD_LINKER_FLAGS("-OPT:REF -OPT:ICF" Release MinSizeRel CACHE)
136ADD_LINKER_FLAGS("-OPT:NOWIN98" MSVC80 CACHE)
Note: See TracBrowser for help on using the repository browser.