Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/cmake/CompilerConfigMSVC.cmake @ 8362

Last change on this file since 8362 was 8362, checked in by rgrieder, 13 years ago

Cleaned up linker and compiler flag configuration for Visual Studio.
ORXONOX_RELEASE is not respected anymore (see next commit).

  • Property svn:eol-style set to native
File size: 5.3 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 #    Sets the right compiler and linker flags for the Microsoft Compiler.
24 #
25
26INCLUDE(FlagUtilities)
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.")
31ENDIF()
32
33# Orxonox only supports MSVC 8 and above, which gets asserted above
34SET(PCH_COMPILER_SUPPORT TRUE)
35
36
37#################### Compiler Flags #####################
38
39# CMake default flags : -DWIN32 -D_WINDOWS -W3 -Zm1000
40# additionally for CXX: -EHsc -GR
41# We keep these flags but reset the build specific flags
42SET_COMPILER_FLAGS("" Debug RelWithDebInfo Release MinSizeRel CACHE)
43
44# Make sure we define all the possible macros for identifying Windows
45ADD_COMPILER_FLAGS("-D__WIN32__ -D_WIN32"  CACHE)
46# Suppress some annoying warnings
47ADD_COMPILER_FLAGS("-D_CRT_SECURE_NO_WARNINGS" CACHE)
48ADD_COMPILER_FLAGS("-D_SCL_SECURE_NO_WARNINGS" CACHE)
49
50# Use multiprocessed compiling (like "make -j3" on Unix)
51ADD_COMPILER_FLAGS("-MP" CACHE)
52
53# Always generate debug symbols (there is really no reason not to)
54ADD_COMPILER_FLAGS("-Zi" CACHE)
55
56# Never omit frame pointers to avoid useless stack traces (the performance
57# loss is almost not measurable)
58ADD_COMPILER_FLAGS("-Oy-" CACHE)
59# Enable non standard floating point optimisations
60ADD_COMPILER_FLAGS("-fp:fast" CACHE)
61
62# Set build specific flags.
63# -MD[d]    Multithreaded [debug] shared MSVC runtime library
64# -O[d|2|1] No optimisations, optimise for speed, optimise for size
65# -Oi[-]    Use or disable use of intrinisic functions
66# -GL       Link time code generation (see -LTCG in linker flags)
67# -RTC1     Both basic runtime checks
68ADD_COMPILER_FLAGS("-MDd -Od -Oi  -D_DEBUG -RTC1" Debug          CACHE)
69ADD_COMPILER_FLAGS("-MD  -O2 -Oi  -DNDEBUG"       RelWithDebInfo CACHE)
70ADD_COMPILER_FLAGS("-MD  -O2 -Oi  -DNDEBUG -GL"   Release        CACHE)
71ADD_COMPILER_FLAGS("-MD  -O1 -Oi- -DNDEBUG -GL"   MinSizeRel     CACHE)
72
73
74####################### Warnings ########################
75
76# -WX    General warning Level X
77# -wdX   Disable specific warning X
78# -wnX   Set warning level of specific warning X to level n
79
80# Increase warning level if requested
81IF(EXTRA_COMPILER_WARNINGS)
82  REMOVE_COMPILER_FLAGS("-W1 -W2 -W3" CACHE)
83  ADD_COMPILER_FLAGS   ("-W4" CACHE)
84ELSE()
85  REMOVE_COMPILER_FLAGS("-W1 -W2 -W4" CACHE)
86  ADD_COMPILER_FLAGS   ("-W3" CACHE)
87ENDIF()
88
89# "<type> needs to have dll-interface to be used by clients'
90# Happens on STL member variables which are not public
91ADD_COMPILER_FLAGS("-w44251" CACHE)
92ADD_COMPILER_FLAGS("-w44275" CACHE) # For inheritance
93
94# Multiple assignment operators specified
95ADD_COMPILER_FLAGS("-w44522" CACHE)
96
97# Forcing values to bool
98ADD_COMPILER_FLAGS("-w44800" CACHE)
99
100# TODO: Resolve the cause of this warning!
101# ('class1' : inherits 'class2::member' via dominance)
102ADD_COMPILER_FLAGS("-w44250" CACHE)
103
104# conversion from 'double' to 'float', possible loss of data
105# conversion from 'ogg_int64_t' to 'long', possible loss of data
106# ADD_COMPILER_FLAGS("-w44244" CACHE)
107
108# "conversion from 'size_t' to 'unsigned int', possible loss of data
109# ADD_COMPILER_FLAGS("-w44267" CACHE)
110
111# "truncation from 'double' to 'float'
112# ADD_COMPILER_FLAGS("-w44305" CACHE)
113
114# "non dll-interface class used as base for dll-interface class"
115# ADD_COMPILER_FLAGS("-w44275" CACHE)
116
117
118##################### Linker Flags ######################
119
120# CMake default flags: -MANIFEST -STACK:10000000 -machine:I386
121# We keep these flags but reset the build specific flags
122SET_LINKER_FLAGS("" Debug RelWithDebInfo Release MinSizeRel CACHE)
123
124# Always generate debug symbols (there is really no reason not to)
125ADD_LINKER_FLAGS("-DEBUG" CACHE)
126
127# Never fold multiple functions into a single one because we might compare
128# function pointers (for instance with network functions)
129ADD_LINKER_FLAGS("-OPT:NOICF" CACHE)
130
131# Very old flag that would do some extra Windows 98 alignment optimisations
132ADD_LINKER_FLAGS("-OPT:NOWIN98" MSVC80 CACHE)
133
134# Incremental linking speeds up development builds
135ADD_LINKER_FLAGS("-INCREMENTAL:YES" Debug   RelWithDebInfo CACHE)
136ADD_LINKER_FLAGS("-INCREMENTAL:NO"  Release MinSizeRel     CACHE)
137
138# Eliminate unreferenced data
139ADD_LINKER_FLAGS("-OPT:REF" Release MinSizeRel CACHE)
140
141# Link time code generation can improve run time performance at the cost of
142# hugely increased link time (the total build time is about the same though)
143ADD_LINKER_FLAGS("-LTCG" Release MinSizeRel CACHE)
Note: See TracBrowser for help on using the repository browser.