Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8362


Ignore:
Timestamp:
Apr 30, 2011, 4:02:27 AM (14 years ago)
Author:
rgrieder
Message:

Cleaned up linker and compiler flag configuration for Visual Studio.
ORXONOX_RELEASE is not respected anymore (see next commit).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/cmake/CompilerConfigMSVC.cmake

    r8351 r8362  
    2626INCLUDE(FlagUtilities)
    2727
    28 ################### Compiler Version ####################
    29 
    3028# We make use of variadic macros, which is only supported by MSVC 8 and above
    3129IF(MSVC_VERSION LESS 1400)
    32   MESSAGE(FATAL_ERROR "Microsoft Visual Studio versions below 8 (2005) are not supported because of missing compiler extensions.")
     30  MESSAGE(FATAL_ERROR "Microsoft Visual Studio versions below 8 (2005) are not supported.")
    3331ENDIF()
    34 
    35 
    36 ######################## Options ########################
    3732
    3833# Orxonox only supports MSVC 8 and above, which gets asserted above
     
    4237#################### Compiler Flags #####################
    4338
    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
     39# CMake default flags : -DWIN32 -D_WINDOWS -W3 -Zm1000
     40# additionally for CXX: -EHsc -GR
     41# We keep these flags but reset the build specific flags
     42SET_COMPILER_FLAGS("" Debug RelWithDebInfo Release MinSizeRel CACHE)
     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
     47ADD_COMPILER_FLAGS("-D_CRT_SECURE_NO_WARNINGS" CACHE)
     48ADD_COMPILER_FLAGS("-D_SCL_SECURE_NO_WARNINGS" CACHE)
     49
     50# Use multiprocessed compiling (like "make -j3" on Unix)
     51ADD_COMPILER_FLAGS("-MP" CACHE)
     52
     53# Always generate debug symbols (there is really no reason not to)
     54ADD_COMPILER_FLAGS("-Zi" CACHE)
     55
     56# Never omit frame pointers to avoid useless stack traces (the performance
     57# loss is almost not measurable)
     58ADD_COMPILER_FLAGS("-Oy-" CACHE)
     59# Enable non standard floating point optimisations
     60ADD_COMPILER_FLAGS("-fp:fast" CACHE)
     61
     62# Set build specific flags.
     63# -MD[d]    Multithreaded [debug] shared MSVC runtime library
     64# -O[d|2|1] No optimisations, optimise for speed, optimise for size
     65# -Oi[-]    Use or disable use of intrinisic functions
     66# -GL       Link time code generation (see -LTCG in linker flags)
     67# -RTC1     Both basic runtime checks
     68ADD_COMPILER_FLAGS("-MDd -Od -Oi  -D_DEBUG -RTC1" Debug          CACHE)
     69ADD_COMPILER_FLAGS("-MD  -O2 -Oi  -DNDEBUG"       RelWithDebInfo CACHE)
     70ADD_COMPILER_FLAGS("-MD  -O2 -Oi  -DNDEBUG -GL"   Release        CACHE)
     71ADD_COMPILER_FLAGS("-MD  -O1 -Oi- -DNDEBUG -GL"   MinSizeRel     CACHE)
     72
     73
     74####################### Warnings ########################
     75
    4976# -WX    General warning Level X
    5077# -wdX   Disable specific warning X
    5178# -wnX   Set warning level of specific warning X to level n
    52 
    53 # Only add (not set) some general compiler flags.
    54 # CMake default flags : -DWIN32 -D_WINDOWS -W3 -Zm1000
    55 # additionally for CXX: -EHsc -GR
    56 # -MP is for multiprocessed compiling
    57 ADD_COMPILER_FLAGS("-D__WIN32__ -D_WIN32 -MP"  CACHE)
    58 ADD_COMPILER_FLAGS("-D_CRT_SECURE_NO_WARNINGS" CACHE)
    59 ADD_COMPILER_FLAGS("-D_SCL_SECURE_NO_WARNINGS" CACHE)
    60 
    61 # Overwrite CMake default flags here for the individual configurations
    62 SET_COMPILER_FLAGS("-MDd -Od -Oi -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 
    67 # Enable non standard floating point optimisations
    68 ADD_COMPILER_FLAGS("-fp:fast" CACHE)
    69 
    70 # Use Link time code generation for Release config if ORXONOX_RELEASE is defined
    71 IF(ORXONOX_RELEASE)
    72   ADD_COMPILER_FLAGS("-GL" ReleaseAll CACHE)
    73 ENDIF()
    74 
    75 
    76 ####################### Warnings ########################
    7779
    7880# Increase warning level if requested
     
    100102ADD_COMPILER_FLAGS("-w44250" CACHE)
    101103
    102 # This warns about truncation to 255 characters in debug/browse info
    103 # ADD_COMPILER_FLAGS("-w44786 -w44503" CACHE)
    104 
    105104# conversion from 'double' to 'float', possible loss of data
    106105# conversion from 'ogg_int64_t' to 'long', possible loss of data
     
    116115# ADD_COMPILER_FLAGS("-w44275" CACHE)
    117116
    118 # "C++ Exception Specification ignored"
    119 # This is because MSVC 6 did not implement all the C++ exception
    120 # specifications in the ANSI C++ draft.
    121 # ADD_COMPILER_FLAGS("-w44290" CACHE)
    122 
    123 # "no suitable definition provided for explicit template
    124 # instantiation request" Occurs in VC7 for no justifiable reason.
    125 # ADD_COMPILER_FLAGS("-w44661" CACHE)
    126 
    127 # Deprecation warnings when using CRT calls in VC8
    128 # These show up on all C runtime lib code in VC8, disable since they clutter
    129 # the warnings with things we may not be able to do anything about (e.g.
    130 # generated code from nvparse etc). I doubt very much that these calls
    131 # will ever be actually removed from VC anyway, it would break too much code.
    132 # Note: Probably handled by "-DCRT_SECURE_NO_WARNINGS"
    133 # ADD_COMPILER_FLAGS("-w44996" CACHE)
    134 
    135 # "conditional expression constant"
    136 # ADD_COMPILER_FLAGS("-w4201" CACHE)
    137 
    138117
    139118##################### Linker Flags ######################
    140119
    141120# CMake default flags: -MANIFEST -STACK:10000000 -machine:I386
    142 # and INCREMENTAL and DEBUG for debug versions
    143 SET_LINKER_FLAGS("-debug -INCREMENTAL:YES" Debug              CACHE)
    144 SET_LINKER_FLAGS("-debug"                  RelWithDebInfo     CACHE)
    145 SET_LINKER_FLAGS(""                        Release MinSizeRel CACHE)
     121# We keep these flags but reset the build specific flags
     122SET_LINKER_FLAGS("" Debug RelWithDebInfo Release MinSizeRel CACHE)
    146123
     124# Always generate debug symbols (there is really no reason not to)
     125ADD_LINKER_FLAGS("-DEBUG" CACHE)
     126
     127# Never fold multiple functions into a single one because we might compare
     128# function pointers (for instance with network functions)
     129ADD_LINKER_FLAGS("-OPT:NOICF" CACHE)
     130
     131# Very old flag that would do some extra Windows 98 alignment optimisations
    147132ADD_LINKER_FLAGS("-OPT:NOWIN98" MSVC80 CACHE)
    148133
    149 # Use Link time code generation for Release config if ORXONOX_RELEASE is defined
    150 IF(ORXONOX_RELEASE)
    151   ADD_LINKER_FLAGS("-INCREMENTAL:NO -OPT:ICF -OPT:REF -LTCG" ReleaseAll   CACHE)
    152   # Static linker flags have to be added manually to a target
    153   SET(ORXONOX_STATIC_LINKER_FLAGS "/LTCG")
    154 ELSE()
    155   ADD_LINKER_FLAGS("-INCREMENTAL:YES"                  RelWithDebInfo     CACHE)
    156   ADD_LINKER_FLAGS("-INCREMENTAL:NO -OPT:ICF -OPT:REF" Release MinSizeRel CACHE)
    157 ENDIF()
     134# Incremental linking speeds up development builds
     135ADD_LINKER_FLAGS("-INCREMENTAL:YES" Debug   RelWithDebInfo CACHE)
     136ADD_LINKER_FLAGS("-INCREMENTAL:NO"  Release MinSizeRel     CACHE)
     137
     138# Eliminate unreferenced data
     139ADD_LINKER_FLAGS("-OPT:REF" Release MinSizeRel CACHE)
     140
     141# Link time code generation can improve run time performance at the cost of
     142# hugely increased link time (the total build time is about the same though)
     143ADD_LINKER_FLAGS("-LTCG" Release MinSizeRel CACHE)
Note: See TracChangeset for help on using the changeset viewer.