[Orxonox-commit 2429] r7138 - code/branches/presentation3/cmake
rgrieder at orxonox.net
rgrieder at orxonox.net
Thu Jun 10 01:00:59 CEST 2010
Author: rgrieder
Date: 2010-06-10 01:00:59 +0200 (Thu, 10 Jun 2010)
New Revision: 7138
Modified:
code/branches/presentation3/cmake/TargetUtilities.cmake
Log:
DEFINE_SYMBOL should now work for static linking as well.
Modified: code/branches/presentation3/cmake/TargetUtilities.cmake
===================================================================
--- code/branches/presentation3/cmake/TargetUtilities.cmake 2010-06-09 22:58:40 UTC (rev 7137)
+++ code/branches/presentation3/cmake/TargetUtilities.cmake 2010-06-09 23:00:59 UTC (rev 7138)
@@ -229,23 +229,36 @@
ENDIF()
# DEFINE_SYMBOL
- IF(_arg_DEFINE_SYMBOL)
- # Format is: static "static_symbol" shared "shared_symbol"
- # but the order doesn't matter
- LIST(LENGTH _arg_DEFINE_SYMBOL _define_symbol_length)
- IF (_define_symbol_length LESS 2)
- MESSAGE(FATAL_ERROR "Number of expected arguments for DEFINE_SYMBOL is at least 2: static \"STATIC_SYMBOL\" shared \"SHARED_SYMBOL\"")
+ IF(_arg_DEFINE_SYMBOL OR NOT _arg_ORXONOX_EXTERNAL)
+ IF(_arg_DEFINE_SYMBOL)
+ # Format is: static "static_symbol" shared "shared_symbol"
+ # but the order doesn't matter
+ LIST(LENGTH _arg_DEFINE_SYMBOL _define_symbol_length)
+ IF (_define_symbol_length LESS 2)
+ MESSAGE(FATAL_ERROR "Number of expected arguments for DEFINE_SYMBOL is at least 2: static \"STATIC_SYMBOL\" shared \"SHARED_SYMBOL\"")
+ ENDIF()
+ STRING(TOLOWER "${_arg_STATIC}${_arg_SHARED}" _static_shared_lower)
+ LIST(FIND _arg_DEFINE_SYMBOL ${_static_shared_lower} _symbol_definition_index)
+ MATH(EXPR _symbol_definition_index "${_symbol_definition_index} + 1")
+ IF(_symbol_definition_index LESS _define_symbol_length)
+ LIST(GET _arg_DEFINE_SYMBOL ${_symbol_definition_index} _symbol_definition)
+ ENDIF()
+ ELSE()
+ # Automatically add the macro definitions for our own libraries
+ SET(_symbol_definition "${_target_name_upper}_${_arg_STATIC}${_arg_SHARED}_BUILD")
ENDIF()
- STRING(TOLOWER "${_arg_STATIC}${_arg_SHARED}" _static_shared_lower)
- LIST(FIND _arg_DEFINE_SYMBOL ${_static_shared_lower} _symbol_definition_index)
- MATH(EXPR _symbol_definition_index "${_symbol_definition_index} + 1")
- IF(_symbol_definition_index LESS _define_symbol_length)
- LIST(GET _arg_DEFINE_SYMBOL ${_symbol_definition_index} _symbol_definition)
+
+ # Use the DEFINE_SYMBOL property for shared builds (not used by CMake for static builds),
+ # but if we only use COMPILE_FLAGS, CMake will define a symbol anyway.
+ IF(_arg_SHARED)
SET_TARGET_PROPERTIES(${_target_name} PROPERTIES DEFINE_SYMBOL ${_symbol_definition})
+ ELSE()
+ GET_TARGET_PROPERTY(_compile_flags ${_target_name} COMPILE_FLAGS)
+ IF(NOT _compile_flags)
+ SET(_compile_flags)
+ ENDIF()
+ SET_TARGET_PROPERTIES(${_target_name} PROPERTIES COMPILE_FLAGS "${_compile_flags} -D${_symbol_definition}")
ENDIF()
- ELSEIF(NOT _arg_ORXONOX_EXTERNAL)
- # Automatically add the macro definitions for our own libraries
- SET_TARGET_PROPERTIES(${_target_name} PROPERTIES DEFINE_SYMBOL "${_target_name_upper}_${_arg_STATIC}${_arg_SHARED}_BUILD")
ENDIF()
# VERSION
More information about the Orxonox-commit
mailing list