Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 8496 was 8368, checked in by rgrieder, 14 years ago

Added CMake configuration type "RelForDevs", which replaces "RelWithDebInfo". That latter is now equivalent to "Release", but with symbols.
Also, I removed debug symbol generation for Release and MinSizeRel when compiling with MSVC.

The new configuration should be used as standard Release mode when developing. The other three release configurations are for actual installed binaries (and behave again as the name suggests).

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