[3116] | 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 | # Adds a library or an executable like ADD_LIBRARY/ADD_EXECUTABLE, but |
---|
| 24 | # accepts a lot more input information. Simply supply the keywords |
---|
| 25 | # described below in any order you wish. |
---|
[5693] | 26 | # The output is then stored in "_arg_ARGNAME" where ARGNAME is the the |
---|
| 27 | # name of the switch or list. |
---|
[3116] | 28 | # |
---|
| 29 | # Switches: (when given --> TRUE, FALSE otherwise) |
---|
| 30 | # FIND_HEADER_FILES: Searches the current directory for all header files |
---|
| 31 | # and adds them to the target. |
---|
| 32 | # EXCLUDE_FROM_ALL: Inherited from ADD_LIBRARY/ADD_EXECUTABLE |
---|
| 33 | # ORXONOX_EXTERNAL: Specify this for third party libraries |
---|
| 34 | # NO_DLL_INTERFACE: Link statically with MSVC |
---|
| 35 | # NO_SOURCE_GROUPS: Don't create msvc source groups |
---|
[7143] | 36 | # MODULE: For dynamic module libraries (libraries only) |
---|
| 37 | # WIN32: Inherited from ADD_EXECUTABLE (executables only) |
---|
[3117] | 38 | # PCH_NO_DEFAULT: Do not make precompiled header files default if |
---|
| 39 | # specified with PCH_FILE |
---|
[5693] | 40 | # NO_INSTALL: Do not install the target at all |
---|
[7123] | 41 | # NO_VERSION: Prevents adding any version to a target |
---|
[5693] | 42 | # |
---|
[3116] | 43 | # Lists: |
---|
| 44 | # LINK_LIBRARIES: Redirects to TARGET_LINK_LIBRARIES |
---|
[8351] | 45 | # LINK_LIBS_LINUX: Redirects to TARGET_LINK_LIBRARIES only on Linux |
---|
| 46 | # LINK_LIBS_WIN32: Redirects to TARGET_LINK_LIBRARIES only on Windows |
---|
| 47 | # LINK_LIBS_APPLE: Redirects to TARGET_LINK_LIBRARIES only on Apple |
---|
| 48 | # LINK_LIBS_UNIX: Redirects to TARGET_LINK_LIBRARIES only on UNIX |
---|
[3116] | 49 | # VERSION: Set version to the binary |
---|
| 50 | # SOURCE_FILES: Source files for the target |
---|
| 51 | # DEFINE_SYMBOL: Sets the DEFINE_SYMBOL target property |
---|
| 52 | # TOLUA_FILES: Files with tolua interface |
---|
[3117] | 53 | # PCH_FILE: Precompiled header file |
---|
| 54 | # PCH_EXCLUDE: Source files to be excluded from PCH support |
---|
[5693] | 55 | # OUTPUT_NAME: If you want a different name than the target name |
---|
[3116] | 56 | # Note: |
---|
| 57 | # This function also installs the target! |
---|
| 58 | # Prerequisistes: |
---|
[8351] | 59 | # ORXONOX_DEFAULT_LINK |
---|
[3116] | 60 | # Parameters: |
---|
| 61 | # _target_name, ARGN for the macro arguments |
---|
| 62 | # |
---|
| 63 | |
---|
[8622] | 64 | INCLUDE(BuildUnits) |
---|
[5695] | 65 | INCLUDE(CMakeDependentOption) |
---|
[3116] | 66 | INCLUDE(CapitaliseName) |
---|
| 67 | INCLUDE(GenerateToluaBindings) |
---|
| 68 | INCLUDE(ParseMacroArguments) |
---|
| 69 | INCLUDE(SourceFileUtilities) |
---|
[3117] | 70 | IF(PCH_COMPILER_SUPPORT) |
---|
| 71 | INCLUDE(PrecompiledHeaderFiles) |
---|
| 72 | ENDIF() |
---|
[3116] | 73 | |
---|
[5929] | 74 | MACRO(ORXONOX_ADD_LIBRARY _target_name) |
---|
[7143] | 75 | TU_ADD_TARGET(${_target_name} LIBRARY "MODULE" ${ARGN}) |
---|
[5929] | 76 | ENDMACRO(ORXONOX_ADD_LIBRARY) |
---|
[3116] | 77 | |
---|
[5929] | 78 | MACRO(ORXONOX_ADD_EXECUTABLE _target_name) |
---|
[3116] | 79 | TU_ADD_TARGET(${_target_name} EXECUTABLE "WIN32" ${ARGN}) |
---|
[5929] | 80 | ENDMACRO(ORXONOX_ADD_EXECUTABLE) |
---|
[3116] | 81 | |
---|
| 82 | |
---|
[5929] | 83 | MACRO(TU_ADD_TARGET _target_name _target_type _additional_switches) |
---|
[3116] | 84 | CAPITALISE_NAME(${_target_name} _target_name_capitalised) |
---|
[7132] | 85 | STRING(TOUPPER "${_target_name}" _target_name_upper) |
---|
[3116] | 86 | |
---|
| 87 | # Specify all possible options (either switch or with add. arguments) |
---|
| 88 | SET(_switches FIND_HEADER_FILES EXCLUDE_FROM_ALL ORXONOX_EXTERNAL |
---|
[7143] | 89 | NO_DLL_INTERFACE NO_SOURCE_GROUPS PCH_NO_DEFAULT |
---|
| 90 | NO_INSTALL NO_VERSION ${_additional_switches}) |
---|
[7415] | 91 | SET(_list_names LINK_LIBRARIES VERSION SOURCE_FILES |
---|
| 92 | DEFINE_SYMBOL TOLUA_FILES PCH_FILE |
---|
[8351] | 93 | PCH_EXCLUDE OUTPUT_NAME LINK_LIBS_LINUX |
---|
| 94 | LINK_LIBS_WIN32 LINK_LIBS_APPLE LINK_LIBS_UNIX) |
---|
[7415] | 95 | |
---|
[3116] | 96 | PARSE_MACRO_ARGUMENTS("${_switches}" "${_list_names}" ${ARGN}) |
---|
| 97 | |
---|
[8558] | 98 | # Process source files with support for build units |
---|
[7818] | 99 | # Note: All file paths are relative to the root source directory, even the |
---|
[8558] | 100 | # name of the build unit. |
---|
[7818] | 101 | SET(_${_target_name}_source_files) |
---|
[8558] | 102 | SET(_get_build_unit_file FALSE) |
---|
| 103 | SET(_add_to_build_unit FALSE) |
---|
[5929] | 104 | FOREACH(_file ${_arg_SOURCE_FILES}) |
---|
[8558] | 105 | IF(_file STREQUAL "BUILD_UNIT") |
---|
| 106 | # Next file is the name of the build unit |
---|
| 107 | SET(_get_build_unit_file TRUE) |
---|
| 108 | ELSEIF(_file STREQUAL "END_BUILD_UNIT") |
---|
| 109 | IF(NOT _build_unit_file) |
---|
| 110 | MESSAGE(FATAL_ERROR "No name provided for build unit") |
---|
[7818] | 111 | ENDIF() |
---|
[8569] | 112 | IF(ENABLE_BUILD_UNITS) |
---|
[8558] | 113 | IF(NOT _build_unit_include_string) |
---|
| 114 | MESSAGE(STATUS "Warning: Empty build unit!") |
---|
[8351] | 115 | ENDIF() |
---|
[8558] | 116 | IF(EXISTS ${_build_unit_file}) |
---|
| 117 | FILE(READ ${_build_unit_file} _include_string_file) |
---|
[7818] | 118 | ENDIF() |
---|
[8558] | 119 | IF(NOT _build_unit_include_string STREQUAL "${_include_string_file}") |
---|
| 120 | FILE(WRITE ${_build_unit_file} "${_build_unit_include_string}") |
---|
[7818] | 121 | ENDIF() |
---|
[8558] | 122 | LIST(APPEND _${_target_name}_source_files ${_build_unit_file}) |
---|
[8622] | 123 | LIST(APPEND _${_target_name}_build_units ${_build_unit_file}) |
---|
| 124 | # Store the number of files included. May be used for full build units. |
---|
| 125 | SET_SOURCE_FILES_PROPERTIES(${_build_unit_file} |
---|
| 126 | PROPERTIES BUILD_UNIT_SIZE "${_build_unit_count}") |
---|
[7818] | 127 | ENDIF() |
---|
[8558] | 128 | SET(_add_to_build_unit FALSE) |
---|
| 129 | ELSEIF(_get_build_unit_file) |
---|
[8622] | 130 | # Note: ${_file} is relative to the binary directory |
---|
[8558] | 131 | SET(_build_unit_file ${CMAKE_BINARY_DIR}/${_file}) |
---|
| 132 | SET(_get_build_unit_file FALSE) |
---|
| 133 | SET(_add_to_build_unit TRUE) |
---|
| 134 | SET(_build_unit_include_string) |
---|
[8622] | 135 | SET(_build_unit_count "0") |
---|
[5929] | 136 | ELSE() |
---|
[7818] | 137 | # Default, add source file |
---|
| 138 | |
---|
| 139 | # Prepare relative paths |
---|
| 140 | IF(NOT _file MATCHES "^(.\\:|\\/)") |
---|
| 141 | # Path can be relative to the current source directory if the file was |
---|
| 142 | # not added with the source file macros. Otherwise there is a "./" at |
---|
| 143 | # the beginning of each file and the filename is relative |
---|
| 144 | # to the CMAKE_SOURCE_DIR |
---|
| 145 | STRING(REGEX REPLACE "^\\.\\/(.+)$" "\\1" _temp ${_file}) |
---|
| 146 | IF(NOT ${_temp} STREQUAL ${_file}) |
---|
| 147 | SET(_file ${CMAKE_SOURCE_DIR}/${_temp}) |
---|
| 148 | ELSE() |
---|
| 149 | SET(_file ${CMAKE_CURRENT_SOURCE_DIR}/${_file}) |
---|
| 150 | ENDIF() |
---|
| 151 | ENDIF() |
---|
| 152 | |
---|
[5929] | 153 | LIST(APPEND _${_target_name}_source_files ${_file}) |
---|
[7818] | 154 | |
---|
[8558] | 155 | # Handle build units |
---|
[8569] | 156 | IF(_add_to_build_unit AND ENABLE_BUILD_UNITS) |
---|
[7818] | 157 | IF(_file MATCHES "\\.(c|cc|cpp|cxx)$") |
---|
[8558] | 158 | SET(_build_unit_include_string "${_build_unit_include_string}#include \"${_file}\"\n") |
---|
[8622] | 159 | MATH(EXPR _build_unit_count "1 + ${_build_unit_count}") |
---|
[7818] | 160 | ENDIF() |
---|
| 161 | # Don't compile these files, even if they are source files |
---|
| 162 | SET_SOURCE_FILES_PROPERTIES(${_file} PROPERTIES HEADER_FILE_ONLY TRUE) |
---|
| 163 | ENDIF() |
---|
[5929] | 164 | ENDIF() |
---|
| 165 | ENDFOREACH(_file) |
---|
| 166 | |
---|
| 167 | # Assemble all header files of the library |
---|
[3116] | 168 | IF(_arg_FIND_HEADER_FILES) |
---|
[5929] | 169 | GET_ALL_HEADER_FILES(_${_target_name}_header_files) |
---|
[3116] | 170 | ENDIF() |
---|
| 171 | |
---|
[7415] | 172 | # Combine source and header files |
---|
| 173 | SET(_${_target_name}_files |
---|
| 174 | ${_${_target_name}_header_files} |
---|
| 175 | ${_${_target_name}_source_files} |
---|
| 176 | ) |
---|
[3116] | 177 | # Remove potential duplicates |
---|
| 178 | LIST(REMOVE_DUPLICATES _${_target_name}_files) |
---|
| 179 | |
---|
[8622] | 180 | # Full build units |
---|
| 181 | IF(NOT _arg_ORXONOX_EXTERNAL AND ENABLE_BUILD_UNITS MATCHES "full") |
---|
| 182 | GENERATE_BUILD_UNITS(${_target_name} _${_target_name}_files) |
---|
| 183 | ENDIF() |
---|
| 184 | |
---|
[3116] | 185 | # TOLUA_FILES |
---|
| 186 | IF(_arg_TOLUA_FILES) |
---|
| 187 | GENERATE_TOLUA_BINDINGS(${_target_name_capitalised} _${_target_name}_files |
---|
| 188 | INPUTFILES ${_arg_TOLUA_FILES}) |
---|
[8351] | 189 | # Workaround for XCode: The folder where the bind files are written to has |
---|
| 190 | # to be present beforehand. |
---|
| 191 | IF(CMAKE_CONFIGURATION_TYPES) |
---|
| 192 | FOREACH(_dir ${CMAKE_CONFIGURATION_TYPES}) |
---|
| 193 | FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${_dir}) |
---|
| 194 | ENDFOREACH(_dir) |
---|
| 195 | ENDIF() |
---|
[3116] | 196 | ENDIF() |
---|
| 197 | |
---|
[3117] | 198 | # First part (pre target) of precompiled header files |
---|
[5695] | 199 | IF(PCH_COMPILER_SUPPORT AND _arg_PCH_FILE) |
---|
[3117] | 200 | # Provide convenient option to control PCH |
---|
| 201 | IF(_arg_PCH_NO_DEFAULT) |
---|
| 202 | SET(PCH_DEFAULT FALSE) |
---|
| 203 | ELSE() |
---|
| 204 | SET(PCH_DEFAULT TRUE) |
---|
| 205 | ENDIF() |
---|
[5695] | 206 | CMAKE_DEPENDENT_OPTION(PCH_ENABLE_${_target_name_upper} |
---|
| 207 | "Enable using precompiled header files for library ${_target_name}." ${PCH_DEFAULT} PCH_ENABLE OFF) |
---|
[8421] | 208 | # Almost never used individually, but produces a lot of options --> hide |
---|
| 209 | MARK_AS_ADVANCED(PCH_ENABLE_${_target_name_upper}) |
---|
[3117] | 210 | |
---|
[8623] | 211 | IF(PCH_ENABLE_${_target_name_upper} AND NOT PCH_DISABLE_${_target_name}) |
---|
[3117] | 212 | PRECOMPILED_HEADER_FILES_PRE_TARGET(${_target_name} ${_arg_PCH_FILE} _${_target_name}_files EXCLUDE ${_arg_PCH_EXCLUDE}) |
---|
| 213 | ENDIF() |
---|
| 214 | ENDIF() |
---|
| 215 | |
---|
[7415] | 216 | # Generate the source groups |
---|
| 217 | IF(MSVC AND NOT _arg_NO_SOURCE_GROUPS) |
---|
| 218 | GENERATE_SOURCE_GROUPS(${_${_target_name}_files}) |
---|
| 219 | |
---|
| 220 | IF(NOT _arg_ORXONOX_EXTERNAL) |
---|
[8351] | 221 | # Move the ...Prereqs.h and the PCH files to the 'Config' section |
---|
[7415] | 222 | IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${_target_name_capitalised}Prereqs.h) |
---|
| 223 | SOURCE_GROUP("Config" FILES ${_target_name_capitalised}Prereqs.h) |
---|
| 224 | ENDIF() |
---|
[8351] | 225 | IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${_arg_PCH_FILE}) |
---|
| 226 | SOURCE_GROUP("Config" FILES ${CMAKE_CURRENT_SOURCE_DIR}/${_arg_PCH_FILE}) |
---|
| 227 | ENDIF() |
---|
[7415] | 228 | ENDIF() |
---|
[7416] | 229 | ENDIF() |
---|
[7415] | 230 | |
---|
[7143] | 231 | # Set link mode (SHARED/STATIC) |
---|
[3116] | 232 | IF(MSVC AND _arg_NO_DLL_INTERFACE) |
---|
[7143] | 233 | # Certain libraries don't have dllexport/dllimport and can't be linked shared with MSVC |
---|
| 234 | SET(_link_mode STATIC) |
---|
| 235 | ELSEIF(_arg_ORXONOX_EXTERNAL) |
---|
| 236 | # Externals can be linked shared or statically |
---|
| 237 | SET(_link_mode ${ORXONOX_EXTERNAL_LINK_MODE}) |
---|
| 238 | ELSE() |
---|
| 239 | # All our own libraries are linked dynamically because of static symbols |
---|
| 240 | SET(_link_mode SHARED) |
---|
[3116] | 241 | ENDIF() |
---|
| 242 | |
---|
[5929] | 243 | # No warnings needed from third party libraries |
---|
| 244 | IF(_arg_ORXONOX_EXTERNAL) |
---|
| 245 | REMOVE_COMPILER_FLAGS("-W3 -W4" MSVC) |
---|
[8351] | 246 | ADD_COMPILER_FLAGS("-w" NOT MSVC) |
---|
| 247 | ADD_COMPILER_FLAGS("-W0" MSVC) |
---|
[5929] | 248 | ENDIF() |
---|
| 249 | |
---|
[5901] | 250 | # Don't compile header files |
---|
| 251 | FOREACH(_file ${_${_target_name}_files}) |
---|
[8351] | 252 | IF(NOT _file MATCHES "\\.(c|cc|cpp|cxx|mm)$") |
---|
[5901] | 253 | SET_SOURCE_FILES_PROPERTIES(${_file} PROPERTIES HEADER_FILE_ONLY TRUE) |
---|
| 254 | ENDIF() |
---|
| 255 | ENDFOREACH(_file) |
---|
| 256 | |
---|
[5963] | 257 | |
---|
| 258 | |
---|
[3116] | 259 | # Add the library/executable |
---|
| 260 | IF("${_target_type}" STREQUAL "LIBRARY") |
---|
[7143] | 261 | ADD_LIBRARY(${_target_name} ${_link_mode} |
---|
[3116] | 262 | ${_arg_EXCLUDE_FROM_ALL} ${_${_target_name}_files}) |
---|
| 263 | ELSE() |
---|
| 264 | ADD_EXECUTABLE(${_target_name} ${_arg_WIN32} ${_arg_EXCLUDE_FROM_ALL} |
---|
| 265 | ${_${_target_name}_files}) |
---|
| 266 | ENDIF() |
---|
| 267 | |
---|
[5963] | 268 | |
---|
| 269 | |
---|
[5929] | 270 | # Change library prefix to "lib" |
---|
| 271 | IF(MSVC AND ${_target_type} STREQUAL "LIBRARY") |
---|
| 272 | SET_TARGET_PROPERTIES(${_target_name} PROPERTIES |
---|
| 273 | PREFIX "lib" |
---|
| 274 | ) |
---|
| 275 | ENDIF() |
---|
| 276 | |
---|
[5963] | 277 | # MSVC hack to exclude external library sources from the intellisense database |
---|
| 278 | # (IntelliSense stops working when adding "-Zm1000" as compile flag. "/Zm1000" |
---|
| 279 | # would not work because of the slash) |
---|
| 280 | IF(_arg_ORXONOX_EXTERNAL AND MSVC) |
---|
[7137] | 281 | GET_TARGET_PROPERTY(_compile_flags ${_target_name} COMPILE_FLAGS) |
---|
| 282 | IF(NOT _compile_flags) |
---|
| 283 | SET(_compile_flags) |
---|
| 284 | ENDIF() |
---|
| 285 | SET_TARGET_PROPERTIES(${_target_name} PROPERTIES COMPILE_FLAGS "${_compile_flags} -Zm1000") |
---|
[5963] | 286 | ENDIF() |
---|
| 287 | |
---|
[7143] | 288 | # Configure modules |
---|
[5693] | 289 | IF (_arg_MODULE) |
---|
| 290 | SET_TARGET_PROPERTIES(${_target_name} PROPERTIES |
---|
| 291 | RUNTIME_OUTPUT_DIRECTORY ${CMAKE_MODULE_OUTPUT_DIRECTORY} # Windows |
---|
| 292 | LIBRARY_OUTPUT_DIRECTORY ${CMAKE_MODULE_OUTPUT_DIRECTORY} # Unix |
---|
| 293 | ) |
---|
| 294 | ADD_MODULE(${_target_name}) |
---|
[7401] | 295 | # Ensure that the main program depends on the module |
---|
[8079] | 296 | SET(ORXONOX_MODULES ${ORXONOX_MODULES} ${_target_name} CACHE INTERNAL "") |
---|
[5693] | 297 | ENDIF() |
---|
| 298 | |
---|
[7818] | 299 | # Static library flags are not globally available |
---|
| 300 | IF(ORXONOX_STATIC_LINKER_FLAGS) |
---|
| 301 | SET_TARGET_PROPERTIES(${_target_name} PROPERTIES STATIC_LIBRARY_FLAGS ${ORXONOX_STATIC_LINKER_FLAGS}) |
---|
| 302 | ENDIF() |
---|
| 303 | |
---|
[3116] | 304 | # LINK_LIBRARIES |
---|
| 305 | IF(_arg_LINK_LIBRARIES) |
---|
| 306 | TARGET_LINK_LIBRARIES(${_target_name} ${_arg_LINK_LIBRARIES}) |
---|
| 307 | ENDIF() |
---|
[8351] | 308 | IF(_arg_LINK_LIBS_LINUX AND LINUX) |
---|
| 309 | TARGET_LINK_LIBRARIES(${_target_name} ${_arg_LINK_LIBS_LINUX}) |
---|
| 310 | ENDIF() |
---|
| 311 | IF(_arg_LINK_LIBS_WIN32 AND WIN32) |
---|
| 312 | TARGET_LINK_LIBRARIES(${_target_name} ${_arg_LINK_LIBS_WIN32}) |
---|
| 313 | ENDIF() |
---|
| 314 | IF(_arg_LINK_LIBS_APPLE AND APPLE) |
---|
| 315 | TARGET_LINK_LIBRARIES(${_target_name} ${_arg_LINK_LIBS_APPLE}) |
---|
| 316 | ENDIF() |
---|
| 317 | IF(_arg_LINK_LIBS_UNIX AND UNIX) |
---|
| 318 | TARGET_LINK_LIBRARIES(${_target_name} ${_arg_LINK_LIBS_UNIX}) |
---|
| 319 | ENDIF() |
---|
[3116] | 320 | |
---|
[8409] | 321 | # Visual Leak Detector specific stuff (avoids the include) |
---|
[8412] | 322 | IF(VISUAL_LEAK_DETECTOR_ENABLE) |
---|
| 323 | TARGET_LINK_LIBRARIES(${_target_name} debug ${VLD_LIBRARY}) |
---|
[8409] | 324 | ENDIF() |
---|
| 325 | |
---|
[8351] | 326 | # RPATH settings for the installation |
---|
| 327 | IF("${_target_type}" STREQUAL "LIBRARY") |
---|
| 328 | IF(_arg_MODULE) |
---|
| 329 | SET(_rpath "${MODULE_RPATH}") |
---|
| 330 | ELSE() |
---|
| 331 | SET(_rpath "${LIBRARY_RPATH}") |
---|
| 332 | ENDIF() |
---|
| 333 | ELSE() |
---|
| 334 | SET(_rpath "${RUNTIME_RPATH}") |
---|
| 335 | ENDIF() |
---|
| 336 | SET_TARGET_PROPERTIES(${_target_name} PROPERTIES INSTALL_RPATH "${_rpath}") |
---|
| 337 | |
---|
[3116] | 338 | # DEFINE_SYMBOL |
---|
[7143] | 339 | IF(_arg_DEFINE_SYMBOL) |
---|
| 340 | SET_TARGET_PROPERTIES(${_target_name} PROPERTIES DEFINE_SYMBOL ${_arg_DEFINE_SYMBOL}) |
---|
| 341 | ELSEIF(NOT _arg_ORXONOX_EXTERNAL) |
---|
| 342 | # Automatically add the macro definitions for our own libraries |
---|
| 343 | SET_TARGET_PROPERTIES(${_target_name} PROPERTIES DEFINE_SYMBOL "${_target_name_upper}_SHARED_BUILD") |
---|
[3116] | 344 | ENDIF() |
---|
| 345 | |
---|
| 346 | # VERSION |
---|
| 347 | IF(_arg_VERSION) |
---|
| 348 | SET_TARGET_PROPERTIES(${_target_name} PROPERTIES VERSION ${_arg_VERSION}) |
---|
[7131] | 349 | ELSEIF(NOT _arg_ORXONOX_EXTERNAL AND NOT _arg_NO_VERSION AND NOT ${_target_type} STREQUAL "EXECUTABLE") |
---|
[3116] | 350 | SET_TARGET_PROPERTIES(${_target_name} PROPERTIES VERSION ${ORXONOX_VERSION}) |
---|
| 351 | ENDIF() |
---|
| 352 | |
---|
[5693] | 353 | # OUTPUT_NAME |
---|
| 354 | IF(_arg_OUTPUT_NAME) |
---|
| 355 | SET_TARGET_PROPERTIES(${_target_name} PROPERTIES OUTPUT_NAME ${_arg_OUTPUT_NAME}) |
---|
| 356 | ENDIF() |
---|
| 357 | |
---|
[3117] | 358 | # Second part of precompiled header files |
---|
[8623] | 359 | IF(PCH_COMPILER_SUPPORT AND PCH_ENABLE_${_target_name_upper} AND _arg_PCH_FILE AND NOT PCH_DISABLE_${_target_name}) |
---|
[3117] | 360 | PRECOMPILED_HEADER_FILES_POST_TARGET(${_target_name} ${_arg_PCH_FILE}) |
---|
| 361 | ENDIF() |
---|
| 362 | |
---|
[7143] | 363 | # Install all targets except for static ones (executables also have SHARED in _link_mode) |
---|
[7170] | 364 | IF(${_link_mode} STREQUAL "SHARED" AND NOT _arg_NO_INSTALL) |
---|
[5693] | 365 | IF(_arg_MODULE) |
---|
| 366 | INSTALL(TARGETS ${_target_name} |
---|
[5695] | 367 | RUNTIME DESTINATION ${MODULE_INSTALL_DIRECTORY} |
---|
| 368 | LIBRARY DESTINATION ${MODULE_INSTALL_DIRECTORY} |
---|
[5693] | 369 | ) |
---|
| 370 | ELSE() |
---|
| 371 | INSTALL(TARGETS ${_target_name} |
---|
[5695] | 372 | RUNTIME DESTINATION ${RUNTIME_INSTALL_DIRECTORY} |
---|
| 373 | LIBRARY DESTINATION ${LIBRARY_INSTALL_DIRECTORY} |
---|
[5693] | 374 | ) |
---|
| 375 | ENDIF() |
---|
[8405] | 376 | IF(INSTALL_PDB_FILES) # MSVC specific: install debug symbols files |
---|
| 377 | FOREACH(_config RelForDevs RelWithDebInfo) |
---|
| 378 | GET_TARGET_PROPERTY(_location ${_target_name} LOCATION_${_config}) |
---|
| 379 | # Get absolute location without dll/exe extension |
---|
| 380 | STRING(REGEX REPLACE "^(.+)\\.(dll|exe)$" "\\1" _location_we ${_location}) |
---|
| 381 | IF(_arg_MODULE) |
---|
| 382 | INSTALL(FILES ${_location_we}.pdb |
---|
| 383 | DESTINATION ${MODULE_INSTALL_DIRECTORY} |
---|
| 384 | CONFIGURATIONS ${_config} |
---|
| 385 | ) |
---|
| 386 | ELSE() |
---|
| 387 | INSTALL(FILES ${_location_we}.pdb |
---|
| 388 | DESTINATION ${RUNTIME_INSTALL_DIRECTORY} |
---|
| 389 | CONFIGURATIONS ${_config} |
---|
| 390 | ) |
---|
| 391 | ENDIF() |
---|
| 392 | ENDFOREACH(_config) |
---|
| 393 | ENDIF() |
---|
[3116] | 394 | ENDIF() |
---|
| 395 | |
---|
[5929] | 396 | ENDMACRO(TU_ADD_TARGET) |
---|
[5693] | 397 | |
---|
| 398 | |
---|
[5695] | 399 | # Creates a helper file with name <name_of_the_library>${ORXONOX_MODULE_EXTENSION} |
---|
[5693] | 400 | # This helps finding dynamically loadable modules at runtime |
---|
| 401 | |
---|
| 402 | FUNCTION(ADD_MODULE _target) |
---|
| 403 | # We use the properties to get the name because the librarys name may differ from |
---|
| 404 | # the target name (for example orxonox <-> liborxonox) |
---|
| 405 | |
---|
| 406 | GET_TARGET_PROPERTY(_target_loc ${_target} LOCATION) |
---|
| 407 | GET_FILENAME_COMPONENT(_target_name ${_target_loc} NAME_WE) |
---|
| 408 | |
---|
| 409 | IF(CMAKE_CONFIGURATION_TYPES) |
---|
| 410 | FOREACH(_config ${CMAKE_CONFIGURATION_TYPES}) |
---|
| 411 | SET(_module_filename ${CMAKE_MODULE_OUTPUT_DIRECTORY}/${_config}/${_target_name}${ORXONOX_MODULE_EXTENSION}) |
---|
| 412 | |
---|
| 413 | FILE(WRITE ${_module_filename}) |
---|
| 414 | |
---|
| 415 | INSTALL( |
---|
| 416 | FILES ${_module_filename} |
---|
[5695] | 417 | DESTINATION ${MODULE_INSTALL_DIRECTORY} |
---|
[5693] | 418 | CONFIGURATIONS ${_config} |
---|
| 419 | ) |
---|
| 420 | ENDFOREACH() |
---|
| 421 | ELSE() |
---|
| 422 | SET(_module_filename ${CMAKE_MODULE_OUTPUT_DIRECTORY}/${_target_name}${ORXONOX_MODULE_EXTENSION}) |
---|
| 423 | |
---|
| 424 | FILE(WRITE ${_module_filename}) |
---|
| 425 | |
---|
| 426 | INSTALL( |
---|
| 427 | FILES ${_module_filename} |
---|
[5695] | 428 | DESTINATION ${MODULE_INSTALL_DIRECTORY} |
---|
[5693] | 429 | ) |
---|
| 430 | ENDIF() |
---|
| 431 | ENDFUNCTION(ADD_MODULE) |
---|