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