Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/cmake/tools/TargetUtilities.cmake @ 10619

Last change on this file since 10619 was 10267, checked in by muemart, 10 years ago

Add program icon for Windows builds (MSVC only for now)

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