Changeset 7143 for code/branches/presentation3/cmake
- Timestamp:
- Jun 10, 2010, 1:44:21 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation3/cmake/tools/TargetUtilities.cmake
r7139 r7143 34 34 # NO_DLL_INTERFACE: Link statically with MSVC 35 35 # NO_SOURCE_GROUPS: Don't create msvc source groups 36 # STATIC/SHARED: Inherited from ADD_LIBRARY 37 # MODULE: For dynamic module libraries 38 # WIN32: Inherited from ADD_EXECUTABLE 36 # MODULE: For dynamic module libraries (libraries only) 37 # WIN32: Inherited from ADD_EXECUTABLE (executables only) 39 38 # PCH_NO_DEFAULT: Do not make precompiled header files default if 40 39 # specified with PCH_FILE … … 47 46 # SOURCE_FILES: Source files for the target 48 47 # DEFINE_SYMBOL: Sets the DEFINE_SYMBOL target property 49 # Usage: DEFINE_SYMBOL static "symbol" shared "symbol2"50 # (or shared "symbol2" static "symbol")51 48 # TOLUA_FILES: Files with tolua interface 52 49 # PCH_FILE: Precompiled header file … … 71 68 72 69 MACRO(ORXONOX_ADD_LIBRARY _target_name) 73 TU_ADD_TARGET(${_target_name} LIBRARY " STATIC;SHARED" ${ARGN})70 TU_ADD_TARGET(${_target_name} LIBRARY "MODULE" ${ARGN}) 74 71 ENDMACRO(ORXONOX_ADD_LIBRARY) 75 72 … … 85 82 # Specify all possible options (either switch or with add. arguments) 86 83 SET(_switches FIND_HEADER_FILES EXCLUDE_FROM_ALL ORXONOX_EXTERNAL 87 NO_DLL_INTERFACE NO_SOURCE_GROUPS ${_additional_switches}88 PCH_NO_DEFAULT NO_INSTALL MODULE NO_VERSION)84 NO_DLL_INTERFACE NO_SOURCE_GROUPS PCH_NO_DEFAULT 85 NO_INSTALL NO_VERSION ${_additional_switches}) 89 86 SET(_list_names LINK_LIBRARIES VERSION SOURCE_FILES DEFINE_SYMBOL 90 TOLUA_FILES PCH_FILE PCH_EXCLUDE OUTPUT_NAME)87 TOLUA_FILES PCH_FILE PCH_EXCLUDE OUTPUT_NAME) 91 88 PARSE_MACRO_ARGUMENTS("${_switches}" "${_list_names}" ${ARGN}) 92 89 … … 149 146 ENDIF() 150 147 151 # Certain libraries don't have dllexport/dllimport and can't be linked shared with msvc148 # Set link mode (SHARED/STATIC) 152 149 IF(MSVC AND _arg_NO_DLL_INTERFACE) 153 SET(_arg_SHARED) 154 SET(_arg_STATIC STATIC) 150 # Certain libraries don't have dllexport/dllimport and can't be linked shared with MSVC 151 SET(_link_mode STATIC) 152 ELSEIF(_arg_ORXONOX_EXTERNAL) 153 # Externals can be linked shared or statically 154 SET(_link_mode ${ORXONOX_EXTERNAL_LINK_MODE}) 155 ELSE() 156 # All our own libraries are linked dynamically because of static symbols 157 SET(_link_mode SHARED) 155 158 ENDIF() 156 159 … … 161 164 ENDIF() 162 165 163 # Set default linking if required164 IF(NOT _arg_SHARED AND NOT _arg_STATIC)165 IF("${ORXONOX_DEFAULT_LINK}" STREQUAL "STATIC")166 SET(_arg_STATIC STATIC)167 ELSEIF("${ORXONOX_DEFAULT_LINK}" STREQUAL "SHARED")168 SET(_arg_SHARED SHARED)169 ENDIF()170 ENDIF()171 172 # MODULE A173 # Always create shared libraries174 IF(_arg_MODULE)175 SET(_arg_SHARED SHARED)176 SET(_arg_STATIC)177 ENDIF()178 179 166 # Don't compile header files 180 167 FOREACH(_file ${_${_target_name}_files}) … … 188 175 # Add the library/executable 189 176 IF("${_target_type}" STREQUAL "LIBRARY") 190 ADD_LIBRARY(${_target_name} ${_ arg_STATIC} ${_arg_SHARED}177 ADD_LIBRARY(${_target_name} ${_link_mode} 191 178 ${_arg_EXCLUDE_FROM_ALL} ${_${_target_name}_files}) 192 179 ELSE() … … 215 202 ENDIF() 216 203 217 # MODULE B204 # Configure modules 218 205 IF (_arg_MODULE) 219 206 SET_TARGET_PROPERTIES(${_target_name} PROPERTIES … … 230 217 231 218 # DEFINE_SYMBOL 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) 254 SET_TARGET_PROPERTIES(${_target_name} PROPERTIES DEFINE_SYMBOL ${_symbol_definition}) 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() 219 IF(_arg_DEFINE_SYMBOL) 220 SET_TARGET_PROPERTIES(${_target_name} PROPERTIES DEFINE_SYMBOL ${_arg_DEFINE_SYMBOL}) 221 ELSEIF(NOT _arg_ORXONOX_EXTERNAL) 222 # Automatically add the macro definitions for our own libraries 223 SET_TARGET_PROPERTIES(${_target_name} PROPERTIES DEFINE_SYMBOL "${_target_name_upper}_SHARED_BUILD") 262 224 ENDIF() 263 225 … … 279 241 ENDIF() 280 242 281 IF((${_target_type} STREQUAL "EXECUTABLE" OR NOT _arg_STATIC) AND NOT _arg_NO_INSTALL) 243 # Install all targets except for static ones (executables also have SHARED in _link_mode) 244 IF((${_link_mode} STREQUAL "SHARED") AND NOT _arg_NO_INSTALL) 282 245 IF(_arg_MODULE) 283 246 INSTALL(TARGETS ${_target_name}
Note: See TracChangeset
for help on using the changeset viewer.