Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 23, 2015, 11:57:53 AM (9 years ago)
Author:
landauf
Message:

added support for plugins in the buildsystem. plugins are like modules, but can be loaded/unloaded at runtime

Location:
code/branches/core7/cmake
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core7/cmake/InstallConfig.cmake

    r8405 r10547  
    4949SET(ARCHIVE_INSTALL_DIRECTORY ${DEFAULT_ARCHIVE_PATH})
    5050SET(MODULE_INSTALL_DIRECTORY  ${DEFAULT_MODULE_PATH})
     51SET(PLUGIN_INSTALL_DIRECTORY  ${DEFAULT_PLUGIN_PATH})
    5152SET(DOC_INSTALL_DIRECTORY     ${DEFAULT_DOC_PATH})
    5253SET(DATA_INSTALL_DIRECTORY    ${DEFAULT_DATA_PATH})
     
    6162    SET(ARCHIVE_INSTALL_DIRECTORY lib/games/orxonox/static)
    6263    SET(MODULE_INSTALL_DIRECTORY  lib/games/orxonox/modules)
     64    SET(PLUGIN_INSTALL_DIRECTORY  lib/games/orxonox/plugins)
    6365    SET(DOC_INSTALL_DIRECTORY     share/doc/orxonox)
    6466    SET(DATA_INSTALL_DIRECTORY    share/games/orxonox)
     
    8587# The RPATH to be used when installing
    8688IF(INSTALL_COPYABLE)
    87   # Get relative paths from run to lib and from module to lib directory.
     89  # Get relative paths from run to lib and from module/plugin to lib directory.
    8890  FILE(RELATIVE_PATH _runtime_rpath "/${RUNTIME_INSTALL_DIRECTORY}" "/${LIBRARY_INSTALL_DIRECTORY}")
    8991  FILE(RELATIVE_PATH _module_rpath  "/${MODULE_INSTALL_DIRECTORY}" "/${LIBRARY_INSTALL_DIRECTORY}")
     92  FILE(RELATIVE_PATH _plugin_rpath  "/${PLUGIN_INSTALL_DIRECTORY}" "/${LIBRARY_INSTALL_DIRECTORY}")
    9093  # $ORIGIN (with $ escaped) refers to the actual location of the library
    9194  # The UNIX loader recognises this special variable
     
    9396  SET(LIBRARY_RPATH "\$ORIGIN")
    9497  SET(MODULE_RPATH  "\$ORIGIN:\$ORIGIN/${_module_rpath}")
     98  SET(PLUGIN_RPATH  "\$ORIGIN:\$ORIGIN/${_plugin_rpath}")
    9599ELSE()
    96100  SET(RUNTIME_RPATH "${CMAKE_INSTALL_PREFIX}/${LIBRARY_INSTALL_DIRECTORY}")
    97101  SET(LIBRARY_RPATH "${CMAKE_INSTALL_PREFIX}/${LIBRARY_INSTALL_DIRECTORY}")
    98102  SET(MODULE_RPATH  "${LIBRARY_RPATH}:${CMAKE_INSTALL_PREFIX}/${MODULE_INSTALL_DIRECTORY}")
     103  SET(PLUGIN_RPATH  "${LIBRARY_RPATH}:${CMAKE_INSTALL_PREFIX}/${PLUGIN_INSTALL_DIRECTORY}")
    99104ENDIF()
    100105
  • code/branches/core7/cmake/tools/TargetUtilities.cmake

    r10267 r10547  
    3535 #      NO_SOURCE_GROUPS:  Don't create msvc source groups
    3636 #      MODULE:            For dynamic module libraries (libraries only)
     37 #      PLUGIN:            For dynamic plugin libraries (libraries only)
     38 #                         Plugins are a special kind of modules that can be
     39 #                         loaded and unloaded during runtime on demand
    3740 #      WIN32:             Inherited from ADD_EXECUTABLE (executables only)
    3841 #      PCH_NO_DEFAULT:    Do not make precompiled header files default if
     
    7780
    7881MACRO(ORXONOX_ADD_LIBRARY _target_name)
    79   TU_ADD_TARGET(${_target_name} LIBRARY "MODULE" ${ARGN})
     82  SET(_additional_switches MODULE PLUGIN)
     83  TU_ADD_TARGET(${_target_name} LIBRARY "${_additional_switches}" ${ARGN})
    8084ENDMACRO(ORXONOX_ADD_LIBRARY)
    8185
    8286MACRO(ORXONOX_ADD_EXECUTABLE _target_name)
    83   TU_ADD_TARGET(${_target_name} EXECUTABLE "WIN32" ${ARGN})
     87  SET(_additional_switches WIN32)
     88  TU_ADD_TARGET(${_target_name} EXECUTABLE "${_additional_switches}" ${ARGN})
    8489 
    8590  # When using Visual Studio we want to use the output directory as working
     
    329334      LIBRARY_OUTPUT_DIRECTORY ${CMAKE_MODULE_OUTPUT_DIRECTORY} # Unix
    330335    )
    331     ADD_MODULE(${_target_name})
     336    ADD_MODULE_OR_PLUGIN(${_target_name} ${CMAKE_MODULE_OUTPUT_DIRECTORY} ${MODULE_INSTALL_DIRECTORY} ${ORXONOX_MODULE_EXTENSION})
    332337    # Ensure that the main program depends on the module
    333338    SET(ORXONOX_MODULES ${ORXONOX_MODULES} ${_target_name} CACHE INTERNAL "")
     339  ENDIF()
     340
     341  # Configure plugins
     342  IF (_arg_PLUGIN)
     343    SET_TARGET_PROPERTIES(${_target_name} PROPERTIES
     344      RUNTIME_OUTPUT_DIRECTORY ${CMAKE_PLUGIN_OUTPUT_DIRECTORY} # Windows
     345      LIBRARY_OUTPUT_DIRECTORY ${CMAKE_PLUGIN_OUTPUT_DIRECTORY} # Unix
     346    )
     347    ADD_MODULE_OR_PLUGIN(${_target_name} ${CMAKE_PLUGIN_OUTPUT_DIRECTORY} ${PLUGIN_INSTALL_DIRECTORY} ${ORXONOX_PLUGIN_EXTENSION})
    334348  ENDIF()
    335349
     
    372386    IF(_arg_MODULE)
    373387      SET(_rpath "${MODULE_RPATH}")
     388    ELSEIF(_arg_PLUGIN)
     389      SET(_rpath "${PLUGIN_RPATH}")
    374390    ELSE()
    375391      SET(_rpath "${LIBRARY_RPATH}")
     
    411427        RUNTIME DESTINATION ${MODULE_INSTALL_DIRECTORY}
    412428        LIBRARY DESTINATION ${MODULE_INSTALL_DIRECTORY}
     429      )
     430    ELSEIF(_arg_PLUGIN)
     431      INSTALL(TARGETS ${_target_name}
     432        RUNTIME DESTINATION ${PLUGIN_INSTALL_DIRECTORY}
     433        LIBRARY DESTINATION ${PLUGIN_INSTALL_DIRECTORY}
    413434      )
    414435    ELSE()
     
    428449            CONFIGURATIONS ${_config}
    429450          )
     451        ELSEIF(_arg_PLUGIN)
     452          INSTALL(FILES ${_location_we}.pdb
     453            DESTINATION ${PLUGIN_INSTALL_DIRECTORY}
     454            CONFIGURATIONS ${_config}
     455          )
    430456        ELSE()
    431457          INSTALL(FILES ${_location_we}.pdb
     
    441467
    442468
    443 # Creates a helper file with name <name_of_the_library>${ORXONOX_MODULE_EXTENSION}
    444 # This helps finding dynamically loadable modules at runtime
    445 
    446 FUNCTION(ADD_MODULE _target)
     469# Creates a helper file with name <name_of_the_library>.<extension>
     470# This helps finding dynamically loadable modules or plugins at runtime
     471
     472FUNCTION(ADD_MODULE_OR_PLUGIN _target _output_dir _install_dir _extension)
    447473  # We use the properties to get the name because the librarys name may differ from
    448474  # the target name (for example orxonox <-> liborxonox)
     
    459485  IF(CMAKE_CONFIGURATION_TYPES)
    460486    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})
     487      SET(_helper_filename ${_output_dir}/${_config}/${_target_name}${_extension})
     488
     489      FILE(WRITE ${_helper_filename})
    464490
    465491      INSTALL(
    466         FILES ${_module_filename}
    467         DESTINATION ${MODULE_INSTALL_DIRECTORY}
     492        FILES ${_helper_filename}
     493        DESTINATION ${_install_dir}
    468494        CONFIGURATIONS ${_config}
    469495      )
    470496    ENDFOREACH()
    471497  ELSE()
    472     SET(_module_filename ${CMAKE_MODULE_OUTPUT_DIRECTORY}/${_target_name}${ORXONOX_MODULE_EXTENSION})
    473 
    474     FILE(WRITE ${_module_filename})
     498    SET(_helper_filename ${_output_dir}/${_target_name}${_extension})
     499
     500    FILE(WRITE ${_helper_filename})
    475501
    476502    INSTALL(
    477       FILES ${_module_filename}
    478       DESTINATION ${MODULE_INSTALL_DIRECTORY}
     503      FILES ${_helper_filename}
     504      DESTINATION ${_install_dir}
    479505    )
    480506  ENDIF()
    481 ENDFUNCTION(ADD_MODULE)
     507ENDFUNCTION(ADD_MODULE_OR_PLUGIN)
Note: See TracChangeset for help on using the changeset viewer.