Ticket #1104: cmake.patch

File cmake.patch, 68.0 KB (added by historic_bruno, 11 years ago)

Old WIP patch from Philip

  • new file uild/cmake/CMakeModules/CompareVersionStrings.cmake

    # HG changeset patch
    # Parent 27195836057e09472d6c83f70b239951338b65a1
    
    diff -r 27195836057e build/cmake/CMakeModules/CompareVersionStrings.cmake
    - +  
     1# Computes the relationship between two version strings.  A version
     2# string is a number delineated by '.'s such as 1.3.2 and 0.99.9.1.
     3# You can feed version strings with different number of dot versions,
     4# and the shorter version number will be padded with zeros: 9.2 <
     5# 9.2.1 will actually compare 9.2.0 < 9.2.1.
     6#
     7# Input: a_in - value, not variable
     8#        b_in - value, not variable
     9#        result_out - variable with value:
     10#                         -1 : a_in <  b_in
     11#                          0 : a_in == b_in
     12#                          1 : a_in >  b_in
     13#        optional argument - TRUE or default FALSE:
     14#              When passing 1.2.3 and 1.2 and this switch is on
     15#              the function will actually compare 1.2 < 1.2
     16#              Caution: Only the first string is adjusted!
     17#
     18# Written by James Bigler.
     19# Extended with an optional argument by Reto Grieder
     20
     21FUNCTION(COMPARE_VERSION_STRINGS a_in b_in result_out)
     22  # Additional argument can be a switch to change compare behaviour
     23  SET(cut_first ${ARGN})
     24
     25  # Replace '.' with ';' to allow easy tokenization of the string.
     26  STRING(REPLACE "." ";" a ${a_in})
     27  STRING(REPLACE "." ";" b ${b_in})
     28
     29  # Check the size of each list to see if they are equal.
     30  LIST(LENGTH a a_length)
     31  LIST(LENGTH b b_length)
     32
     33  # Pad the shorter list with zeros.
     34
     35  IF(a_length LESS b_length)
     36    # a is shorter
     37    SET(shorter a)
     38    MATH(EXPR pad_range "${b_length} - ${a_length} - 1")
     39  ELSE(a_length LESS b_length)
     40    # b is shorter
     41    SET(shorter b)
     42    SET(first_longer a)
     43    MATH(EXPR pad_range "${a_length} - ${b_length} - 1")
     44  ENDIF(a_length LESS b_length)
     45
     46  # PAD out if we need to
     47  IF(NOT pad_range LESS 0)
     48    FOREACH(pad RANGE ${pad_range})
     49      # Since shorter is an alias for b, we need to get to it by dereferencing shorter.
     50      IF(cut_first AND first_longer)
     51        LIST(REMOVE_AT a -1) # remove last element
     52      ELSE(cut_first AND first_longer)
     53        LIST(APPEND ${shorter} 0)
     54      ENDIF(cut_first AND first_longer)
     55    ENDFOREACH(pad)
     56  ENDIF(NOT pad_range LESS 0)
     57
     58  SET(result 0)
     59  SET(index 0)
     60  FOREACH(a_version ${a})
     61    IF(result EQUAL 0)
     62      # Only continue to compare things as long as they are equal
     63      LIST(GET b ${index} b_version)
     64      # LESS
     65      IF(a_version LESS b_version)
     66        SET(result -1)
     67      ENDIF(a_version LESS b_version)
     68      # GREATER
     69      IF(a_version GREATER b_version)
     70        SET(result 1)
     71      ENDIF(a_version GREATER b_version)
     72    ENDIF(result EQUAL 0)
     73    MATH(EXPR index "${index} + 1")
     74  ENDFOREACH(a_version)
     75
     76  # Copy out the return result
     77  SET(${result_out} ${result} PARENT_SCOPE)
     78ENDFUNCTION(COMPARE_VERSION_STRINGS)
  • new file uild/cmake/CMakeModules/DetermineVersion.cmake

    diff -r 27195836057e build/cmake/CMakeModules/DetermineVersion.cmake
    - +  
     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 #    Inspects a given file for the following expressions
     24 #    "NAME_VERSION_MAJOR #"
     25 #    "NAME_VERSION_MINOR #"
     26 #    "NAME_VERSION_PATCH #"
     27 #    and sets NAME_VERSION accordingly. NAME_PART_VERSION variables are also
     28 #    set. If you wish to look for different parts (e.g. "first" "second", etc.)
     29 #    simply deliver them as additional arguments (have to be three though).
     30 #
     31
     32FUNCTION(DETERMINE_VERSION _name _file)
     33  IF(EXISTS ${_file})
     34    FILE(READ ${_file} _file_content)
     35    SET(_parts ${ARGN})
     36    LIST(LENGTH _parts _parts_length)
     37    IF(NOT ${_parts_length} EQUAL 3)
     38      SET(_parts MAJOR MINOR PATCH)
     39    ENDIF()
     40
     41    FOREACH(_part ${_parts})
     42      STRING(REGEX MATCH "${_name}_VERSION_${_part} +([0-9]+)" _match ${_file_content})
     43      IF(_match)
     44        SET(${_name}_VERSION_${_part} ${CMAKE_MATCH_1})
     45        SET(${_name}_VERSION_${_part} ${CMAKE_MATCH_1} PARENT_SCOPE)
     46      ELSE()
     47        SET(${_name}_VERSION_${_part} "0")
     48        SET(${_name}_VERSION_${_part} "0" PARENT_SCOPE)
     49      ENDIF()
     50      IF("${_parts}" MATCHES "^${_part}") # First?
     51        SET(${_name}_VERSION "${${_name}_VERSION_${_part}}")
     52      ELSE()
     53        SET(${_name}_VERSION "${${_name}_VERSION}.${${_name}_VERSION_${_part}}")
     54      ENDIF()
     55    ENDFOREACH(_part)
     56    SET(${_name}_VERSION "${${_name}_VERSION}" PARENT_SCOPE)
     57  ENDIF(EXISTS ${_file})
     58ENDFUNCTION(DETERMINE_VERSION)
  • new file uild/cmake/CMakeModules/FindENet.cmake

    diff -r 27195836057e build/cmake/CMakeModules/FindENet.cmake
    - +  
     1# - Try to find enet
     2# Once done this will define
     3#
     4#  ENET_FOUND - system has enet
     5#  ENet_INCLUDE_DIR - the enet include directory
     6#  ENet_LIBRARY - the library needed to link against enet
     7#
     8# $ENETDIR is an environment variable used for finding enet.
     9#
     10#  Borrowed from The Mana World
     11#  http://themanaworld.org/
     12#
     13# Several changes and additions by Fabian 'x3n' Landau
     14# Lots of simplifications by Adrian Friedli and Reto Grieder
     15# Version checking by Reto Grieder
     16#                 > www.orxonox.net <
     17
     18INCLUDE(FindPackageHandleAdvancedArgs)
     19INCLUDE(HandleLibraryTypes)
     20
     21FIND_PATH(ENET_INCLUDE_DIR enet/enet.h
     22  PATHS $ENV{ENETDIR}
     23  PATH_SUFFIXES include
     24)
     25FIND_LIBRARY(ENET_LIBRARY_OPTIMIZED
     26  NAMES enet
     27  PATHS $ENV{ENETDIR}
     28  PATH_SUFFIXES lib
     29)
     30FIND_LIBRARY(ENET_LIBRARY_DEBUG
     31  NAMES enetd enet_d enet_D
     32  PATHS $ENV{ENETDIR}
     33  PATH_SUFFIXES lib
     34)
     35
     36# Only works for 1.2.2 and higher, otherwise see below
     37DETERMINE_VERSION(ENET ${ENET_INCLUDE_DIR}/enet/enet.h)
     38IF(${ENET_VERSION} STREQUAL "0.0.0")
     39  # Try to determine the version. Note that enet only stores the major
     40  # version in the header file. So we check for existing functions.
     41  # Hence the this script only distinguishes between 1.0, 1.1 and 1.2
     42  FILE(STRINGS ${ENET_INCLUDE_DIR}/enet/enet.h _enet_header REGEX "ENET_")
     43  IF(_enet_header MATCHES "ENET_VERSION[ \t]*=[ \t]*1")
     44    IF(_enet_header MATCHES "enet_socket_set_option")
     45      SET(ENET_VERSION 1.2)
     46    ELSEIF(_enet_header MATCHES "enet_peer_disconnect_later")
     47      SET(ENET_VERSION 1.1)
     48    ELSE()
     49      SET(ENET_VERSION 1.0)
     50    ENDIF()
     51  ELSE()
     52    SET(ENET_VERSION 0) # Script doesn't support versions below 1.0
     53  ENDIF()
     54ENDIF()
     55
     56# Handle the REQUIRED argument and set ENET_FOUND
     57# Also check the the version requirements
     58FIND_PACKAGE_HANDLE_ADVANCED_ARGS(ENet DEFAULT_MSG ${ENET_VERSION}
     59  ENET_LIBRARY_OPTIMIZED
     60  ENET_INCLUDE_DIR
     61)
     62
     63COMPARE_VERSION_STRINGS(${ENET_VERSION} 1.2 _comparison TRUE)
     64IF(${_comparison} EQUAL 1)
     65  MESSAGE(STATUS "Warning: Using ENet version 1.3, which is not protocol compatible with 1.1 and 1.2.")
     66ENDIF()
     67
     68# Collect optimized and debug libraries
     69IF(NOT LINK_ENET_DYNAMIC AND WIN32)
     70  # ENet is linked statically, hence we need to add some windows dependencies
     71  HANDLE_LIBRARY_TYPES(ENET ws2_32 winmm)
     72ELSE()
     73  HANDLE_LIBRARY_TYPES(ENET)
     74ENDIF()
     75
     76MARK_AS_ADVANCED(
     77  ENET_INCLUDE_DIR
     78  ENET_LIBRARY_OPTIMIZED
     79  ENET_LIBRARY_DEBUG
     80)
  • new file uild/cmake/CMakeModules/FindENet1.cmake

    diff -r 27195836057e build/cmake/CMakeModules/FindENet1.cmake
    - +  
     1# - Try to find ENet
     2# Once done, this will define
     3#
     4#  ENet_FOUND - system has ENet
     5#  ENet_INCLUDE_DIRS - the ENet include directories
     6#  ENet_LIBRARIES - link these to use ENet
     7#
     8# Accepted Inputs:
     9#  Those defined in FindPackageHelper.cmake (use ENet for ${name})
     10
     11include(FindPackageHelper)
     12
     13set(ENet_INCLUDE_NAMES
     14  enet/enet.h
     15)
     16set(ENet_LIBRARY_NAMES
     17  enet
     18)
     19set(ENet_INCLUDE_PATH_SUFFIXES
     20  include
     21)
     22set(ENet_LIBRARY_PATH_SUFFIXES "")
     23
     24set(ENet_ONLY_STATIC TRUE) # Require static linking
     25
     26FindPackage(ENet)
  • new file uild/cmake/CMakeModules/FindFAM.cmake

    diff -r 27195836057e build/cmake/CMakeModules/FindFAM.cmake
    - +  
     1# - Try to find the FAM directory notification library
     2# Once done this will define
     3#
     4#  FAM_FOUND - system has FAM
     5#  FAM_INCLUDE_DIR - the FAM include directory
     6#  FAM_LIBRARIES - The libraries needed to use FAM
     7
     8# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
     9#
     10# Redistribution and use is allowed according to the terms of the BSD license.
     11# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
     12
     13
     14FIND_PATH(FAM_INCLUDE_DIR fam.h)
     15
     16FIND_LIBRARY(FAM_LIBRARIES NAMES fam )
     17
     18INCLUDE(FindPackageHandleStandardArgs)
     19FIND_PACKAGE_HANDLE_STANDARD_ARGS(FAM DEFAULT_MSG FAM_INCLUDE_DIR FAM_LIBRARIES )
     20
     21MARK_AS_ADVANCED(FAM_INCLUDE_DIR FAM_LIBRARIES)
     22
  • new file uild/cmake/CMakeModules/FindOgg.cmake

    diff -r 27195836057e build/cmake/CMakeModules/FindOgg.cmake
    - +  
     1# - Locate Ogg library
     2# This module defines
     3#  OGG_LIBRARY, the library to link against
     4#  OGG_FOUND, if false, do not try to link to OGG
     5#  OGG_INCLUDE_DIR, where to find headers.
     6
     7IF(OGG_LIBRARY AND OGG_INCLUDE_DIR)
     8  # in cache already
     9  SET(OGG_FIND_QUIETLY TRUE)
     10ENDIF(OGG_LIBRARY AND OGG_INCLUDE_DIR)
     11
     12
     13FIND_PATH(OGG_INCLUDE_DIR
     14  ogg/ogg.h
     15  PATHS
     16  $ENV{OGG_DIR}/include
     17  /usr/local/include
     18  /usr/include
     19  /sw/include
     20  /opt/local/include
     21  /opt/csw/include
     22  /opt/include
     23)
     24
     25FIND_LIBRARY(OGG_LIBRARY
     26  NAMES ogg libogg
     27  PATHS
     28  $ENV{OGG_DIR}/lib
     29  /usr/local/lib
     30  /usr/lib
     31  /usr/local/X11R6/lib
     32  /usr/X11R6/lib
     33  /sw/lib
     34  /opt/local/lib
     35  /opt/csw/lib
     36  /opt/lib
     37  /usr/freeware/lib64
     38)
     39
     40IF(OGG_LIBRARY AND OGG_INCLUDE_DIR)
     41  SET(OGG_FOUND "YES")
     42  IF(NOT OGG_FIND_QUIETLY)
     43    MESSAGE(STATUS "Found Ogg: ${OGG_LIBRARY}")
     44  ENDIF(NOT OGG_FIND_QUIETLY)
     45ELSE(OGG_LIBRARY AND OGG_INCLUDE_DIR)
     46  IF(NOT OGG_FIND_QUIETLY)
     47    MESSAGE(STATUS "Warning: Unable to find Ogg!")
     48  ENDIF(NOT OGG_FIND_QUIETLY)
     49ENDIF(OGG_LIBRARY AND OGG_INCLUDE_DIR)
  • new file uild/cmake/CMakeModules/FindPackageHandleAdvancedArgs.cmake

    diff -r 27195836057e build/cmake/CMakeModules/FindPackageHandleAdvancedArgs.cmake
    - +  
     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 #    Extension of the standard module "FindPackageHandleStandardArgs".
     24 #    This function also checks the version requirements. Also regards the
     25 #    EXACT keyword if specified in FIND_PACKAGE(...).
     26 #
     27
     28INCLUDE(FindPackageHandleStandardArgs)
     29INCLUDE(CompareVersionStrings)
     30
     31FUNCTION(FIND_PACKAGE_HANDLE_ADVANCED_ARGS _name _fail_msg _version)
     32
     33  # Modify the message to include version requirements
     34  IF("${_fail_msg}" STREQUAL "DEFAULT_MSG")
     35    SET(_fail_msg_adv "Could NOT find ${_name}")
     36  ELSE()
     37    SET(_fail_msg_adv "${_fail_msg}")
     38  ENDIF()
     39  IF(${_name}_FIND_VERSION_EXACT)
     40    SET(_fail_msg_adv "${_fail_msg_adv} (version requirements: exactly ${${_name}_FIND_VERSION})")
     41  ELSE()
     42    SET(_fail_msg_adv "${_fail_msg_adv} (version requirements: at least ${${_name}_FIND_VERSION})")
     43  ENDIF()
     44  FIND_PACKAGE_HANDLE_STANDARD_ARGS("${_name}" "${_fail_msg_adv}" ${ARGN})
     45  STRING(TOUPPER ${_name} _NAME_UPPER)
     46
     47  # Also check version requirements if given to FindPackage(...)
     48  IF(${_name}_FIND_VERSION)
     49    # Note: the last argument of the function tells it to cut the first
     50    #       version string instead of padding it with zeros if necessary
     51    COMPARE_VERSION_STRINGS("${_version}" "${${_name}_FIND_VERSION}" _compatible TRUE)
     52    IF(${_name}_FIND_VERSION_EXACT AND NOT _compatible EQUAL 0)
     53      MESSAGE(FATAL_ERROR "Exact ${_name} version required is ${${_name}_FIND_VERSION}\n"
     54                          "Your version is ${_version}")
     55      SET(${_NAME_UPPER}_FOUND FALSE)
     56    ELSEIF(_compatible LESS 0)
     57      MESSAGE(FATAL_ERROR "Minimum ${_name} version required is ${${_name}_FIND_VERSION}\n"
     58                          "Your version is ${_version}")
     59      SET(${_NAME_UPPER}_FOUND FALSE)
     60    ENDIF()
     61  ENDIF(${_name}_FIND_VERSION)
     62
     63  # Raise scope (FindPackageHandleStandardArgs uses PARENT_SCOPE)
     64  SET(${_NAME_UPPER}_FOUND ${${_NAME_UPPER}_FOUND} PARENT_SCOPE)
     65
     66ENDFUNCTION(FIND_PACKAGE_HANDLE_ADVANCED_ARGS)
  • new file uild/cmake/CMakeModules/FindVorbis.cmake

    diff -r 27195836057e build/cmake/CMakeModules/FindVorbis.cmake
    - +  
     1# - Locate Vorbis library
     2# This module defines
     3#  VORBIS_LIBRARY, the library to link against
     4#  VORBIS_FOUND, if false, do not try to link to VORBIS
     5#  VORBIS_INCLUDE_DIR, where to find headers.
     6
     7IF(VORBIS_LIBRARY AND VORBIS_INCLUDE_DIR)
     8  # in cache already
     9  SET(VORBIS_FIND_QUIETLY TRUE)
     10ENDIF(VORBIS_LIBRARY AND VORBIS_INCLUDE_DIR)
     11
     12
     13FIND_PATH(VORBIS_INCLUDE_DIR
     14  vorbis/vorbisfile.h
     15  PATHS
     16  $ENV{VORBIS_DIR}/include
     17  /usr/local/include
     18  /usr/include
     19  /sw/include
     20  /opt/local/include
     21  /opt/csw/include
     22  /opt/include
     23)
     24
     25FIND_LIBRARY(VORBIS_LIBRARY
     26  NAMES vorbis libvorbis
     27  PATHS
     28  $ENV{VORBIS_DIR}/lib
     29  /usr/local/lib
     30  /usr/lib
     31  /usr/local/X11R6/lib
     32  /usr/X11R6/lib
     33  /sw/lib
     34  /opt/local/lib
     35  /opt/csw/lib
     36  /opt/lib
     37  /usr/freeware/lib64
     38)
     39
     40FIND_LIBRARY(VORBISFILE_LIBRARY
     41  NAMES vorbisfile libvorbisfile
     42  PATHS
     43  $ENV{VORBIS_DIR}/lib
     44  /usr/local/lib
     45  /usr/lib
     46  /usr/local/X11R6/lib
     47  /usr/X11R6/lib
     48  /sw/lib
     49  /opt/local/lib
     50  /opt/csw/lib
     51  /opt/lib
     52  /usr/freeware/lib64
     53)
     54
     55IF(VORBIS_LIBRARY AND VORBISFILE_LIBRARY AND VORBIS_INCLUDE_DIR)
     56  SET(VORBIS_FOUND "YES")
     57  SET(VORBIS_LIBRARIES ${VORBIS_LIBRARY} ${VORBISFILE_LIBRARY})
     58  IF(NOT VORBIS_FIND_QUIETLY)
     59    MESSAGE(STATUS "Found Vorbis: ${VORBIS_LIBRARY}")
     60  ENDIF(NOT VORBIS_FIND_QUIETLY)
     61ELSE(VORBIS_LIBRARY AND VORBISFILE_LIBRARY AND VORBIS_INCLUDE_DIR)
     62  IF(NOT VORBIS_FIND_QUIETLY)
     63    MESSAGE(STATUS "Warning: Unable to find Vorbis!")
     64  ENDIF(NOT VORBIS_FIND_QUIETLY)
     65ENDIF(VORBIS_LIBRARY AND VORBISFILE_LIBRARY AND VORBIS_INCLUDE_DIR)
  • new file uild/cmake/CMakeModules/HandleLibraryTypes.cmake

    diff -r 27195836057e build/cmake/CMakeModules/HandleLibraryTypes.cmake
    - +  
     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 #    Checks debug and optimized libaries and sets the variable ${_name}_LIBRARY
     24 #    accordingly. If only an optimized library was found, the "optimized"
     25 #    keyword is omitted to support the debug version too.
     26 #
     27
     28FUNCTION(HANDLE_LIBRARY_TYPES _name)
     29  # Additional libraries can be added as additional arguments
     30  IF(${_name}_LIBRARY_DEBUG AND ${_name}_LIBRARY_OPTIMIZED)
     31    SET(${_name}_LIBRARY
     32      optimized ${${_name}_LIBRARY_OPTIMIZED} ${ARGN}
     33      debug     ${${_name}_LIBRARY_DEBUG}     ${ARGN}
     34      PARENT_SCOPE
     35    )
     36  ELSE()
     37    SET(${_name}_LIBRARY
     38      ${${_name}_LIBRARY_OPTIMIZED} ${ARGN}
     39      PARENT_SCOPE
     40     )
     41  ENDIF()
     42ENDFUNCTION(HANDLE_LIBRARY_TYPES)
  • new file uild/cmake/CMakeModules/PCHSupport.cmake

    diff -r 27195836057e build/cmake/CMakeModules/PCHSupport.cmake
    - +  
     1# - Try to find precompiled headers support for GCC 3.4 and 4.x (and MSVC)
     2# Once done this will define:
     3#
     4# Variable:
     5#   PCHSupport_FOUND
     6#
     7#   ADD_PRECOMPILED_HEADER  _targetName _inputh _inputcpp
     8#   ADD_PRECOMPILED_HEADER_TO_TARGET _targetName _input _pch_output_to_use
     9#   ADD_NATIVE_PRECOMPILED_HEADER _targetName _inputh _inputcpp
     10
     11IF(CMAKE_COMPILER_IS_GNUCXX)
     12
     13    EXEC_PROGRAM(
     14        ${CMAKE_CXX_COMPILER}
     15        ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
     16        OUTPUT_VARIABLE gcc_compiler_version)
     17
     18    IF(gcc_compiler_version MATCHES "4\\.[0-9]\\.[0-9]")
     19        SET(PCHSupport_FOUND TRUE)
     20    ELSE(gcc_compiler_version MATCHES "4\\.[0-9]\\.[0-9]")
     21        IF(gcc_compiler_version MATCHES "3\\.4\\.[0-9]")
     22            SET(PCHSupport_FOUND TRUE)
     23        ENDIF(gcc_compiler_version MATCHES "3\\.4\\.[0-9]")
     24    ENDIF(gcc_compiler_version MATCHES "4\\.[0-9]\\.[0-9]")
     25
     26    SET(_PCH_include_prefix "-I")
     27
     28ELSE(CMAKE_COMPILER_IS_GNUCXX)
     29
     30    IF(WIN32)
     31        SET(PCHSupport_FOUND TRUE) # for experimental msvc support
     32        SET(_PCH_include_prefix "/I")
     33    ELSE(WIN32)
     34        SET(PCHSupport_FOUND FALSE)
     35    ENDIF(WIN32)
     36
     37ENDIF(CMAKE_COMPILER_IS_GNUCXX)
     38
     39MACRO(_PCH_GET_COMPILE_FLAGS _out_compile_flags)
     40    STRING(TOUPPER "CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}" _flags_var_name)
     41    SET(${_out_compile_flags} ${${_flags_var_name}} )
     42
     43    IF(CMAKE_COMPILER_IS_GNUCXX)
     44        GET_TARGET_PROPERTY(_targetType ${_PCH_current_target} TYPE)
     45        IF(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY)
     46            LIST(APPEND ${_out_compile_flags} "-fPIC")
     47        ENDIF(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY)
     48    ENDIF(CMAKE_COMPILER_IS_GNUCXX)
     49
     50    GET_DIRECTORY_PROPERTY(DIRINC INCLUDE_DIRECTORIES )
     51    FOREACH(item ${DIRINC})
     52        LIST(APPEND ${_out_compile_flags} " ${_PCH_include_prefix}\"${item}\"")
     53    ENDFOREACH(item)
     54
     55    GET_DIRECTORY_PROPERTY(_directory_flags DEFINITIONS)
     56    GET_DIRECTORY_PROPERTY(_global_definitions DIRECTORY ${CMAKE_SOURCE_DIR} DEFINITIONS)
     57    LIST(APPEND ${_out_compile_flags} ${_directory_flags})
     58    LIST(APPEND ${_out_compile_flags} ${_global_definitions})
     59    LIST(APPEND ${_out_compile_flags} ${CMAKE_CXX_FLAGS})
     60
     61    SEPARATE_ARGUMENTS(${_out_compile_flags})
     62ENDMACRO(_PCH_GET_COMPILE_FLAGS)
     63
     64MACRO(_PCH_GET_PDB_FILENAME out_filename _target)
     65    # determine output directory based on target type
     66    GET_TARGET_PROPERTY(_targetType ${_target} TYPE)
     67    IF(${_targetType} STREQUAL EXECUTABLE)
     68        SET(_targetOutput ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
     69    ELSEIF(${_targetType} STREQUAL STATIC_LIBRARY)
     70        SET(_targetOutput ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})
     71    ELSE(${_targetType} STREQUAL EXECUTABLE)
     72        SET(_targetOutput ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
     73    ENDIF(${_targetType} STREQUAL EXECUTABLE)
     74
     75    # determine target postfix
     76    STRING(TOUPPER "${CMAKE_BUILD_TYPE}_POSTFIX" _postfix_var_name)
     77    GET_TARGET_PROPERTY(_targetPostfix ${_target} ${_postfix_var_name})
     78    IF(${_targetPostfix} MATCHES NOTFOUND)
     79        SET(_targetPostfix "")
     80    ENDIF(${_targetPostfix} MATCHES NOTFOUND)
     81
     82    SET(${out_filename} "${_targetOutput}/${_target}${_targetPostfix}.pdb")
     83ENDMACRO(_PCH_GET_PDB_FILENAME)
     84
     85MACRO(_PCH_GET_COMPILE_COMMAND out_command _input _inputcpp _output)
     86    IF(CMAKE_CXX_COMPILER_ARG1)
     87        # remove leading space in compiler argument
     88        STRING(REGEX REPLACE "^ +" "" pchsupport_compiler_cxx_arg1 ${CMAKE_CXX_COMPILER_ARG1})
     89    ELSE(CMAKE_CXX_COMPILER_ARG1)
     90        SET(pchsupport_compiler_cxx_arg1 "")
     91    ENDIF(CMAKE_CXX_COMPILER_ARG1)
     92
     93    IF(CMAKE_COMPILER_IS_GNUCXX)
     94        SET(${out_command}
     95            ${CMAKE_CXX_COMPILER} ${pchsupport_compiler_cxx_arg1} ${_compile_FLAGS} -x c++-header -o ${_output} -c ${_input}
     96            )
     97    ELSE(CMAKE_COMPILER_IS_GNUCXX)
     98        _PCH_GET_PDB_FILENAME(PDB_FILE ${_PCH_current_target})
     99        SET(${out_command}
     100            ${CMAKE_CXX_COMPILER} ${pchsupport_compiler_cxx_arg1} ${_compile_FLAGS} /Yc  /Fp\"${_output}\" ${_inputcpp} /c /Fd\"${PDB_FILE}\"
     101            )
     102    ENDIF(CMAKE_COMPILER_IS_GNUCXX)
     103ENDMACRO(_PCH_GET_COMPILE_COMMAND )
     104
     105MACRO(GET_PRECOMPILED_HEADER_OUTPUT _targetName _input _output)
     106    IF(MSVC)
     107        GET_FILENAME_COMPONENT(_name ${_input} NAME_WE)
     108        SET(_output "${CMAKE_CURRENT_BINARY_DIR}/${_name}.pch")
     109    ELSE(MSVC)
     110        GET_FILENAME_COMPONENT(_name ${_input} NAME)
     111        SET(_output "${CMAKE_CURRENT_BINARY_DIR}/${_name}.gch")
     112    ENDIF(MSVC)
     113ENDMACRO(GET_PRECOMPILED_HEADER_OUTPUT _targetName _input)
     114
     115MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET _targetName _input _pch_output_to_use )
     116    GET_TARGET_PROPERTY(oldProps ${_targetName} COMPILE_FLAGS)
     117    IF(${oldProps} MATCHES NOTFOUND)
     118        SET(oldProps "")
     119    ENDIF(${oldProps} MATCHES NOTFOUND)
     120
     121    IF(CMAKE_COMPILER_IS_GNUCXX)
     122        # to do: test whether compiler flags match between target  _targetName
     123        # and _pch_output_to_use
     124        FILE(TO_NATIVE_PATH ${_pch_output_to_use} _native_pch_path)
     125
     126        # for use with distcc and gcc >4.0.1 if preprocessed files are accessible
     127        # on all remote machines set
     128        # PCH_ADDITIONAL_COMPILER_FLAGS to -fpch-preprocess
     129        GET_FILENAME_COMPONENT(_name ${_input} NAME_WE)
     130        SET(_target_cflags "${oldProps} ${PCH_ADDITIONAL_COMPILER_FLAGS}-include ${CMAKE_CURRENT_BINARY_DIR}/${_name}.h -Winvalid-pch")
     131    ELSE(CMAKE_COMPILER_IS_GNUCXX)
     132        IF(MSVC)
     133            SET(_target_cflags "${oldProps} /Yu\"${_input}\" /FI\"${_input}\" /Fp\"${_pch_output_to_use}\"")
     134        ENDIF(MSVC)
     135    ENDIF(CMAKE_COMPILER_IS_GNUCXX)
     136
     137    SET_TARGET_PROPERTIES(${_targetName} PROPERTIES COMPILE_FLAGS ${_target_cflags})
     138    #SET_TARGET_PROPERTIES(${_targetName}_pch_dephelp PROPERTIES COMPILE_FLAGS ${_target_cflags})
     139    ADD_CUSTOM_TARGET(pch_Generate_${_targetName} DEPENDS ${_pch_output_to_use})
     140    ADD_DEPENDENCIES(${_targetName} pch_Generate_${_targetName})
     141ENDMACRO(ADD_PRECOMPILED_HEADER_TO_TARGET)
     142
     143MACRO(ADD_PRECOMPILED_HEADER _targetName _inputh _inputcpp)
     144
     145    SET(_PCH_current_target ${_targetName})
     146
     147    IF(NOT CMAKE_BUILD_TYPE)
     148        MESSAGE(FATAL_ERROR
     149            "This is the ADD_PRECOMPILED_HEADER macro. "
     150            "You must set CMAKE_BUILD_TYPE!"
     151        )
     152    ENDIF(NOT CMAKE_BUILD_TYPE)
     153
     154    GET_PRECOMPILED_HEADER_OUTPUT( ${_targetName} ${_inputh} _output)
     155
     156    GET_TARGET_PROPERTY(_targetType ${_PCH_current_target} TYPE)
     157
     158    # always build static library because it doesn't need linking
     159    ADD_LIBRARY(${_targetName}_pch_dephelp STATIC ${_inputcpp})
     160
     161    _PCH_GET_COMPILE_FLAGS(_compile_FLAGS)
     162
     163    SET_SOURCE_FILES_PROPERTIES(${_inputh} PROPERTIES GENERATED 1)
     164
     165    _PCH_GET_COMPILE_COMMAND(_command  ${_inputh} ${_inputcpp} ${_output})
     166
     167    ADD_CUSTOM_COMMAND(
     168        OUTPUT ${_output}
     169        COMMAND ${_command}
     170        DEPENDS ${_inputh} ${_targetName}_pch_dephelp
     171    )
     172
     173    ADD_PRECOMPILED_HEADER_TO_TARGET(${_targetName} ${_inputh} ${_output})
     174ENDMACRO(ADD_PRECOMPILED_HEADER)
     175
     176MACRO(ADD_NATIVE_PRECOMPILED_HEADER _targetName _inputh _inputcpp)
     177    IF(CMAKE_GENERATOR MATCHES Visual*)
     178        # Auto include the precompile (useful for moc processing, since the use of
     179        # precompiled is specified at the target level
     180        # and I don't want to specifiy /F- for each moc/res/ui generated files (using Qt)
     181
     182        GET_TARGET_PROPERTY(oldProps ${_targetName} COMPILE_FLAGS)
     183        IF(${oldProps} MATCHES NOTFOUND)
     184            SET(oldProps "")
     185        ENDIF(${oldProps} MATCHES NOTFOUND)
     186
     187        SET(newProperties "${oldProps} /Yu\"${_inputh}\" /FI\"${_inputh}\"")
     188        SET_TARGET_PROPERTIES(${_targetName} PROPERTIES COMPILE_FLAGS "${newProperties}")
     189
     190        #also inlude ${oldProps} to have the same compile options
     191        SET_SOURCE_FILES_PROPERTIES(${_inputcpp} PROPERTIES COMPILE_FLAGS "${oldProps} /Yc\"${_inputh}\"")
     192    ELSE(CMAKE_GENERATOR MATCHES Visual*)
     193        IF(CMAKE_GENERATOR MATCHES Xcode)
     194            # For Xcode, cmake needs my patch to process
     195            # GCC_PREFIX_HEADER and GCC_PRECOMPILE_PREFIX_HEADER as target properties
     196
     197            GET_TARGET_PROPERTY(oldProps ${_targetName} COMPILE_FLAGS)
     198            IF(${oldProps} MATCHES NOTFOUND)
     199                SET(oldProps "")
     200            ENDIF(${oldProps} MATCHES NOTFOUND)
     201
     202            # When buiding out of the tree, precompiled may not be located
     203            # Use full path instead.
     204            GET_FILENAME_COMPONENT(fullPath ${_inputh} ABSOLUTE)
     205
     206            SET_TARGET_PROPERTIES(${_targetName} PROPERTIES XCODE_ATTRIBUTE_GCC_PREFIX_HEADER "${fullPath}")
     207            SET_TARGET_PROPERTIES(${_targetName} PROPERTIES XCODE_ATTRIBUTE_GCC_PRECOMPILE_PREFIX_HEADER "YES")
     208        ELSE(CMAKE_GENERATOR MATCHES Xcode)
     209            #Fallback to the "old" precompiled suppport
     210            ADD_PRECOMPILED_HEADER(${_targetName} ${_inputh} ${_inputcpp})
     211        ENDIF(CMAKE_GENERATOR MATCHES Xcode)
     212    ENDIF(CMAKE_GENERATOR MATCHES Visual*)
     213
     214ENDMACRO(ADD_NATIVE_PRECOMPILED_HEADER)
  • new file uild/cmake/CMakeModules/PCHSupport1.cmake

    diff -r 27195836057e build/cmake/CMakeModules/PCHSupport1.cmake
    - +  
     1# - Try to find precompiled headers support for GCC 3.4 and 4.x (and MSVC)
     2# Once done this will define:
     3#
     4# Variable:
     5#   PCHSupport_FOUND
     6#
     7#   ADD_PRECOMPILED_HEADER  _targetName _inputh _inputcpp
     8#   ADD_PRECOMPILED_HEADER_TO_TARGET _targetName _input _pch_output_to_use
     9#   ADD_NATIVE_PRECOMPILED_HEADER _targetName _inputh _inputcpp
     10
     11IF(CMAKE_COMPILER_IS_GNUCXX)
     12
     13    EXEC_PROGRAM(
     14        ${CMAKE_CXX_COMPILER}
     15        ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
     16        OUTPUT_VARIABLE gcc_compiler_version)
     17
     18    IF(gcc_compiler_version MATCHES "4\\.[0-9]\\.[0-9]")
     19        SET(PCHSupport_FOUND TRUE)
     20    ELSE(gcc_compiler_version MATCHES "4\\.[0-9]\\.[0-9]")
     21        IF(gcc_compiler_version MATCHES "3\\.4\\.[0-9]")
     22            SET(PCHSupport_FOUND TRUE)
     23        ENDIF(gcc_compiler_version MATCHES "3\\.4\\.[0-9]")
     24    ENDIF(gcc_compiler_version MATCHES "4\\.[0-9]\\.[0-9]")
     25
     26    SET(_PCH_include_prefix "-I")
     27
     28ELSE(CMAKE_COMPILER_IS_GNUCXX)
     29
     30    IF(WIN32)
     31        SET(PCHSupport_FOUND TRUE) # for experimental msvc support
     32        SET(_PCH_include_prefix "/I")
     33    ELSE(WIN32)
     34        SET(PCHSupport_FOUND FALSE)
     35    ENDIF(WIN32)
     36
     37ENDIF(CMAKE_COMPILER_IS_GNUCXX)
     38
     39MACRO(_PCH_GET_COMPILE_FLAGS _out_compile_flags)
     40
     41    STRING(TOUPPER "CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}" _flags_var_name)
     42    SET(${_out_compile_flags} ${${_flags_var_name}} )
     43
     44    IF(CMAKE_COMPILER_IS_GNUCXX)
     45
     46        GET_TARGET_PROPERTY(_targetType ${_PCH_current_target} TYPE)
     47        IF((${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY) AND NOT WIN32)
     48            LIST(APPEND ${_out_compile_flags} "-fPIC")
     49        ENDIF((${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY) AND NOT WIN32)
     50
     51    ELSE(CMAKE_COMPILER_IS_GNUCXX)
     52        ## TODO ... ? or does it work out of the box
     53    ENDIF(CMAKE_COMPILER_IS_GNUCXX)
     54
     55    GET_DIRECTORY_PROPERTY(DIRINC INCLUDE_DIRECTORIES )
     56    FOREACH(item ${DIRINC})
     57        LIST(APPEND ${_out_compile_flags} "${_PCH_include_prefix}${item}")
     58    ENDFOREACH(item)
     59
     60    GET_DIRECTORY_PROPERTY(_directory_flags DEFINITIONS)
     61    GET_DIRECTORY_PROPERTY(_global_definitions DIRECTORY ${CMAKE_SOURCE_DIR} DEFINITIONS)
     62    LIST(APPEND ${_out_compile_flags} ${_directory_flags})
     63    LIST(APPEND ${_out_compile_flags} ${_global_definitions})
     64    LIST(APPEND ${_out_compile_flags} ${CMAKE_CXX_FLAGS})
     65
     66    SEPARATE_ARGUMENTS(${_out_compile_flags})
     67
     68ENDMACRO(_PCH_GET_COMPILE_FLAGS)
     69
     70MACRO(_PCH_GET_COMPILE_COMMAND out_command _input _output)
     71
     72    IF(CMAKE_COMPILER_IS_GNUCXX)
     73        IF(CMAKE_CXX_COMPILER_ARG1)
     74            # remove leading space in compiler argument
     75            STRING(REGEX REPLACE "^ +" "" pchsupport_compiler_cxx_arg1 ${CMAKE_CXX_COMPILER_ARG1})
     76
     77            SET(${out_command}
     78                ${CMAKE_CXX_COMPILER} ${pchsupport_compiler_cxx_arg1} ${_compile_FLAGS} -x c++-header -o ${_output} -c ${_input}
     79                )
     80        ELSE(CMAKE_CXX_COMPILER_ARG1)
     81            SET(${out_command}
     82                ${CMAKE_CXX_COMPILER} ${_compile_FLAGS} -x c++-header -o ${_output} -c ${_input}
     83                )
     84        ENDIF(CMAKE_CXX_COMPILER_ARG1)
     85    ELSE(CMAKE_COMPILER_IS_GNUCXX)
     86
     87        # nothing to do because std*.cpp are already added to target
     88
     89    ENDIF(CMAKE_COMPILER_IS_GNUCXX)
     90
     91ENDMACRO(_PCH_GET_COMPILE_COMMAND )
     92
     93
     94
     95MACRO(_PCH_GET_TARGET_COMPILE_FLAGS _cflags _header_name _pch_path)
     96
     97    FILE(TO_NATIVE_PATH ${_pch_path} _native_pch_path)
     98
     99    IF(CMAKE_COMPILER_IS_GNUCXX)
     100        # for use with distcc and gcc >4.0.1 if preprocessed files are accessible
     101        # on all remote machines set
     102        # PCH_ADDITIONAL_COMPILER_FLAGS to -fpch-preprocess
     103        SET(${_cflags} "${PCH_ADDITIONAL_COMPILER_FLAGS}-include ${CMAKE_CURRENT_BINARY_DIR}/${_header_name} -Winvalid-pch")
     104    ENDIF(CMAKE_COMPILER_IS_GNUCXX)
     105
     106ENDMACRO(_PCH_GET_TARGET_COMPILE_FLAGS )
     107
     108MACRO(GET_PRECOMPILED_HEADER_OUTPUT _targetName _input _output)
     109    GET_FILENAME_COMPONENT(_name ${_input} NAME)
     110    SET(_output "${CMAKE_CURRENT_BINARY_DIR}/${_name}.gch")
     111ENDMACRO(GET_PRECOMPILED_HEADER_OUTPUT _targetName _input)
     112
     113
     114MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET _targetName _input _pch_output_to_use )
     115
     116    # to do: test whether compiler flags match between target  _targetName
     117    # and _pch_output_to_use
     118    GET_FILENAME_COMPONENT(_name ${_input} NAME)
     119
     120    _PCH_GET_TARGET_COMPILE_FLAGS(_target_cflags ${_name} ${_pch_output_to_use})
     121
     122    SET_TARGET_PROPERTIES(${_targetName}
     123        PROPERTIES
     124        COMPILE_FLAGS ${_target_cflags}
     125    )
     126
     127    ADD_CUSTOM_TARGET(pch_Generate_${_targetName}
     128        DEPENDS ${_pch_output_to_use}
     129    )
     130
     131    ADD_DEPENDENCIES(${_targetName} pch_Generate_${_targetName} )
     132
     133ENDMACRO(ADD_PRECOMPILED_HEADER_TO_TARGET)
     134
     135MACRO(ADD_PRECOMPILED_HEADER _targetName _inputh _inputcpp)
     136
     137    SET(_PCH_current_target ${_targetName})
     138
     139    IF(NOT CMAKE_BUILD_TYPE)
     140        MESSAGE(FATAL_ERROR
     141            "This is the ADD_PRECOMPILED_HEADER macro. "
     142            "You must set CMAKE_BUILD_TYPE!"
     143        )
     144    ENDIF(NOT CMAKE_BUILD_TYPE)
     145
     146    GET_PRECOMPILED_HEADER_OUTPUT( ${_targetName} ${_inputh} _output)
     147
     148    GET_TARGET_PROPERTY(_targetType ${_PCH_current_target} TYPE)
     149
     150    # always build static library because it doesn't need linking
     151    ADD_LIBRARY(${_targetName}_pch_dephelp STATIC ${_inputcpp})
     152
     153    _PCH_GET_COMPILE_FLAGS(_compile_FLAGS)
     154
     155    SET_SOURCE_FILES_PROPERTIES(${_inputh} PROPERTIES GENERATED 1)
     156
     157    _PCH_GET_COMPILE_COMMAND(_command  ${_inputh} ${_output})
     158
     159    ADD_CUSTOM_COMMAND(
     160        OUTPUT ${_output}
     161        COMMAND ${_command}
     162        DEPENDS ${_inputh} ${_targetName}_pch_dephelp
     163    )
     164
     165    ADD_PRECOMPILED_HEADER_TO_TARGET(${_targetName} ${_inputh}  ${_output})
     166
     167ENDMACRO(ADD_PRECOMPILED_HEADER)
     168
     169MACRO(ADD_NATIVE_PRECOMPILED_HEADER _targetName _inputh _inputcpp)
     170
     171    if(CMAKE_GENERATOR MATCHES Visual*)
     172        # Auto include the precompile (useful for moc processing, since the use of
     173        # precompiled is specified at the target level
     174        # and I don't want to specifiy /F- for each moc/res/ui generated files (using Qt)
     175
     176        GET_TARGET_PROPERTY(oldProps ${_targetName} COMPILE_FLAGS)
     177        if (${oldProps} MATCHES NOTFOUND)
     178            SET(oldProps "")
     179        endif(${oldProps} MATCHES NOTFOUND)
     180
     181        SET(newProperties "${oldProps} /Yu\"${_inputh}\" /FI\"${_inputh}\"")
     182        SET_TARGET_PROPERTIES(${_targetName} PROPERTIES COMPILE_FLAGS "${newProperties}")
     183
     184        #also inlude ${oldProps} to have the same compile options
     185        SET_SOURCE_FILES_PROPERTIES(${_inputcpp} PROPERTIES COMPILE_FLAGS "${oldProps} /Yc\"${_inputh}\"")
     186
     187    else(CMAKE_GENERATOR MATCHES Visual*)
     188
     189        if (CMAKE_GENERATOR MATCHES Xcode)
     190            # For Xcode, cmake needs my patch to process
     191            # GCC_PREFIX_HEADER and GCC_PRECOMPILE_PREFIX_HEADER as target properties
     192
     193            GET_TARGET_PROPERTY(oldProps ${_targetName} COMPILE_FLAGS)
     194            if (${oldProps} MATCHES NOTFOUND)
     195                SET(oldProps "")
     196            endif(${oldProps} MATCHES NOTFOUND)
     197
     198            # When buiding out of the tree, precompiled may not be located
     199            # Use full path instead.
     200            GET_FILENAME_COMPONENT(fullPath ${_inputh} ABSOLUTE)
     201
     202            SET_TARGET_PROPERTIES(${_targetName} PROPERTIES XCODE_ATTRIBUTE_GCC_PREFIX_HEADER "${fullPath}")
     203            SET_TARGET_PROPERTIES(${_targetName} PROPERTIES XCODE_ATTRIBUTE_GCC_PRECOMPILE_PREFIX_HEADER "YES")
     204
     205        else (CMAKE_GENERATOR MATCHES Xcode)
     206
     207            #Fallback to the "old" precompiled suppport
     208            ADD_PRECOMPILED_HEADER(${_targetName} ${_inputh} ${_inputcpp})
     209        endif(CMAKE_GENERATOR MATCHES Xcode)
     210    endif(CMAKE_GENERATOR MATCHES Visual*)
     211
     212ENDMACRO(ADD_NATIVE_PRECOMPILED_HEADER)
  • new file uild/cmake/CMakeModules/PCHSupport2.cmake

    diff -r 27195836057e build/cmake/CMakeModules/PCHSupport2.cmake
    - +  
     1# - Try to find precompiled headers support for GCC 3.4 and 4.x
     2# Once done this will define:
     3#
     4# Variable:
     5#   PCHSupport_FOUND
     6#
     7# Macro:
     8#   ADD_PRECOMPILED_HEADER  _targetName _input  _dowarn
     9#   ADD_PRECOMPILED_HEADER_TO_TARGET _targetName _input _pch_output_to_use _dowarn
     10#   ADD_NATIVE_PRECOMPILED_HEADER _targetName _input _dowarn
     11#   GET_NATIVE_PRECOMPILED_HEADER _targetName _input
     12
     13IF(CMAKE_COMPILER_IS_GNUCXX)
     14
     15    EXEC_PROGRAM(
     16        ${CMAKE_CXX_COMPILER} 
     17        ARGS    ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
     18        OUTPUT_VARIABLE gcc_compiler_version)
     19    #MESSAGE("GCC Version: ${gcc_compiler_version}")
     20    IF(gcc_compiler_version MATCHES "4\\.[0-9]\\.[0-9]")
     21        SET(PCHSupport_FOUND TRUE)
     22    ELSE(gcc_compiler_version MATCHES "4\\.[0-9]\\.[0-9]")
     23        IF(gcc_compiler_version MATCHES "3\\.4\\.[0-9]")
     24            SET(PCHSupport_FOUND TRUE)
     25        ENDIF(gcc_compiler_version MATCHES "3\\.4\\.[0-9]")
     26    ENDIF(gcc_compiler_version MATCHES "4\\.[0-9]\\.[0-9]")
     27   
     28    SET(_PCH_include_prefix "-I")
     29   
     30ELSE(CMAKE_COMPILER_IS_GNUCXX)
     31    IF(WIN32)   
     32        SET(PCHSupport_FOUND TRUE) # for experimental msvc support
     33        SET(_PCH_include_prefix "/I")
     34    ELSE(WIN32)
     35        SET(PCHSupport_FOUND FALSE)
     36    ENDIF(WIN32)   
     37ENDIF(CMAKE_COMPILER_IS_GNUCXX)
     38
     39
     40MACRO(_PCH_GET_COMPILE_FLAGS _out_compile_flags)
     41
     42
     43  STRING(TOUPPER "CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}" _flags_var_name)
     44  SET(${_out_compile_flags} ${${_flags_var_name}} )
     45 
     46  IF(CMAKE_COMPILER_IS_GNUCXX)
     47   
     48    GET_TARGET_PROPERTY(_targetType ${_PCH_current_target} TYPE)
     49    IF(${_targetType} STREQUAL SHARED_LIBRARY)
     50      LIST(APPEND ${_out_compile_flags} "${${_out_compile_flags}} -fPIC")
     51    ENDIF(${_targetType} STREQUAL SHARED_LIBRARY)
     52   
     53  ELSE(CMAKE_COMPILER_IS_GNUCXX)
     54    ## TODO ... ? or does it work out of the box
     55  ENDIF(CMAKE_COMPILER_IS_GNUCXX)
     56 
     57  GET_DIRECTORY_PROPERTY(DIRINC INCLUDE_DIRECTORIES )
     58  FOREACH(item ${DIRINC})
     59    LIST(APPEND ${_out_compile_flags} "${_PCH_include_prefix}${item}")
     60  ENDFOREACH(item)
     61 
     62  GET_DIRECTORY_PROPERTY(_directory_flags DEFINITIONS)
     63  #MESSAGE("_directory_flags ${_directory_flags}" )
     64  LIST(APPEND ${_out_compile_flags} ${_directory_flags})
     65  LIST(APPEND ${_out_compile_flags} ${CMAKE_CXX_FLAGS} )
     66 
     67  SEPARATE_ARGUMENTS(${_out_compile_flags})
     68
     69ENDMACRO(_PCH_GET_COMPILE_FLAGS)
     70
     71
     72MACRO(_PCH_WRITE_PCHDEP_CXX _targetName _include_file _dephelp)
     73
     74  SET(${_dephelp} ${CMAKE_CURRENT_BINARY_DIR}/${_targetName}_pch_dephelp.cxx)
     75  FILE(WRITE  ${${_dephelp}}
     76"#include \"${_include_file}\"
     77int testfunction()
     78{
     79    return 0;
     80}
     81"
     82    )
     83
     84ENDMACRO(_PCH_WRITE_PCHDEP_CXX )
     85
     86MACRO(_PCH_GET_COMPILE_COMMAND out_command _input _output)
     87
     88    FILE(TO_NATIVE_PATH ${_input} _native_input)
     89    FILE(TO_NATIVE_PATH ${_output} _native_output)
     90   
     91
     92    IF(CMAKE_COMPILER_IS_GNUCXX)
     93          IF(CMAKE_CXX_COMPILER_ARG1)
     94        # remove leading space in compiler argument
     95            STRING(REGEX REPLACE "^ +" "" pchsupport_compiler_cxx_arg1 ${CMAKE_CXX_COMPILER_ARG1})
     96
     97        SET(${out_command}
     98          ${CMAKE_CXX_COMPILER} ${pchsupport_compiler_cxx_arg1} ${_compile_FLAGS}   -x c++-header -o ${_output} ${_input}
     99          )
     100      ELSE(CMAKE_CXX_COMPILER_ARG1)
     101        SET(${out_command}
     102          ${CMAKE_CXX_COMPILER}  ${_compile_FLAGS}  -x c++-header -o ${_output} ${_input}
     103          )
     104          ENDIF(CMAKE_CXX_COMPILER_ARG1)
     105    ELSE(CMAKE_COMPILER_IS_GNUCXX)
     106       
     107        SET(_dummy_str "#include <${_input}>")
     108        FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/pch_dummy.cpp ${_dummy_str})
     109   
     110        SET(${out_command}
     111            ${CMAKE_CXX_COMPILER} ${_compile_FLAGS} /c /Fp${_native_output} /Yc${_native_input} pch_dummy.cpp
     112        )   
     113        #/out:${_output}
     114
     115    ENDIF(CMAKE_COMPILER_IS_GNUCXX)
     116   
     117ENDMACRO(_PCH_GET_COMPILE_COMMAND )
     118
     119
     120
     121MACRO(_PCH_GET_TARGET_COMPILE_FLAGS _cflags  _header_name _pch_path _dowarn )
     122
     123  FILE(TO_NATIVE_PATH ${_pch_path} _native_pch_path)
     124 
     125  IF(CMAKE_COMPILER_IS_GNUCXX)
     126    # for use with distcc and gcc >4.0.1 if preprocessed files are accessible
     127    # on all remote machines set
     128    # PCH_ADDITIONAL_COMPILER_FLAGS to -fpch-preprocess
     129    # if you want warnings for invalid header files (which is very inconvenient
     130    # if you have different versions of the headers for different build types
     131    # you may set _pch_dowarn
     132    IF (_dowarn)
     133      SET(${_cflags} "${PCH_ADDITIONAL_COMPILER_FLAGS} -include ${CMAKE_CURRENT_BINARY_DIR}/${_header_name} -Winvalid-pch " )
     134    ELSE (_dowarn)
     135      SET(${_cflags} "${PCH_ADDITIONAL_COMPILER_FLAGS} -include ${CMAKE_CURRENT_BINARY_DIR}/${_header_name} " )
     136    ENDIF (_dowarn)
     137  ELSE(CMAKE_COMPILER_IS_GNUCXX)
     138   
     139    set(${_cflags} "/Fp${_native_pch_path} /Yu${_header_name}" )   
     140   
     141  ENDIF(CMAKE_COMPILER_IS_GNUCXX)   
     142 
     143ENDMACRO(_PCH_GET_TARGET_COMPILE_FLAGS )
     144
     145MACRO(GET_PRECOMPILED_HEADER_OUTPUT _targetName _input _output)
     146  GET_FILENAME_COMPONENT(_name ${_input} NAME)
     147  GET_FILENAME_COMPONENT(_path ${_input} PATH)
     148  SET(_output "${CMAKE_CURRENT_BINARY_DIR}/${_name}.gch/${_targetName}_${CMAKE_BUILD_TYPE}.h++")
     149ENDMACRO(GET_PRECOMPILED_HEADER_OUTPUT _targetName _input)
     150
     151
     152MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET _targetName _input _pch_output_to_use )
     153   
     154  # to do: test whether compiler flags match between target  _targetName
     155  # and _pch_output_to_use
     156  GET_FILENAME_COMPONENT(_name ${_input} NAME)
     157
     158  IF( "${ARGN}" STREQUAL "0")
     159    SET(_dowarn 0)
     160  ELSE( "${ARGN}" STREQUAL "0")
     161    SET(_dowarn 1)
     162  ENDIF("${ARGN}" STREQUAL "0")
     163
     164
     165  _PCH_GET_TARGET_COMPILE_FLAGS(_target_cflags ${_name} ${_pch_output_to_use} ${_dowarn})
     166  #   MESSAGE("Add flags ${_target_cflags} to ${_targetName} " )
     167  SET_TARGET_PROPERTIES(${_targetName}
     168    PROPERTIES 
     169    COMPILE_FLAGS ${_target_cflags}
     170    )
     171
     172  ADD_CUSTOM_TARGET(pch_Generate_${_targetName}
     173    DEPENDS ${_pch_output_to_use}
     174    )
     175 
     176  ADD_DEPENDENCIES(${_targetName} pch_Generate_${_targetName} )
     177 
     178ENDMACRO(ADD_PRECOMPILED_HEADER_TO_TARGET)
     179
     180MACRO(ADD_PRECOMPILED_HEADER _targetName _input)
     181
     182  SET(_PCH_current_target ${_targetName})
     183 
     184  IF(NOT CMAKE_BUILD_TYPE)
     185    MESSAGE(FATAL_ERROR
     186      "This is the ADD_PRECOMPILED_HEADER macro. "
     187      "You must set CMAKE_BUILD_TYPE!"
     188      )
     189  ENDIF(NOT CMAKE_BUILD_TYPE)
     190
     191  IF( "${ARGN}" STREQUAL "0")
     192    SET(_dowarn 0)
     193  ELSE( "${ARGN}" STREQUAL "0")
     194    SET(_dowarn 1)
     195  ENDIF("${ARGN}" STREQUAL "0")
     196
     197
     198  GET_FILENAME_COMPONENT(_name ${_input} NAME)
     199  GET_FILENAME_COMPONENT(_path ${_input} PATH)
     200  GET_PRECOMPILED_HEADER_OUTPUT( ${_targetName} ${_input} _output)
     201
     202  GET_FILENAME_COMPONENT(_outdir ${_output} PATH )
     203
     204  GET_TARGET_PROPERTY(_targetType ${_PCH_current_target} TYPE)
     205   _PCH_WRITE_PCHDEP_CXX(${_targetName} ${_input} _pch_dephelp_cxx)
     206
     207  IF(${_targetType} STREQUAL SHARED_LIBRARY)
     208    ADD_LIBRARY(${_targetName}_pch_dephelp SHARED ${_pch_dephelp_cxx} )
     209  ELSE(${_targetType} STREQUAL SHARED_LIBRARY)
     210    ADD_LIBRARY(${_targetName}_pch_dephelp STATIC ${_pch_dephelp_cxx})
     211  ENDIF(${_targetType} STREQUAL SHARED_LIBRARY)
     212
     213  FILE(MAKE_DIRECTORY ${_outdir})
     214
     215 
     216  _PCH_GET_COMPILE_FLAGS(_compile_FLAGS)
     217 
     218  #MESSAGE("_compile_FLAGS: ${_compile_FLAGS}")
     219  #message("COMMAND ${CMAKE_CXX_COMPILER}   ${_compile_FLAGS} -x c++-header -o ${_output} ${_input}")
     220  SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/${_name} PROPERTIES GENERATED 1)
     221  ADD_CUSTOM_COMMAND(
     222   OUTPUT   ${CMAKE_CURRENT_BINARY_DIR}/${_name}
     223   COMMAND ${CMAKE_COMMAND} -E copy  ${_input} ${CMAKE_CURRENT_BINARY_DIR}/${_name} # ensure same directory! Required by gcc
     224   DEPENDS ${_input}
     225  )
     226 
     227  #message("_command  ${_input} ${_output}")
     228  _PCH_GET_COMPILE_COMMAND(_command  ${CMAKE_CURRENT_BINARY_DIR}/${_name} ${_output} )
     229 
     230  #message(${_input} )
     231  #message("_output ${_output}")
     232
     233  ADD_CUSTOM_COMMAND(
     234    OUTPUT ${_output}   
     235    COMMAND ${_command}
     236    DEPENDS ${_input}   ${CMAKE_CURRENT_BINARY_DIR}/${_name} ${_targetName}_pch_dephelp
     237   )
     238
     239
     240  ADD_PRECOMPILED_HEADER_TO_TARGET(${_targetName} ${_input}  ${_output} ${_dowarn})
     241ENDMACRO(ADD_PRECOMPILED_HEADER)
     242
     243
     244# Generates the use of precompiled in a target,
     245# without using depency targets (2 extra for each target)
     246# Using Visual, must also add ${_targetName}_pch to sources
     247# Not needed by Xcode
     248
     249MACRO(GET_NATIVE_PRECOMPILED_HEADER _targetName _input)
     250
     251    if(CMAKE_GENERATOR MATCHES Visual*)
     252
     253        SET(_dummy_str "#include \"${_input}\"\n"
     254                                        "// This is required to suppress LNK4221.  Very annoying.\n"
     255                                        "void *g_${_targetName}Dummy = 0\;\n")
     256
     257        # Use of cxx extension for generated files (as Qt does)
     258        SET(${_targetName}_pch ${CMAKE_CURRENT_BINARY_DIR}/${_targetName}_pch.cxx)
     259        if(EXISTS ${${_targetName}_pch})
     260            # Check if contents is the same, if not rewrite
     261            # todo
     262        else(EXISTS ${${_targetName}_pch})
     263            FILE(WRITE ${${_targetName}_pch} ${_dummy_str})
     264        endif(EXISTS ${${_targetName}_pch})
     265    endif(CMAKE_GENERATOR MATCHES Visual*)
     266
     267ENDMACRO(GET_NATIVE_PRECOMPILED_HEADER)
     268
     269
     270MACRO(ADD_NATIVE_PRECOMPILED_HEADER _targetName _input)
     271
     272    IF( "${ARGN}" STREQUAL "0")
     273        SET(_dowarn 0)
     274    ELSE( "${ARGN}" STREQUAL "0")
     275        SET(_dowarn 1)
     276    ENDIF("${ARGN}" STREQUAL "0")
     277   
     278    if(CMAKE_GENERATOR MATCHES Visual*)
     279        # Auto include the precompile (useful for moc processing, since the use of
     280        # precompiled is specified at the target level
     281        # and I don't want to specifiy /F- for each moc/res/ui generated files (using Qt)
     282
     283        GET_TARGET_PROPERTY(oldProps ${_targetName} COMPILE_FLAGS)
     284        if (${oldProps} MATCHES NOTFOUND)
     285            SET(oldProps "")
     286        endif(${oldProps} MATCHES NOTFOUND)
     287
     288        SET(newProperties "${oldProps} /Yu\"${_input}\" /FI\"${_input}\"")
     289        SET_TARGET_PROPERTIES(${_targetName} PROPERTIES COMPILE_FLAGS "${newProperties}")
     290       
     291        #also inlude ${oldProps} to have the same compile options
     292        SET_SOURCE_FILES_PROPERTIES(${${_targetName}_pch} PROPERTIES COMPILE_FLAGS "${oldProps} /Yc\"${_input}\"")
     293       
     294    else(CMAKE_GENERATOR MATCHES Visual*)
     295   
     296        if (CMAKE_GENERATOR MATCHES Xcode)
     297            # For Xcode, cmake needs my patch to process
     298            # GCC_PREFIX_HEADER and GCC_PRECOMPILE_PREFIX_HEADER as target properties
     299           
     300            GET_TARGET_PROPERTY(oldProps ${_targetName} COMPILE_FLAGS)
     301            if (${oldProps} MATCHES NOTFOUND)
     302                SET(oldProps "")
     303            endif(${oldProps} MATCHES NOTFOUND)
     304
     305            # When buiding out of the tree, precompiled may not be located
     306            # Use full path instead.
     307            GET_FILENAME_COMPONENT(fullPath ${_input} ABSOLUTE)
     308
     309            SET_TARGET_PROPERTIES(${_targetName} PROPERTIES XCODE_ATTRIBUTE_GCC_PREFIX_HEADER "${fullPath}")
     310            SET_TARGET_PROPERTIES(${_targetName} PROPERTIES XCODE_ATTRIBUTE_GCC_PRECOMPILE_PREFIX_HEADER "YES")
     311
     312        else (CMAKE_GENERATOR MATCHES Xcode)
     313
     314            #Fallback to the "old" precompiled suppport
     315            ADD_PRECOMPILED_HEADER(${_targetName} ${_input} ${_dowarn})
     316        endif(CMAKE_GENERATOR MATCHES Xcode)
     317    endif(CMAKE_GENERATOR MATCHES Visual*)
     318
     319ENDMACRO(ADD_NATIVE_PRECOMPILED_HEADER)
  • new file uild/cmake/README.txt

    diff -r 27195836057e build/cmake/README.txt
    - +  
     1The current CMake-based system is an experimental prototype and
     2probably does not work. You should use the normal build process
     3(http://trac.wildfiregames.com/wiki/BuildInstructions) instead.
     4
     5Otherwise, on Linux run some commands in build/cmake/ :
     6
     7  mkdir release
     8  cd release
     9  cmake ../../../source
     10  make
     11
     12or for debug mode:
     13
     14  mkdir debug
     15  cd debug
     16  cmake ../../../source -DCMAKE_BUILD_TYPE=Debug
     17  make
     18
     19On Windows:
     20
     21  mkdir vs2008
     22  cd vs2008
     23  "c:\program files\cmake 2.8\bin\cmake" -G "Visual Studio 9 2008" ../../../source
     24
     25or similar.
  • new file source/CMakeLists.txt

    diff -r 27195836057e source/CMakeLists.txt
    - +  
     1cmake_minimum_required(VERSION 2.8)
     2
     3# Default to release-with-debug-info mode
     4# (Override with "cmake -DCMAKE_BUILD_TYPE=Debug" or Release etc)
     5if (NOT CMAKE_BUILD_TYPE)
     6  set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "" FORCE)
     7endif ()
     8
     9project(Pyrogenesis)
     10
     11set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../build/cmake/CMakeModules;${CMAKE_MODULE_PATH}")
     12
     13# Detect 32-bit or 64-bit (currently we only support x86 archs)
     14if (CMAKE_SIZEOF_VOID_P EQUAL 8)
     15  set(TARGET_AMD64 1)
     16else ()
     17  set(TARGET_IA32 1)
     18endif ()
     19
     20if (MSVC)
     21
     22  # Force to always compile with W4
     23  if (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
     24    string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
     25  else ()
     26    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
     27  endif ()
     28
     29  # Disable RTTI
     30  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
     31
     32  # Add NDEBUG when appropriate
     33  set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /DNDEBUG")
     34  set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /DNDEBUG")
     35
     36elseif (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
     37
     38  # Enable some warnings
     39  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wunused-parameter -Wredundant-decls -Wnon-virtual-dtor -Wundef")
     40
     41  # Disable some other warnings
     42  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch -Wno-reorder -Wno-invalid-offsetof -Wno-missing-field-initializers")
     43
     44  # Do some other stuff
     45  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-all -D_FORTIFY_SOURCE=2 -fstrict-aliasing -fno-omit-frame-pointer -fvisibility=hidden")
     46
     47  # (TODO: document these better)
     48
     49  # Add NDEBUG when appropriate
     50  set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG")
     51  set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DNDEBUG")
     52
     53endif()
     54
     55# ps_bundled macro: alternative to find_package for our bundled libraries
     56macro (ps_bundled name dir)
     57  set(${name}_LIBRARY_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../libraries/${dir}/lib")
     58  set(${name}_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../libraries/${dir}/include")
     59endmacro ()
     60
     61# Use bundled header-only libraries on all platforms
     62ps_bundled(CXXTEST cxxtest)
     63ps_bundled(VALGRIND valgrind)
     64
     65if (WIN32)
     66
     67  # Use bundled nasm
     68  set(CMAKE_ASM_NASM_COMPILER "${CMAKE_CURRENT_SOURCE_DIR}/../build/bin/nasm.exe")
     69
     70  # Use all of the bundled pre-compiled libraries
     71  ps_bundled(Boost boost)
     72  ps_bundled(CURL libcurl)
     73  ps_bundled(ENet enet)
     74  ps_bundled(JPEG libjpg)
     75  ps_bundled(LIBXML2 libxml2)
     76  ps_bundled(NVTT nvtt)
     77  ps_bundled(OGG ogg)
     78  ps_bundled(OPENAL openal)
     79  ps_bundled(OPENGL opengl)
     80  ps_bundled(PNG libpng)
     81  ps_bundled(SDL sdl)
     82  ps_bundled(VORBIS vorbis)
     83  ps_bundled(ZLIB zlib)
     84
     85  # SpiderMonkey has non-standard paths so add them manually.
     86  # (The /debug and /release headers are identical so we can always use the same one.)
     87  set(SPIDERMONKEY_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../libraries/spidermonkey-tip/include-win32/debug)
     88  set(SPIDERMONKEY_LIBRARY_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../libraries/spidermonkey-tip/lib)
     89
     90else ()
     91
     92  include(ExternalProject)
     93
     94  # TODO: the .tar.gz this uses isn't in SVN
     95  ExternalProject_Add(ENet
     96    BUILD_IN_SOURCE 1
     97    URL ${CMAKE_CURRENT_SOURCE_DIR}/../libraries/enet-1.3.1.tar.gz
     98    URL_MD5 d31adbd50924fe39aab3c23308f58959
     99    CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR>
     100  )
     101  ExternalProject_Get_Property(ENet install_dir)
     102  set(ENet_INCLUDE_DIRS ${install_dir}/include)
     103  set(ENet_LIBRARY_DIRS ${install_dir}/lib)
     104  link_directories(${ENet_LIBRARY_DIRS})
     105  set(ENET_LIBRARY_OPTIMIZED enet)
     106
     107  if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
     108    set(spidermonkey_config_flags --enable-debug)
     109  elseif (${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo")
     110    set(spidermonkey_config_flags --enable-debug-symbols)
     111  else ()
     112    set(spidermonkey_config_flags)
     113  endif()
     114
     115  # TODO: only if Valgrind is installed
     116  set(spidermonkey_config_flags ${spidermonkey_config_flags} --enable-valgrind)
     117
     118#  ExternalProject_Add(SpiderMonkey
     119#    URL ${CMAKE_CURRENT_SOURCE_DIR}/../libraries/spidermonkey/js185-1.0.0.tar.gz
     120#    URL_MD5 a4574365938222adca0a6bd33329cb32
     121#    CONFIGURE_COMMAND <SOURCE_DIR>/js/src/configure ${spidermonkey_config_flags} --disable-tests --prefix=<INSTALL_DIR>
     122#  )
     123#  ExternalProject_Get_Property(SpiderMonkey install_dir)
     124#  set(SPIDERMONKEY_INCLUDE_DIR ${install_dir}/include)
     125#  set(SPIDERMONKEY_LIBRARY_DIRS ${install_dir}/lib)
     126#  set(SPIDERMONKEY_LIBRARIES mozjs185)
     127
     128  ExternalProject_Add(SpiderMonkey
     129    SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../libraries/spidermonkey-tip/src
     130    CONFIGURE_COMMAND <SOURCE_DIR>/configure ${spidermonkey_config_flags} --disable-tests --prefix=<INSTALL_DIR>
     131  )
     132  ExternalProject_Get_Property(SpiderMonkey install_dir)
     133  set(SPIDERMONKEY_INCLUDE_DIRS ${install_dir}/include)
     134  set(SPIDERMONKEY_LIBRARY_DIRS ${install_dir}/lib)
     135  set(SPIDERMONKEY_LIBRARIES mozjs)
     136
     137
     138  ExternalProject_Add(NVTT
     139    SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../libraries/nvtt/src
     140    CMAKE_ARGS -DNVTT_SHARED=1 -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
     141  )
     142  ExternalProject_Get_Property(NVTT install_dir)
     143  set(NVTT_INCLUDE_DIRS ${install_dir}/include)
     144  set(NVTT_LIBRARY_DIRS ${install_dir}/lib)
     145  set(NVTT_LIBRARIES nvcore nvimage nvmath nvtt)
     146
     147  include(DetermineVersion) # required by some find_packae
     148
     149  set(Boost_USE_STATIC_RUNTIME OFF) # TODO: do we need this?
     150  find_package(Boost REQUIRED COMPONENTS system)
     151
     152  # TODO: if non-bundled ENet:
     153  #  set(LINK_ENET_DYNAMIC ON)
     154  #  find_package(ENet REQUIRED)
     155
     156  find_package(CURL REQUIRED)
     157  find_package(FAM REQUIRED)
     158  find_package(JPEG REQUIRED)
     159  find_package(LibXml2 REQUIRED)
     160  find_package(Ogg REQUIRED)
     161  find_package(OpenAL REQUIRED)
     162  find_package(OpenGL REQUIRED)
     163  find_package(PNG REQUIRED)
     164  find_package(SDL REQUIRED)
     165  find_package(Threads REQUIRED)
     166  find_package(Vorbis REQUIRED)
     167  find_package(X11 REQUIRED)
     168
     169  # TODO: is this really needed?
     170  set(LIBXML2_INCLUDE_DIRS ${LIBXML2_INCLUDE_DIR})
     171
     172endif ()
     173
     174
     175include(PCHSupport)
     176
     177# ps_add_pch_library macro: basically add_library but sets up
     178# the extra state necessary for PCH to work (if enabled)
     179if(1) # TODO: only if PCH is available and not disabled
     180  macro (ps_add_pch_library libname modname srcs)
     181    include_directories(${CMAKE_SOURCE_DIR}/pch/${modname})
     182    add_library(${libname} ${CMAKE_SOURCE_DIR}/pch/${modname}/precompiled.cpp ${srcs})
     183    add_native_precompiled_header(${libname} ${CMAKE_SOURCE_DIR}/pch/${modname}/precompiled.h ${CMAKE_SOURCE_DIR}/pch/${modname}/precompiled.cpp)
     184  endmacro ()
     185  add_definitions(-DUSING_PCH)
     186else()
     187  macro (ps_add_pch_library libname modname srcs)
     188    include_directories(${CMAKE_SOURCE_DIR}/pch/${modname})
     189    add_library(${libname} ${srcs})
     190  endmacro ()
     191endif()
     192
     193# ps_add_dependencies macro: takes a list of libraries for which to set up
     194# include paths on the given target, and also handles dependencies on
     195# ExternalProject targets
     196macro (ps_add_dependencies libname libs)
     197  foreach (lib ${libs})
     198
     199    include_directories(${${lib}_INCLUDE_DIRS})
     200
     201    if (lib STREQUAL "SPIDERMONKEY")
     202      add_dependencies(${libname} SpiderMonkey)
     203    elseif (lib STREQUAL "ENet")
     204      add_dependencies(${libname} ENet)
     205    elseif (lib STREQUAL "NVTT")
     206      add_dependencies(${libname} NVTT)
     207    endif ()
     208  endforeach ()
     209endmacro ()
     210
     211# Source root should always be in the include path
     212include_directories(${CMAKE_CURRENT_SOURCE_DIR})
     213
     214# Global defines
     215add_definitions(-DLIB_STATIC_LINK -DNVTT_SHARED)
     216
     217# Import all the source directories
     218add_subdirectory(graphics)
     219add_subdirectory(gui)
     220add_subdirectory(lib)
     221add_subdirectory(maths)
     222add_subdirectory(mocks)
     223add_subdirectory(network)
     224add_subdirectory(ps)
     225add_subdirectory(renderer)
     226add_subdirectory(scripting)
     227add_subdirectory(scriptinterface)
     228add_subdirectory(simulation2)
     229add_subdirectory(sound)
     230add_subdirectory(tools/atlas/GameInterface)
     231
     232link_directories(${Boost_LIBRARY_DIRS})
     233link_directories(${CURL_LIBRARY_DIRS})
     234link_directories(${ENet_LIBRARY_DIRS})
     235link_directories(${JPEG_LIBRARY_DIRS})
     236link_directories(${LIBXML2_LIBRARY_DIRS})
     237link_directories(${NVTT_LIBRARY_DIRS})
     238link_directories(${OGG_LIBRARY_DIRS})
     239link_directories(${OPENAL_LIBRARY_DIRS})
     240link_directories(${OPENGL_LIBRARY_DIRS})
     241link_directories(${PNG_LIBRARY_DIRS})
     242link_directories(${SDL_LIBRARY_DIRS})
     243link_directories(${SPIDERMONKEY_LIBRARY_DIRS})
     244link_directories(${VORBIS_LIBRARY_DIRS})
     245link_directories(${ZLIB_LIBRARY_DIRS})
     246
     247if (WIN32)
     248  # Most libraries get included via "#pragma comment(lib, ...)"
     249  # so we don't need to specify many here
     250  set(EXTERNAL_LIBRARIES
     251    libxml2.lib
     252    nvtt.lib
     253
     254    debug enetd.lib
     255    debug libcurld.lib
     256    debug mozjs-ps-debug.lib
     257
     258    release enet.lib
     259    release libcurl.lib
     260    release mozjs-ps-release.lib
     261  )
     262  # TODO: non-debug
     263else ()
     264  set(EXTERNAL_LIBRARIES
     265    ${Boost_LIBRARIES}
     266    ${CMAKE_THREAD_LIBS_INIT}
     267    ${CURL_LIBRARIES}
     268    ${ENET_LIBRARY_OPTIMIZED} # TODO: maybe not always the optimized one?
     269    ${FAM_LIBRARIES}
     270    ${JPEG_LIBRARIES}
     271    ${LIBXML2_LIBRARIES}
     272    ${NVTT_LIBRARIES}
     273    ${OGG_LIBRARY}
     274    ${OPENAL_LIBRARY}
     275    ${OPENGL_gl_LIBRARY}
     276    ${PNG_LIBRARIES}
     277    ${SDL_LIBRARY}
     278    ${SPIDERMONKEY_LIBRARIES}
     279    ${VORBISFILE_LIBRARY} # we only use libvorbisfile, not libvorbis
     280    ${X11_X11_LIB}
     281  )
     282endif ()
     283
     284# Includes for main.cpp
     285include_directories(${Boost_INCLUDE_DIRS})
     286include_directories(${OPENGL_INCLUDE_DIRS})
     287include_directories(${SDL_INCLUDE_DIRS})
     288include_directories(${SPIDERMONKEY_INCLUDE_DIRS})
     289
     290if (WIN32)
     291  # Use WIN32 flag to set /subsystem:windows
     292  add_executable(pyrogenesis WIN32
     293    main.cpp
     294    lib/sysdep/os/win/icon.rc
     295    lib/sysdep/os/win/error_dialog.rc
     296  )
     297else ()
     298  add_executable(pyrogenesis
     299    main.cpp
     300  )
     301endif ()
     302
     303target_link_libraries(pyrogenesis
     304  # Link all the source directories (ordered so that libraries
     305  # depend only on later libraries, where possible)
     306  network
     307  scriptinterface
     308  gui
     309  simulation2
     310  scripting
     311  renderer
     312  graphics
     313  ps
     314  atlas
     315  sound
     316  lib
     317  maths
     318  mocks_real
     319  # To resolve circular dependencies we have to list
     320  # some libraries a second time
     321  gui
     322  graphics
     323  simulation2
     324
     325  ${EXTERNAL_LIBRARIES}
     326)
     327
     328set_target_properties(pyrogenesis PROPERTIES
     329  RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../binaries/system
     330  INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib
     331)
     332
     333install(TARGETS pyrogenesis
     334  RUNTIME DESTINATION bin
     335)
     336
     337install(FILES
     338  ${ENet_LIBRARY_DIRS}/libenet.so
     339  ${ENet_LIBRARY_DIRS}/libenet.so.1
     340  ${ENet_LIBRARY_DIRS}/libenet.so.1.0.1
     341  ${SPIDERMONKEY_LIBRARY_DIRS}/libmozjs.so
     342  ${NVTT_LIBRARY_DIRS}/libnvcore.so
     343  ${NVTT_LIBRARY_DIRS}/libnvimage.so
     344  ${NVTT_LIBRARY_DIRS}/libnvmath.so
     345  ${NVTT_LIBRARY_DIRS}/libnvtt.so
     346  DESTINATION lib
     347)
     348
  • new file source/graphics/CMakeLists.txt

    diff -r 27195836057e source/graphics/CMakeLists.txt
    - +  
     1file(GLOB SRC
     2  *.cpp *.h
     3)
     4
     5ps_add_pch_library(graphics graphics "${SRC}")
     6ps_add_dependencies(graphics "Boost;OPENGL;SDL;SPIDERMONKEY;NVTT")
  • new file source/gui/CMakeLists.txt

    diff -r 27195836057e source/gui/CMakeLists.txt
    - +  
     1file(GLOB SRC
     2  *.cpp *.h
     3  scripting/*.cpp scripting/*.h
     4)
     5
     6ps_add_pch_library(gui gui "${SRC}")
     7ps_add_dependencies(gui "Boost;OPENGL;SDL;SPIDERMONKEY")
  • new file source/lib/CMakeLists.txt

    diff -r 27195836057e source/lib/CMakeLists.txt
    - +  
     1file(GLOB SRC
     2  *.cpp *.h
     3  adts/*.cpp adts/*.h
     4  allocators/*.cpp allocators/*.h
     5  external_libraries/*.cpp external_libraries/*.h
     6  file/*.cpp file/*.h
     7  file/archive/*.cpp file/archive/*.h
     8  file/common/*.cpp file/common/*.h
     9  file/io/*.cpp file/io/*.h
     10  file/vfs/*.cpp file/vfs/*.h
     11  pch/*.cpp pch/*.h
     12  posix/*.cpp posix/*.h
     13  res/*.cpp res/*.h
     14  res/graphics/*.cpp res/graphics/*.h
     15  res/sound/*.cpp res/sound/*.h
     16  sysdep/*.cpp sysdep/*.h
     17  sysdep/arch/*.cpp sysdep/arch/*.h
     18  sysdep/os/*.cpp sysdep/os/*.h
     19  sysdep/rtl/*.cpp sysdep/rtl/*.h
     20  tex/*.cpp tex/*.h
     21)
     22
     23file(GLOB SRC_IA32
     24  sysdep/arch/x86_x64/*.cpp sysdep/arch/x86_x64/*.h
     25  sysdep/arch/ia32/*.cpp sysdep/arch/ia32/*.h
     26)
     27
     28file(GLOB SRC_AMD64
     29  sysdep/arch/x86_x64/*.cpp sysdep/arch/x86_x64/*.h
     30  sysdep/arch/amd64/*.cpp sysdep/arch/amd64/*.h
     31)
     32
     33file(GLOB SRC_WIN
     34  sysdep/os/win/*.cpp sysdep/os/win/*.h
     35  sysdep/os/win/aken/*.cpp sysdep/os/win/aken/*.h
     36  sysdep/os/win/whrt/*.cpp sysdep/os/win/whrt/*.h
     37  sysdep/os/win/wposix/*.cpp sysdep/os/win/wposix/*.h
     38  sysdep/rtl/msc/*.cpp sysdep/rtl/msc/*.h
     39)
     40
     41file(GLOB SRC_LINUX
     42  sysdep/os/unix/*.cpp sysdep/os/unix/*.h
     43  sysdep/os/unix/x/*.cpp sysdep/os/unix/x/*.h
     44  sysdep/os/linux/*.cpp sysdep/os/linux/*.h
     45  sysdep/rtl/gcc/*.cpp sysdep/rtl/gcc/*.h
     46)
     47
     48file(GLOB SRC_OSX
     49  sysdep/os/unix/*.cpp sysdep/os/unix/*.h
     50  sysdep/os/unix/x/*.cpp sysdep/os/unix/x/*.h
     51  sysdep/os/osx/*.cpp sysdep/os/osx/*.h
     52  sysdep/rtl/gcc/*.cpp sysdep/rtl/gcc/*.h
     53)
     54
     55source_group(_files REGULAR_EXPRESSION /*)
     56source_group(adts REGULAR_EXPRESSION adts/*)
     57source_group(allocators REGULAR_EXPRESSION allocators/*)
     58source_group(external_libraries REGULAR_EXPRESSION external_libraries/*)
     59source_group(file\\archive REGULAR_EXPRESSION file/archive/*)
     60source_group(file\\common REGULAR_EXPRESSION file/common/*)
     61source_group(file\\io REGULAR_EXPRESSION file/io/*)
     62source_group(file\\vfs REGULAR_EXPRESSION file/vfs/*)
     63source_group(file\\_files REGULAR_EXPRESSION file/*)
     64source_group(pch REGULAR_EXPRESSION pch/*)
     65source_group(posix REGULAR_EXPRESSION posix/*)
     66source_group(res\\graphics REGULAR_EXPRESSION res/graphics/*)
     67source_group(res\\sound REGULAR_EXPRESSION res/sound/*)
     68source_group(res\\_files REGULAR_EXPRESSION res/*)
     69source_group(sysdep\\arch\\amd64 REGULAR_EXPRESSION sysdep/arch/amd64/*)
     70source_group(sysdep\\arch\\ia32 REGULAR_EXPRESSION sysdep/arch/ia32/*)
     71source_group(sysdep\\arch\\x86_64 REGULAR_EXPRESSION sysdep/arch/x86_64/*)
     72source_group(sysdep\\os\\linux REGULAR_EXPRESSION sysdep/os/linux/*)
     73source_group(sysdep\\os\\osx REGULAR_EXPRESSION sysdep/os/osx/*)
     74source_group(sysdep\\os\\unix\\x REGULAR_EXPRESSION sysdep/os/unix/x/*)
     75source_group(sysdep\\os\\unix\\_files REGULAR_EXPRESSION sysdep/os/unix/*)
     76source_group(sysdep\\os\\win\\whrt REGULAR_EXPRESSION sysdep/os/win/whrt/*)
     77source_group(sysdep\\os\\win\\wposix REGULAR_EXPRESSION sysdep/os/win/wposix/*)
     78source_group(sysdep\\os\\win\\_files REGULAR_EXPRESSION sysdep/os/win/*)
     79source_group(sysdep\\os\\rtl\\gcc REGULAR_EXPRESSION sysdep/os/rtl/gcc/*)
     80source_group(sysdep\\os\\rtl\\msc REGULAR_EXPRESSION sysdep/os/rtl/msc/*)
     81source_group(tex REGULAR_EXPRESSION tex/*)
     82
     83# Append platform-dependent sources:
     84
     85if (TARGET_IA32)
     86  set(SRC ${SRC} ${SRC_IA32})
     87endif (TARGET_IA32)
     88
     89if (TARGET_AMD64)
     90  set(SRC ${SRC} ${SRC_AMD64})
     91endif (TARGET_AMD64)
     92
     93if (WIN32)
     94  set(SRC ${SRC} ${SRC_WIN})
     95elseif (APPLE)
     96  set(SRC ${SRC} ${SRC_OSX})
     97else (APPLE)
     98  set(SRC ${SRC} ${SRC_LINUX})
     99endif (WIN32)
     100
     101
     102ps_add_pch_library(lib lowlevel "${SRC};sysdep/arch/ia32/ia32_asm.asm")
     103ps_add_dependencies(lib "Boost;CXXTEST;JPEG;OGG;OPENAL;OPENGL;PNG;SDL;VALGRIND;VORBIS;ZLIB")
     104if (UNIX)
     105  include_directories(${X11_INCLUDE_DIR}/X11) # TODO: we shouldn't need this "/X11"
     106endif (UNIX)
     107
     108
     109# NASM and PCH compile flags don't mix well, so compile the .asm files as a
     110# separate library:
     111
     112enable_language(ASM_NASM)
     113
     114if (TARGET_IA32)
     115  #add_library(libasm sysdep/arch/ia32/ia32_asm.asm)
     116endif (TARGET_IA32)
     117
     118if (TARGET_AMD64)
     119  #add_library(libasm sysdep/arch/amd64/amd64_asm.asm)
     120endif (TARGET_AMD64)
     121
     122# The amd64 asm files include "../ia32/something", but CMake always removes
     123# trailing slashes from include paths while NASM concatenates relative paths
     124# without adding an extra "/", so we explicitly define an extra include path
     125# (with trailing slash) to make it happy. (We do this even on ia32 since it's
     126# harmless there.)
     127#set_target_properties(libasm PROPERTIES COMPILE_FLAGS "-i${CMAKE_CURRENT_SOURCE_DIR}/sysdep/arch/amd64/")
     128SET(CMAKE_ASM_NASM_COMPILE_OBJECT "<CMAKE_ASM_NASM_COMPILER> -i${CMAKE_CURRENT_SOURCE_DIR}/sysdep/arch/ia32/ -f win32 -o <OBJECT> <SOURCE>")
  • source/lib/external_libraries/enet.h

    diff -r 27195836057e source/lib/external_libraries/enet.h
    a b  
    3939
    4040#define _WINSOCK2API_   // winsock2.h include guard
    4141
    42 #define WIN32
     42#ifndef WIN32
     43# define WIN32
     44#endif
    4345
    4446#endif  // OS_WIN
    4547
  • source/lib/sysdep/arch/ia32/ia32.inc

    diff -r 27195836057e source/lib/sysdep/arch/ia32/ia32.inc
    a b  
     1%ifnidn __OUTPUT_FORMAT__,win32
     2%define OS_UNIX
     3%endif
     4
    15; disable executable stack
    26%ifidn __OUTPUT_FORMAT__,elf
    37section .note.GNU-stack noalloc noexec nowrite progbits
     
    1721; Usage:
    1822; use sym(ia32_cap) instead of _ia32_cap - on relevant platforms, sym() will add
    1923; the underlines automagically, on others it won't
    20 %ifdef DONT_USE_UNDERLINE
     24%ifidn __OUTPUT_FORMAT__,win32
     25%define sym(a) _ %+ a
     26%elifidn __OUTPUT_FORMAT__,macho
     27%define sym(a) _ %+ a
     28%elifidn __OUTPUT_FORMAT__,macho64
     29%define sym(a) _ %+ a
     30%else
    2131%define sym(a) a
    22 %else
    23 %define sym(a) _ %+ a
    2432%endif
  • new file source/maths/CMakeLists.txt

    diff -r 27195836057e source/maths/CMakeLists.txt
    - +  
     1file(GLOB SRC
     2  *.cpp *.h
     3  scripting/*.cpp scripting/*.h
     4)
     5
     6ps_add_pch_library(maths engine "${SRC}")
     7ps_add_dependencies(maths "Boost;OPENGL;SPIDERMONKEY")
  • new file source/mocks/CMakeLists.txt

    diff -r 27195836057e source/mocks/CMakeLists.txt
    - +  
     1file(GLOB SRC_REAL
     2  mocks_real.cpp *.h
     3)
     4
     5file(GLOB SRC_TEST
     6  mocks_test.cpp *.h
     7)
     8
     9add_library(mocks_real ${SRC_REAL})
     10ps_add_dependencies(mocks_real "Boost;CXXTEST")
     11
     12add_library(mocks_test ${SRC_TEST})
     13ps_add_dependencies(mocks_test "Boost;CXXTEST")
  • new file source/network/CMakeLists.txt

    diff -r 27195836057e source/network/CMakeLists.txt
    - +  
     1file(GLOB SRC
     2  *.cpp *.h
     3)
     4
     5ps_add_pch_library(network network "${SRC}")
     6ps_add_dependencies(network "Boost;ENet;SPIDERMONKEY")
  • source/pch/engine/precompiled.h

    diff -r 27195836057e source/pch/engine/precompiled.h
    a b  
    2727// .. CStr is included very frequently, so a reasonable amount of time is
    2828//    saved by including it here. (~10% in a full rebuild, as of r2365)
    2929#include "ps/CStr.h"
    30 #include "scripting/SpiderMonkey.h"
    3130#include <boost/shared_ptr.hpp>
    3231#include <boost/weak_ptr.hpp>
    3332
  • new file source/ps/CMakeLists.txt

    diff -r 27195836057e source/ps/CMakeLists.txt
    - +  
     1file(GLOB SRC
     2  *.cpp *.h
     3  GameSetup/*.cpp GameSetup/*.h
     4  scripting/*.cpp scripting/*.h
     5  XML/*.cpp XML/*.h
     6)
     7
     8ps_add_pch_library(ps engine "${SRC}")
     9ps_add_dependencies(ps "Boost;CURL;LIBXML2;OPENGL;SDL;SPIDERMONKEY;ZLIB")
  • source/ps/Preprocessor.cpp

    diff -r 27195836057e source/ps/Preprocessor.cpp
    a b  
    763763        }
    764764    }
    765765
    766     uint len = oArg.Length;
     766    unsigned int len = oArg.Length;
    767767    while (true)
    768768    {
    769769        Token t = GetToken (iExpand);
  • new file source/renderer/CMakeLists.txt

    diff -r 27195836057e source/renderer/CMakeLists.txt
    - +  
     1file(GLOB SRC
     2  *.cpp *.h
     3)
     4
     5ps_add_pch_library(renderer graphics "${SRC}")
     6ps_add_dependencies(renderer "Boost;OPENGL;SPIDERMONKEY")
  • new file source/scripting/CMakeLists.txt

    diff -r 27195836057e source/scripting/CMakeLists.txt
    - +  
     1file(GLOB SRC
     2  *.cpp *.h
     3)
     4
     5ps_add_pch_library(scripting engine "${SRC}")
     6ps_add_dependencies(scripting "Boost;OPENGL;SDL;SPIDERMONKEY")
  • new file source/scriptinterface/CMakeLists.txt

    diff -r 27195836057e source/scriptinterface/CMakeLists.txt
    - +  
     1file(GLOB SRC
     2  *.cpp *.h
     3)
     4
     5ps_add_pch_library(scriptinterface scriptinterface "${SRC}")
     6ps_add_dependencies(scriptinterface "Boost;SPIDERMONKEY;VALGRIND")
  • source/scriptinterface/ScriptTypes.h

    diff -r 27195836057e source/scriptinterface/ScriptTypes.h
    a b  
    1919#define INCLUDED_SCRIPTTYPES
    2020
    2121#ifdef _WIN32
     22
    2223# define XP_WIN
    23 # define WIN32 // SpiderMonkey expects this
     24
     25# ifndef WIN32
     26#  define WIN32 // SpiderMonkey expects this
     27# endif
    2428
    2529// The jsval struct type causes crashes due to weird miscompilation
    2630// issues in (at least) VC2008, so force it to be the less-type-safe
     
    3842
    3943#include <cstring> // required by jsutil.h
    4044
     45// SpiderMonkey wants the DEBUG flag
     46#ifndef NDEBUG
     47# ifndef DEBUG
     48#  define DEBUG
     49# endif
     50#endif
     51
    4152#include "js/jsapi.h"
    4253
    4354#if JS_VERSION != 185
  • new file source/simulation2/CMakeLists.txt

    diff -r 27195836057e source/simulation2/CMakeLists.txt
    - +  
     1file(GLOB SRC
     2  *.cpp *.h
     3  components/*.cpp components/*.h
     4  helpers/*.cpp helpers/*.h
     5  scripting/*.cpp scripting/*.h
     6  serialization/*.cpp serialization/*.h
     7  system/*.cpp system/*.h
     8)
     9
     10ps_add_pch_library(simulation2 simulation2 "${SRC}")
     11ps_add_dependencies(simulation2 "Boost;OPENGL;SPIDERMONKEY")
  • new file source/sound/CMakeLists.txt

    diff -r 27195836057e source/sound/CMakeLists.txt
    - +  
     1file(GLOB SRC
     2  *.cpp *.h
     3)
     4
     5ps_add_pch_library(sound engine "${SRC}")
     6ps_add_dependencies(sound "Boost;SPIDERMONKEY")
  • new file source/tools/atlas/GameInterface/CMakeLists.txt

    diff -r 27195836057e source/tools/atlas/GameInterface/CMakeLists.txt
    - +  
     1file(GLOB SRC
     2  *.cpp *.h
     3  Handlers/*.cpp Handlers/*.h
     4)
     5
     6ps_add_pch_library(atlas atlas "${SRC}")
     7ps_add_dependencies(atlas "Boost;OPENGL;SDL;SPIDERMONKEY")