Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3117


Ignore:
Timestamp:
Jun 3, 2009, 8:40:17 PM (15 years ago)
Author:
rgrieder
Message:

Adding experimental precompiled header file support. It seems to work quite well with MSVC, but has a performance penalty when used with GCC

Location:
code/branches/pch
Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/pch/cmake/BuildConfigGCC.cmake

    r3116 r3117  
    4343ENDIF()
    4444
     45# GCC only supports PCH in versions 3.4 and above
     46INCLUDE(CompareVersionStrings)
     47COMPARE_VERSION_STRINGS("${GCC_VERSION}" "3.4.0" _compare_result)
     48IF(_compare_result GREATER -1)
     49  SET(PCH_COMPILER_SUPPORT TRUE)
     50ENDIF()
     51
    4552# Also include environment flags. Could cause conflicts though
    4653SET_COMPILER_FLAGS("$ENV{CXXFLAGS}" CXX CACHE)
  • code/branches/pch/cmake/BuildConfigMSVC.cmake

    r3116 r3117  
    3737  OPTION(VISUAL_LEAK_DETECTOR_ENABLE "Memory leak detector" FALSE)
    3838ENDIF(MSVC80)
     39
     40# Orxonox only supports MSVC 8 and above, which gets asserted above
     41SET(PCH_COMPILER_SUPPORT TRUE)
     42
    3943
    4044#################### Compiler Flags #####################
  • code/branches/pch/cmake/TargetUtilities.cmake

    r3116 r3117  
    3434 #      STATIC/SHARED:     Inherited from ADD_LIBRARY
    3535 #      WIN32:             Inherited from ADD_EXECUTABLE
     36 #      PCH_NO_DEFAULT:    Do not make precompiled header files default if
     37 #                         specified with PCH_FILE
    3638 #    Lists:
    3739 #      LINK_LIBRARIES:    Redirects to TARGET_LINK_LIBRARIES
     
    4042 #      DEFINE_SYMBOL:     Sets the DEFINE_SYMBOL target property
    4143 #      TOLUA_FILES:       Files with tolua interface
     44 #      PCH_FILE:          Precompiled header file
     45 #      PCH_EXCLUDE:       Source files to be excluded from PCH support
    4246 #  Note:
    4347 #    This function also installs the target!
     
    5256INCLUDE(ParseMacroArguments)
    5357INCLUDE(SourceFileUtilities)
     58IF(PCH_COMPILER_SUPPORT)
     59  INCLUDE(PrecompiledHeaderFiles)
     60ENDIF()
    5461
    5562FUNCTION(ORXONOX_ADD_LIBRARY _target_name)
     
    6774  # Specify all possible options (either switch or with add. arguments)
    6875  SET(_switches   FIND_HEADER_FILES  EXCLUDE_FROM_ALL  ORXONOX_EXTERNAL
    69                   NO_DLL_INTERFACE   NO_SOURCE_GROUPS  ${_additional_switches})
     76                  NO_DLL_INTERFACE   NO_SOURCE_GROUPS  ${_additional_switches}
     77                  PCH_NO_DEFAULT)
    7078  SET(_list_names LINK_LIBRARIES  VERSION   SOURCE_FILES  DEFINE_SYMBOL
    71                   TOLUA_FILES)
     79                  TOLUA_FILES     PCH_FILE  PCH_EXCLUDE)
    7280  PARSE_MACRO_ARGUMENTS("${_switches}" "${_list_names}" ${ARGN})
    7381
     
    101109    GENERATE_TOLUA_BINDINGS(${_target_name_capitalised} _${_target_name}_files
    102110                            INPUTFILES ${_arg_TOLUA_FILES})
     111  ENDIF()
     112
     113  # First part (pre target) of precompiled header files
     114  IF(PCH_COMPILER_SUPPORT AND _arg_PCH_FILE)
     115    # Provide convenient option to control PCH
     116    STRING(TOUPPER "${_target_name}" _target_name_upper)
     117    IF(_arg_PCH_NO_DEFAULT)
     118      SET(PCH_DEFAULT FALSE)
     119    ELSE()
     120      SET(PCH_DEFAULT TRUE)
     121    ENDIF()
     122    OPTION(PCH_ENABLE_${_target_name_upper} "Enable using precompiled header files for library ${_target_name}." ${PCH_DEFAULT})
     123
     124    IF(PCH_ENABLE_${_target_name_upper})
     125      PRECOMPILED_HEADER_FILES_PRE_TARGET(${_target_name} ${_arg_PCH_FILE} _${_target_name}_files EXCLUDE ${_arg_PCH_EXCLUDE})
     126    ENDIF()
    103127  ENDIF()
    104128
     
    144168  ENDIF()
    145169
     170  # Second part of precompiled header files
     171  IF(PCH_COMPILER_SUPPORT AND PCH_ENABLE_${_target_name_upper} AND _arg_PCH_FILE)
     172    PRECOMPILED_HEADER_FILES_POST_TARGET(${_target_name} ${_arg_PCH_FILE})
     173  ENDIF()
     174
    146175  IF(NOT _arg_STATIC)
    147176    INSTALL(TARGETS ${_target_name}
  • code/branches/pch/src/orxonox/CMakeLists.txt

    r3116 r3117  
    4141    objects/quest/QuestDescription.h
    4242    objects/quest/QuestManager.h
     43  PCH_FILE
     44    OrxonoxPrecompiledHeaders.h
     45  PCH_NO_DEFAULT
    4346  LINK_LIBRARIES
    4447    ${OGRE_LIBRARY}
Note: See TracChangeset for help on using the changeset viewer.