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