| 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 |  | 
|---|
| 26 | ######################## Options ######################## | 
|---|
| 27 |  | 
|---|
| 28 | OPTION(VISUAL_LEAK_DETECTOR_ENABLE "Memory leak detector" FALSE) | 
|---|
| 29 |  | 
|---|
| 30 | #################### Compiler Flags ##################### | 
|---|
| 31 |  | 
|---|
| 32 | # -MD    Minimal Rebuild | 
|---|
| 33 | # -RTC1  Both basic runtime checks | 
|---|
| 34 | # -MD[d] Multithreaded [debug] DLL | 
|---|
| 35 | # -Zi    Program Database | 
|---|
| 36 | # -ZI    Program Database for Edit & Continue | 
|---|
| 37 | # -WX    General warning Level X | 
|---|
| 38 | # -wdX   Disable specific warning X | 
|---|
| 39 | # -wnX   Set warning level of specific warning X to level n | 
|---|
| 40 |  | 
|---|
| 41 | # Overwrite CMake default flags first. Be careful with this | 
|---|
| 42 | # Only add (not set) the general compiler flags. | 
|---|
| 43 | # CMake default flags : -DWIN32 -D_WINDOWS -W3 -Zm1000 | 
|---|
| 44 | # additionally for CXX: -EHsc -GR | 
|---|
| 45 | ADD_COMPILER_FLAGS("-D__WIN32__ -D_WIN32"      CACHE) | 
|---|
| 46 | ADD_COMPILER_FLAGS("-D_CRT_SECURE_NO_WARNINGS" CACHE) | 
|---|
| 47 |  | 
|---|
| 48 | # Overwrite CMake default flags here. | 
|---|
| 49 | SET_COMPILER_FLAGS("-MDd -Od -ZI -D_DEBUG -Gm -RTC1" Debug          CACHE) | 
|---|
| 50 | SET_COMPILER_FLAGS("-MD  -O2     -DNDEBUG -MP2"      Release        CACHE) | 
|---|
| 51 | SET_COMPILER_FLAGS("-MD  -O2 -Zi -DNDEBUG -MP2"      RelWithDebInfo CACHE) | 
|---|
| 52 | SET_COMPILER_FLAGS("-MD  -O1     -DNDEBUG -MP2"      MinSizeRel     CACHE) | 
|---|
| 53 |  | 
|---|
| 54 | # Microsoft unfortunately couldn't integrate a fix issued while VS 2008 beta 2 | 
|---|
| 55 | # was being tested into the final release even though a fix existed... | 
|---|
| 56 | # And it's actually quite a big issue, you simple can't compile anything. | 
|---|
| 57 | # Fortunately for us, disabling Minimal Rebuild solves the problem. | 
|---|
| 58 | REMOVE_COMPILER_FLAGS("-Gm" Debug MSVC09 CACHE) | 
|---|
| 59 | # And since we have to remove /Gm, let's add /MP2 to speed things up | 
|---|
| 60 | ADD_COMPILER_FLAGS("-MP2" Debug MSVC09 CACHE) | 
|---|
| 61 |  | 
|---|
| 62 |  | 
|---|
| 63 | ####################### Warnings ######################## | 
|---|
| 64 |  | 
|---|
| 65 | # Increase warning level if requested | 
|---|
| 66 | IF(EXTRA_COMPILER_WARNINGS) | 
|---|
| 67 | REMOVE_COMPILER_FLAGS("-W1 -W2 -W3" CACHE) | 
|---|
| 68 | ADD_COMPILER_FLAGS   ("-W4" CACHE) | 
|---|
| 69 | ELSE() | 
|---|
| 70 | REMOVE_COMPILER_FLAGS("-W1 -W2 -W4" CACHE) | 
|---|
| 71 | ADD_COMPILER_FLAGS   ("-W3" CACHE) | 
|---|
| 72 | ENDIF() | 
|---|
| 73 |  | 
|---|
| 74 | # "<type> needs to have dll-interface to be used by clients' | 
|---|
| 75 | # Happens on STL member variables which are not public | 
|---|
| 76 | ADD_COMPILER_FLAGS("-w44251" CACHE) | 
|---|
| 77 |  | 
|---|
| 78 | # Multiple assignment operators specified | 
|---|
| 79 | ADD_COMPILER_FLAGS("-w44522" CACHE) | 
|---|
| 80 |  | 
|---|
| 81 | # Forcing values to bool | 
|---|
| 82 | ADD_COMPILER_FLAGS("-w44800" CACHE) | 
|---|
| 83 |  | 
|---|
| 84 | # This warns about truncation to 255 characters in debug/browse info | 
|---|
| 85 | # ADD_COMPILER_FLAGS("-w44786 -w44503" CACHE) | 
|---|
| 86 |  | 
|---|
| 87 | # conversion from 'double' to 'float', possible loss of data | 
|---|
| 88 | # conversion from 'ogg_int64_t' to 'long', possible loss of data | 
|---|
| 89 | # ADD_COMPILER_FLAGS("-w44244" CACHE) | 
|---|
| 90 |  | 
|---|
| 91 | # "conversion from 'size_t' to 'unsigned int', possible loss of data | 
|---|
| 92 | # ADD_COMPILER_FLAGS("-w44267" CACHE) | 
|---|
| 93 |  | 
|---|
| 94 | # "truncation from 'double' to 'float' | 
|---|
| 95 | # ADD_COMPILER_FLAGS("-w44305" CACHE) | 
|---|
| 96 |  | 
|---|
| 97 | # "non dll-interface class used as base for dll-interface class" | 
|---|
| 98 | # ADD_COMPILER_FLAGS("-w44275" CACHE) | 
|---|
| 99 |  | 
|---|
| 100 | # "C++ Exception Specification ignored" | 
|---|
| 101 | # This is because MSVC 6 did not implement all the C++ exception | 
|---|
| 102 | # specifications in the ANSI C++ draft. | 
|---|
| 103 | # ADD_COMPILER_FLAGS("-w44290" CACHE) | 
|---|
| 104 |  | 
|---|
| 105 | # "no suitable definition provided for explicit template | 
|---|
| 106 | # instantiation request" Occurs in VC7 for no justifiable reason. | 
|---|
| 107 | # ADD_COMPILER_FLAGS("-w44661" CACHE) | 
|---|
| 108 |  | 
|---|
| 109 | # Deprecation warnings when using CRT calls in VC8 | 
|---|
| 110 | # These show up on all C runtime lib code in VC8, disable since they clutter | 
|---|
| 111 | # the warnings with things we may not be able to do anything about (e.g. | 
|---|
| 112 | # generated code from nvparse etc). I doubt very much that these calls | 
|---|
| 113 | # will ever be actually removed from VC anyway, it would break too much code. | 
|---|
| 114 | # Note: Probably handled by "-DCRT_SECURE_NO_WARNINGS" | 
|---|
| 115 | # ADD_COMPILER_FLAGS("-w44996" CACHE) | 
|---|
| 116 |  | 
|---|
| 117 | # "conditional expression constant" | 
|---|
| 118 | # ADD_COMPILER_FLAGS("-w4201" CACHE) | 
|---|
| 119 |  | 
|---|
| 120 |  | 
|---|
| 121 | ##################### Linker Flags ###################### | 
|---|
| 122 |  | 
|---|
| 123 | # CMake default flags: -MANIFEST -STACK:10000000 -machine:I386 | 
|---|
| 124 | # and INCREMENTAL and DEBUG for debug versions | 
|---|
| 125 | ADD_LINKER_FLAGS("-OPT:REF -OPT:ICF" Release MinSizeRel CACHE) | 
|---|
| 126 | ADD_LINKER_FLAGS("-OPT:NOWIN98" MSVC80 CACHE) | 
|---|