Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 10, 2010, 1:00:59 AM (14 years ago)
Author:
rgrieder
Message:

DEFINE_SYMBOL should now work for static linking as well.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation3/cmake/TargetUtilities.cmake

    r7137 r7138  
    230230
    231231  # DEFINE_SYMBOL
    232   IF(_arg_DEFINE_SYMBOL)
    233     # Format is: static "static_symbol" shared "shared_symbol"
    234     # but the order doesn't matter
    235     LIST(LENGTH _arg_DEFINE_SYMBOL _define_symbol_length)
    236     IF (_define_symbol_length LESS 2)
    237       MESSAGE(FATAL_ERROR "Number of expected arguments for DEFINE_SYMBOL is at least 2: static \"STATIC_SYMBOL\" shared \"SHARED_SYMBOL\"")
    238     ENDIF()
    239     STRING(TOLOWER "${_arg_STATIC}${_arg_SHARED}" _static_shared_lower)
    240     LIST(FIND _arg_DEFINE_SYMBOL ${_static_shared_lower} _symbol_definition_index)
    241     MATH(EXPR _symbol_definition_index "${_symbol_definition_index} + 1")
    242     IF(_symbol_definition_index LESS _define_symbol_length)
    243       LIST(GET _arg_DEFINE_SYMBOL ${_symbol_definition_index} _symbol_definition)
     232  IF(_arg_DEFINE_SYMBOL OR NOT _arg_ORXONOX_EXTERNAL)
     233    IF(_arg_DEFINE_SYMBOL)
     234      # Format is: static "static_symbol" shared "shared_symbol"
     235      # but the order doesn't matter
     236      LIST(LENGTH _arg_DEFINE_SYMBOL _define_symbol_length)
     237      IF (_define_symbol_length LESS 2)
     238        MESSAGE(FATAL_ERROR "Number of expected arguments for DEFINE_SYMBOL is at least 2: static \"STATIC_SYMBOL\" shared \"SHARED_SYMBOL\"")
     239      ENDIF()
     240      STRING(TOLOWER "${_arg_STATIC}${_arg_SHARED}" _static_shared_lower)
     241      LIST(FIND _arg_DEFINE_SYMBOL ${_static_shared_lower} _symbol_definition_index)
     242      MATH(EXPR _symbol_definition_index "${_symbol_definition_index} + 1")
     243      IF(_symbol_definition_index LESS _define_symbol_length)
     244        LIST(GET _arg_DEFINE_SYMBOL ${_symbol_definition_index} _symbol_definition)
     245      ENDIF()
     246    ELSE()
     247      # Automatically add the macro definitions for our own libraries
     248      SET(_symbol_definition "${_target_name_upper}_${_arg_STATIC}${_arg_SHARED}_BUILD")
     249    ENDIF()
     250
     251    # Use the DEFINE_SYMBOL property for shared builds (not used by CMake for static builds),
     252    # but if we only use COMPILE_FLAGS, CMake will define a symbol anyway.
     253    IF(_arg_SHARED)
    244254      SET_TARGET_PROPERTIES(${_target_name} PROPERTIES DEFINE_SYMBOL ${_symbol_definition})
    245     ENDIF()
    246   ELSEIF(NOT _arg_ORXONOX_EXTERNAL)
    247     # Automatically add the macro definitions for our own libraries
    248     SET_TARGET_PROPERTIES(${_target_name} PROPERTIES DEFINE_SYMBOL "${_target_name_upper}_${_arg_STATIC}${_arg_SHARED}_BUILD")
     255    ELSE()
     256      GET_TARGET_PROPERTY(_compile_flags ${_target_name} COMPILE_FLAGS)
     257      IF(NOT _compile_flags)
     258        SET(_compile_flags)
     259      ENDIF()
     260      SET_TARGET_PROPERTIES(${_target_name} PROPERTIES COMPILE_FLAGS "${_compile_flags} -D${_symbol_definition}")
     261    ENDIF()
    249262  ENDIF()
    250263
Note: See TracChangeset for help on using the changeset viewer.