[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 | # Orxonox only supports MSVC 8 and above, which gets asserted above |
---|
| 39 | SET(PCH_COMPILER_SUPPORT TRUE) |
---|
| 40 | |
---|
| 41 | |
---|
[2621] | 42 | #################### Compiler Flags ##################### |
---|
[2582] | 43 | |
---|
[2621] | 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 |
---|
[2582] | 52 | |
---|
[7247] | 53 | # Only add (not set) some general compiler flags. |
---|
[2621] | 54 | # CMake default flags : -DWIN32 -D_WINDOWS -W3 -Zm1000 |
---|
| 55 | # additionally for CXX: -EHsc -GR |
---|
[7247] | 56 | # -MP is for multiprocessed compiling |
---|
| 57 | ADD_COMPILER_FLAGS("-D__WIN32__ -D_WIN32 -MP" CACHE) |
---|
[2621] | 58 | ADD_COMPILER_FLAGS("-D_CRT_SECURE_NO_WARNINGS" CACHE) |
---|
[7163] | 59 | ADD_COMPILER_FLAGS("-D_SCL_SECURE_NO_WARNINGS" CACHE) |
---|
[2582] | 60 | |
---|
[7247] | 61 | # Overwrite CMake default flags here for the individual configurations |
---|
| 62 | SET_COMPILER_FLAGS("-MDd -Od -Zi -D_DEBUG -RTC1" Debug CACHE) |
---|
| 63 | SET_COMPILER_FLAGS("-MD -O2 -DNDEBUG" Release CACHE) |
---|
| 64 | SET_COMPILER_FLAGS("-MD -O2 -Zi -DNDEBUG" RelWithDebInfo CACHE) |
---|
| 65 | SET_COMPILER_FLAGS("-MD -O1 -DNDEBUG" MinSizeRel CACHE) |
---|
| 66 | ADD_COMPILER_FLAGS("-D_SECURE_SCL=0" MSVC9 ReleaseAll CACHE) |
---|
[2639] | 67 | |
---|
[5691] | 68 | # Use Link time code generation for Release config if ORXONOX_RELEASE is defined |
---|
| 69 | IF(ORXONOX_RELEASE) |
---|
| 70 | ADD_COMPILER_FLAGS("-GL" ReleaseAll CACHE) |
---|
| 71 | ENDIF() |
---|
[2639] | 72 | |
---|
[2668] | 73 | |
---|
[2639] | 74 | ####################### Warnings ######################## |
---|
| 75 | |
---|
[2621] | 76 | # Increase warning level if requested |
---|
[2673] | 77 | IF(EXTRA_COMPILER_WARNINGS) |
---|
[2621] | 78 | REMOVE_COMPILER_FLAGS("-W1 -W2 -W3" CACHE) |
---|
| 79 | ADD_COMPILER_FLAGS ("-W4" CACHE) |
---|
[2624] | 80 | ELSE() |
---|
[2621] | 81 | REMOVE_COMPILER_FLAGS("-W1 -W2 -W4" CACHE) |
---|
| 82 | ADD_COMPILER_FLAGS ("-W3" CACHE) |
---|
[2624] | 83 | ENDIF() |
---|
[2583] | 84 | |
---|
[2639] | 85 | # "<type> needs to have dll-interface to be used by clients' |
---|
| 86 | # Happens on STL member variables which are not public |
---|
| 87 | ADD_COMPILER_FLAGS("-w44251" CACHE) |
---|
[3196] | 88 | ADD_COMPILER_FLAGS("-w44275" CACHE) # For inheritance |
---|
[2588] | 89 | |
---|
[2639] | 90 | # Multiple assignment operators specified |
---|
| 91 | ADD_COMPILER_FLAGS("-w44522" CACHE) |
---|
[2626] | 92 | |
---|
[2639] | 93 | # Forcing values to bool |
---|
| 94 | ADD_COMPILER_FLAGS("-w44800" CACHE) |
---|
| 95 | |
---|
[7379] | 96 | # TODO: Resolve the cause of this warning! |
---|
| 97 | ADD_COMPILER_FLAGS("-w44250" CACHE) |
---|
| 98 | |
---|
[2639] | 99 | # This warns about truncation to 255 characters in debug/browse info |
---|
| 100 | # ADD_COMPILER_FLAGS("-w44786 -w44503" CACHE) |
---|
| 101 | |
---|
| 102 | # conversion from 'double' to 'float', possible loss of data |
---|
| 103 | # conversion from 'ogg_int64_t' to 'long', possible loss of data |
---|
| 104 | # ADD_COMPILER_FLAGS("-w44244" CACHE) |
---|
| 105 | |
---|
| 106 | # "conversion from 'size_t' to 'unsigned int', possible loss of data |
---|
| 107 | # ADD_COMPILER_FLAGS("-w44267" CACHE) |
---|
| 108 | |
---|
| 109 | # "truncation from 'double' to 'float' |
---|
| 110 | # ADD_COMPILER_FLAGS("-w44305" CACHE) |
---|
| 111 | |
---|
| 112 | # "non dll-interface class used as base for dll-interface class" |
---|
| 113 | # ADD_COMPILER_FLAGS("-w44275" CACHE) |
---|
| 114 | |
---|
| 115 | # "C++ Exception Specification ignored" |
---|
| 116 | # This is because MSVC 6 did not implement all the C++ exception |
---|
| 117 | # specifications in the ANSI C++ draft. |
---|
| 118 | # ADD_COMPILER_FLAGS("-w44290" CACHE) |
---|
| 119 | |
---|
| 120 | # "no suitable definition provided for explicit template |
---|
| 121 | # instantiation request" Occurs in VC7 for no justifiable reason. |
---|
| 122 | # ADD_COMPILER_FLAGS("-w44661" CACHE) |
---|
| 123 | |
---|
| 124 | # Deprecation warnings when using CRT calls in VC8 |
---|
| 125 | # These show up on all C runtime lib code in VC8, disable since they clutter |
---|
| 126 | # the warnings with things we may not be able to do anything about (e.g. |
---|
| 127 | # generated code from nvparse etc). I doubt very much that these calls |
---|
| 128 | # will ever be actually removed from VC anyway, it would break too much code. |
---|
| 129 | # Note: Probably handled by "-DCRT_SECURE_NO_WARNINGS" |
---|
| 130 | # ADD_COMPILER_FLAGS("-w44996" CACHE) |
---|
| 131 | |
---|
| 132 | # "conditional expression constant" |
---|
| 133 | # ADD_COMPILER_FLAGS("-w4201" CACHE) |
---|
| 134 | |
---|
| 135 | |
---|
[2621] | 136 | ##################### Linker Flags ###################### |
---|
[2588] | 137 | |
---|
[2621] | 138 | # CMake default flags: -MANIFEST -STACK:10000000 -machine:I386 |
---|
| 139 | # and INCREMENTAL and DEBUG for debug versions |
---|
[7439] | 140 | SET_LINKER_FLAGS("-debug -INCREMENTAL:YES" Debug CACHE) |
---|
| 141 | SET_LINKER_FLAGS("-debug" RelWithDebInfo CACHE) |
---|
| 142 | SET_LINKER_FLAGS("" Release MinSizeRel CACHE) |
---|
| 143 | |
---|
[2643] | 144 | ADD_LINKER_FLAGS("-OPT:NOWIN98" MSVC80 CACHE) |
---|
[5691] | 145 | |
---|
| 146 | # Use Link time code generation for Release config if ORXONOX_RELEASE is defined |
---|
| 147 | IF(ORXONOX_RELEASE) |
---|
[7439] | 148 | ADD_LINKER_FLAGS("-INCREMENTAL:NO -OPT:ICF -OPT:REF -LTCG" ReleaseAll CACHE) |
---|
[7807] | 149 | # Static linker flags have to be added manually to a target |
---|
| 150 | SET(ORXONOX_STATIC_LINKER_FLAGS "/LTCG") |
---|
[7439] | 151 | ELSE() |
---|
| 152 | ADD_LINKER_FLAGS("-INCREMENTAL:YES" RelWithDebInfo CACHE) |
---|
| 153 | ADD_LINKER_FLAGS("-INCREMENTAL:NO -OPT:ICF -OPT:REF" Release MinSizeRel CACHE) |
---|
[5691] | 154 | ENDIF() |
---|