Index: code/branches/presentation3/cmake/tools/TargetUtilities.cmake
===================================================================
--- code/branches/presentation3/cmake/tools/TargetUtilities.cmake	(revision 7139)
+++ code/branches/presentation3/cmake/tools/TargetUtilities.cmake	(revision 7143)
@@ -34,7 +34,6 @@
  #      NO_DLL_INTERFACE:  Link statically with MSVC
  #      NO_SOURCE_GROUPS:  Don't create msvc source groups
- #      STATIC/SHARED:     Inherited from ADD_LIBRARY
- #      MODULE:            For dynamic module libraries
- #      WIN32:             Inherited from ADD_EXECUTABLE
+ #      MODULE:            For dynamic module libraries (libraries only)
+ #      WIN32:             Inherited from ADD_EXECUTABLE (executables only)
  #      PCH_NO_DEFAULT:    Do not make precompiled header files default if
  #                         specified with PCH_FILE
@@ -47,6 +46,4 @@
  #      SOURCE_FILES:      Source files for the target
  #      DEFINE_SYMBOL:     Sets the DEFINE_SYMBOL target property
- #                         Usage: DEFINE_SYMBOL static "symbol" shared "symbol2"
- #                         (or shared "symbol2" static "symbol")
  #      TOLUA_FILES:       Files with tolua interface
  #      PCH_FILE:          Precompiled header file
@@ -71,5 +68,5 @@
 
 MACRO(ORXONOX_ADD_LIBRARY _target_name)
-  TU_ADD_TARGET(${_target_name} LIBRARY "STATIC;SHARED" ${ARGN})
+  TU_ADD_TARGET(${_target_name} LIBRARY "MODULE" ${ARGN})
 ENDMACRO(ORXONOX_ADD_LIBRARY)
 
@@ -85,8 +82,8 @@
   # Specify all possible options (either switch or with add. arguments)
   SET(_switches   FIND_HEADER_FILES  EXCLUDE_FROM_ALL  ORXONOX_EXTERNAL
-                  NO_DLL_INTERFACE   NO_SOURCE_GROUPS  ${_additional_switches}
-                  PCH_NO_DEFAULT     NO_INSTALL        MODULE NO_VERSION)
+                  NO_DLL_INTERFACE   NO_SOURCE_GROUPS  PCH_NO_DEFAULT 
+                  NO_INSTALL         NO_VERSION        ${_additional_switches})
   SET(_list_names LINK_LIBRARIES  VERSION   SOURCE_FILES  DEFINE_SYMBOL
-                  TOLUA_FILES     PCH_FILE  PCH_EXCLUDE OUTPUT_NAME)
+                  TOLUA_FILES     PCH_FILE  PCH_EXCLUDE   OUTPUT_NAME)
   PARSE_MACRO_ARGUMENTS("${_switches}" "${_list_names}" ${ARGN})
 
@@ -149,8 +146,14 @@
   ENDIF()
 
-  # Certain libraries don't have dllexport/dllimport and can't be linked shared with msvc
+  # Set link mode (SHARED/STATIC)
   IF(MSVC AND _arg_NO_DLL_INTERFACE)
-    SET(_arg_SHARED)
-    SET(_arg_STATIC STATIC)
+    # Certain libraries don't have dllexport/dllimport and can't be linked shared with MSVC
+    SET(_link_mode STATIC)
+  ELSEIF(_arg_ORXONOX_EXTERNAL)
+    # Externals can be linked shared or statically
+    SET(_link_mode ${ORXONOX_EXTERNAL_LINK_MODE})
+  ELSE()
+    # All our own libraries are linked dynamically because of static symbols
+    SET(_link_mode SHARED)
   ENDIF()
 
@@ -161,20 +164,4 @@
   ENDIF()
 
-  # Set default linking if required
-  IF(NOT _arg_SHARED AND NOT _arg_STATIC)
-    IF("${ORXONOX_DEFAULT_LINK}" STREQUAL "STATIC")
-      SET(_arg_STATIC STATIC)
-    ELSEIF("${ORXONOX_DEFAULT_LINK}" STREQUAL "SHARED")
-      SET(_arg_SHARED SHARED)
-    ENDIF()
-  ENDIF()
-
-  # MODULE A
-  # Always create shared libraries
-  IF(_arg_MODULE)
-    SET(_arg_SHARED SHARED)
-    SET(_arg_STATIC)
-  ENDIF()
-
   # Don't compile header files
   FOREACH(_file ${_${_target_name}_files})
@@ -188,5 +175,5 @@
   # Add the library/executable
   IF("${_target_type}" STREQUAL "LIBRARY")
-    ADD_LIBRARY(${_target_name} ${_arg_STATIC} ${_arg_SHARED}
+    ADD_LIBRARY(${_target_name} ${_link_mode}
                 ${_arg_EXCLUDE_FROM_ALL} ${_${_target_name}_files})
   ELSE()
@@ -215,5 +202,5 @@
   ENDIF()
 
-  # MODULE B
+  # Configure modules
   IF (_arg_MODULE)
     SET_TARGET_PROPERTIES(${_target_name} PROPERTIES
@@ -230,34 +217,9 @@
 
   # DEFINE_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()
-
-    # 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()
+  IF(_arg_DEFINE_SYMBOL)
+    SET_TARGET_PROPERTIES(${_target_name} PROPERTIES DEFINE_SYMBOL ${_arg_DEFINE_SYMBOL})
+  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}_SHARED_BUILD")
   ENDIF()
 
@@ -279,5 +241,6 @@
   ENDIF()
 
-  IF((${_target_type} STREQUAL "EXECUTABLE" OR NOT _arg_STATIC) AND NOT _arg_NO_INSTALL)
+  # Install all targets except for static ones (executables also have SHARED in _link_mode)
+  IF((${_link_mode} STREQUAL "SHARED") AND NOT _arg_NO_INSTALL)
     IF(_arg_MODULE)
       INSTALL(TARGETS ${_target_name}
