Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/kicklib/cmake/CompilerConfigMSVC.cmake @ 8080

Last change on this file since 8080 was 8071, checked in by rgrieder, 14 years ago

Merged ois_update branch (before it was renamed to mac_osx) into kicklib branch.

  • Property svn:eol-style set to native
File size: 6.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################### Compiler Version ####################
29
30# We make use of variadic macros, which is only supported by MSVC 8 and above
31IF(MSVC_VERSION LESS 1400)
32  MESSAGE(FATAL_ERROR "Microsoft Visual Studio versions below 8 (2005) are not supported because of missing compiler extensions.")
33ENDIF()
34
35
36######################## Options ########################
37
38# Orxonox only supports MSVC 8 and above, which gets asserted above
39SET(PCH_COMPILER_SUPPORT TRUE)
40
41
42#################### Compiler Flags #####################
43
44# -MD    Minimal Rebuild
45# -RTC1  Both basic runtime checks
46# -MD[d] Multithreaded [debug] DLL
47# -Zi    Program Database
48# -ZI    Program Database for Edit & Continue
49# -WX    General warning Level X
50# -wdX   Disable specific warning X
51# -wnX   Set warning level of specific warning X to level n
52
53# Only add (not set) some general compiler flags.
54# CMake default flags : -DWIN32 -D_WINDOWS -W3 -Zm1000
55# additionally for CXX: -EHsc -GR
56# -MP is for multiprocessed compiling
57ADD_COMPILER_FLAGS("-D__WIN32__ -D_WIN32 -MP"  CACHE)
58ADD_COMPILER_FLAGS("-D_CRT_SECURE_NO_WARNINGS" CACHE)
59ADD_COMPILER_FLAGS("-D_SCL_SECURE_NO_WARNINGS" CACHE)
60
61# Overwrite CMake default flags here for the individual configurations
62SET_COMPILER_FLAGS("-MDd -Od -Oi -Zi -D_DEBUG -RTC1" Debug          CACHE)
63SET_COMPILER_FLAGS("-MD  -O2         -DNDEBUG"       Release        CACHE)
64SET_COMPILER_FLAGS("-MD  -O2     -Zi -DNDEBUG"       RelWithDebInfo CACHE)
65SET_COMPILER_FLAGS("-MD  -O1         -DNDEBUG"       MinSizeRel     CACHE)
66
67# Enable non standard floating point optimisations
68# Note: It hasn't been checked yet whether we have code that might break
69#ADD_COMPILER_FLAGS("-fp:fast" CACHE)
70
71# No iterator checking for release builds (MSVC 8 dosn't understand this though)
72ADD_COMPILER_FLAGS("-D_SECURE_SCL=0" ReleaseAll CACHE)
73
74# Newer MSVC versions come with std::shared_ptr which conflicts with
75# boost::shared_ptr in cpptcl. And since we don't yet use the new C++ standard
76# anyway, disable it completely.
77ADD_COMPILER_FLAGS("-D_HAS_CPP0X=0" CACHE)
78
79# Use Link time code generation for Release config if ORXONOX_RELEASE is defined
80IF(ORXONOX_RELEASE)
81  ADD_COMPILER_FLAGS("-GL" ReleaseAll CACHE)
82ENDIF()
83
84
85####################### Warnings ########################
86
87# Increase warning level if requested
88IF(EXTRA_COMPILER_WARNINGS)
89  REMOVE_COMPILER_FLAGS("-W1 -W2 -W3" CACHE)
90  ADD_COMPILER_FLAGS   ("-W4" CACHE)
91ELSE()
92  REMOVE_COMPILER_FLAGS("-W1 -W2 -W4" CACHE)
93  ADD_COMPILER_FLAGS   ("-W3" CACHE)
94ENDIF()
95
96# "<type> needs to have dll-interface to be used by clients'
97# Happens on STL member variables which are not public
98ADD_COMPILER_FLAGS("-w44251" CACHE)
99ADD_COMPILER_FLAGS("-w44275" CACHE) # For inheritance
100
101# Multiple assignment operators specified
102ADD_COMPILER_FLAGS("-w44522" CACHE)
103
104# Forcing values to bool
105ADD_COMPILER_FLAGS("-w44800" CACHE)
106
107# TODO: Resolve the cause of this warning!
108# ('class1' : inherits 'class2::member' via dominance)
109ADD_COMPILER_FLAGS("-w44250" CACHE)
110
111# This warns about truncation to 255 characters in debug/browse info
112# ADD_COMPILER_FLAGS("-w44786 -w44503" CACHE)
113
114# conversion from 'double' to 'float', possible loss of data
115# conversion from 'ogg_int64_t' to 'long', possible loss of data
116# ADD_COMPILER_FLAGS("-w44244" CACHE)
117
118# "conversion from 'size_t' to 'unsigned int', possible loss of data
119# ADD_COMPILER_FLAGS("-w44267" CACHE)
120
121# "truncation from 'double' to 'float'
122# ADD_COMPILER_FLAGS("-w44305" CACHE)
123
124# "non dll-interface class used as base for dll-interface class"
125# ADD_COMPILER_FLAGS("-w44275" CACHE)
126
127# "C++ Exception Specification ignored"
128# This is because MSVC 6 did not implement all the C++ exception
129# specifications in the ANSI C++ draft.
130# ADD_COMPILER_FLAGS("-w44290" CACHE)
131
132# "no suitable definition provided for explicit template
133# instantiation request" Occurs in VC7 for no justifiable reason.
134# ADD_COMPILER_FLAGS("-w44661" CACHE)
135
136# Deprecation warnings when using CRT calls in VC8
137# These show up on all C runtime lib code in VC8, disable since they clutter
138# the warnings with things we may not be able to do anything about (e.g.
139# generated code from nvparse etc). I doubt very much that these calls
140# will ever be actually removed from VC anyway, it would break too much code.
141# Note: Probably handled by "-DCRT_SECURE_NO_WARNINGS"
142# ADD_COMPILER_FLAGS("-w44996" CACHE)
143
144# "conditional expression constant"
145# ADD_COMPILER_FLAGS("-w4201" CACHE)
146
147
148##################### Linker Flags ######################
149
150# CMake default flags: -MANIFEST -STACK:10000000 -machine:I386
151# and INCREMENTAL and DEBUG for debug versions
152SET_LINKER_FLAGS("-debug -INCREMENTAL:YES" Debug              CACHE)
153SET_LINKER_FLAGS("-debug"                  RelWithDebInfo     CACHE)
154SET_LINKER_FLAGS(""                        Release MinSizeRel CACHE)
155
156ADD_LINKER_FLAGS("-OPT:NOWIN98" MSVC80 CACHE)
157
158# Use Link time code generation for Release config if ORXONOX_RELEASE is defined
159IF(ORXONOX_RELEASE)
160  ADD_LINKER_FLAGS("-INCREMENTAL:NO -OPT:ICF -OPT:REF -LTCG" ReleaseAll   CACHE)
161  # Static linker flags have to be added manually to a target
162  SET(ORXONOX_STATIC_LINKER_FLAGS "/LTCG")
163ELSE()
164  ADD_LINKER_FLAGS("-INCREMENTAL:YES"                  RelWithDebInfo     CACHE)
165  ADD_LINKER_FLAGS("-INCREMENTAL:NO -OPT:ICF -OPT:REF" Release MinSizeRel CACHE)
166ENDIF()
Note: See TracBrowser for help on using the repository browser.