Changeset 10547
- Timestamp:
- Aug 23, 2015, 11:57:53 AM (9 years ago)
- Location:
- code/branches/core7
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core7/CMakeLists.txt
r9550 r10547 65 65 SET(DEFAULT_ARCHIVE_PATH lib/static) 66 66 SET(DEFAULT_MODULE_PATH lib/modules) 67 SET(DEFAULT_PLUGIN_PATH lib/plugins) 67 68 SET(DEFAULT_DOC_PATH doc) 68 69 SET(DEFAULT_DATA_PATH data) … … 76 77 SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_ARCHIVE_PATH}) 77 78 SET(CMAKE_MODULE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_MODULE_PATH}) 79 SET(CMAKE_PLUGIN_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_PLUGIN_PATH}) 78 80 SET(CMAKE_DOC_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_DOC_PATH}) 79 81 # Data directories are only inputs, no delclaration here … … 83 85 # Set the extension of the dynamic modules 84 86 SET(ORXONOX_MODULE_EXTENSION ".module") 87 SET(ORXONOX_PLUGIN_EXTENSION ".plugin") 85 88 86 89 # Sets where to find the external libraries like OgreMain.dll at runtime -
code/branches/core7/cmake/InstallConfig.cmake
r8405 r10547 49 49 SET(ARCHIVE_INSTALL_DIRECTORY ${DEFAULT_ARCHIVE_PATH}) 50 50 SET(MODULE_INSTALL_DIRECTORY ${DEFAULT_MODULE_PATH}) 51 SET(PLUGIN_INSTALL_DIRECTORY ${DEFAULT_PLUGIN_PATH}) 51 52 SET(DOC_INSTALL_DIRECTORY ${DEFAULT_DOC_PATH}) 52 53 SET(DATA_INSTALL_DIRECTORY ${DEFAULT_DATA_PATH}) … … 61 62 SET(ARCHIVE_INSTALL_DIRECTORY lib/games/orxonox/static) 62 63 SET(MODULE_INSTALL_DIRECTORY lib/games/orxonox/modules) 64 SET(PLUGIN_INSTALL_DIRECTORY lib/games/orxonox/plugins) 63 65 SET(DOC_INSTALL_DIRECTORY share/doc/orxonox) 64 66 SET(DATA_INSTALL_DIRECTORY share/games/orxonox) … … 85 87 # The RPATH to be used when installing 86 88 IF(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. 88 90 FILE(RELATIVE_PATH _runtime_rpath "/${RUNTIME_INSTALL_DIRECTORY}" "/${LIBRARY_INSTALL_DIRECTORY}") 89 91 FILE(RELATIVE_PATH _module_rpath "/${MODULE_INSTALL_DIRECTORY}" "/${LIBRARY_INSTALL_DIRECTORY}") 92 FILE(RELATIVE_PATH _plugin_rpath "/${PLUGIN_INSTALL_DIRECTORY}" "/${LIBRARY_INSTALL_DIRECTORY}") 90 93 # $ORIGIN (with $ escaped) refers to the actual location of the library 91 94 # The UNIX loader recognises this special variable … … 93 96 SET(LIBRARY_RPATH "\$ORIGIN") 94 97 SET(MODULE_RPATH "\$ORIGIN:\$ORIGIN/${_module_rpath}") 98 SET(PLUGIN_RPATH "\$ORIGIN:\$ORIGIN/${_plugin_rpath}") 95 99 ELSE() 96 100 SET(RUNTIME_RPATH "${CMAKE_INSTALL_PREFIX}/${LIBRARY_INSTALL_DIRECTORY}") 97 101 SET(LIBRARY_RPATH "${CMAKE_INSTALL_PREFIX}/${LIBRARY_INSTALL_DIRECTORY}") 98 102 SET(MODULE_RPATH "${LIBRARY_RPATH}:${CMAKE_INSTALL_PREFIX}/${MODULE_INSTALL_DIRECTORY}") 103 SET(PLUGIN_RPATH "${LIBRARY_RPATH}:${CMAKE_INSTALL_PREFIX}/${PLUGIN_INSTALL_DIRECTORY}") 99 104 ENDIF() 100 105 -
code/branches/core7/cmake/tools/TargetUtilities.cmake
r10267 r10547 35 35 # NO_SOURCE_GROUPS: Don't create msvc source groups 36 36 # 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 37 40 # WIN32: Inherited from ADD_EXECUTABLE (executables only) 38 41 # PCH_NO_DEFAULT: Do not make precompiled header files default if … … 77 80 78 81 MACRO(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}) 80 84 ENDMACRO(ORXONOX_ADD_LIBRARY) 81 85 82 86 MACRO(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}) 84 89 85 90 # When using Visual Studio we want to use the output directory as working … … 329 334 LIBRARY_OUTPUT_DIRECTORY ${CMAKE_MODULE_OUTPUT_DIRECTORY} # Unix 330 335 ) 331 ADD_MODULE (${_target_name})336 ADD_MODULE_OR_PLUGIN(${_target_name} ${CMAKE_MODULE_OUTPUT_DIRECTORY} ${MODULE_INSTALL_DIRECTORY} ${ORXONOX_MODULE_EXTENSION}) 332 337 # Ensure that the main program depends on the module 333 338 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}) 334 348 ENDIF() 335 349 … … 372 386 IF(_arg_MODULE) 373 387 SET(_rpath "${MODULE_RPATH}") 388 ELSEIF(_arg_PLUGIN) 389 SET(_rpath "${PLUGIN_RPATH}") 374 390 ELSE() 375 391 SET(_rpath "${LIBRARY_RPATH}") … … 411 427 RUNTIME DESTINATION ${MODULE_INSTALL_DIRECTORY} 412 428 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} 413 434 ) 414 435 ELSE() … … 428 449 CONFIGURATIONS ${_config} 429 450 ) 451 ELSEIF(_arg_PLUGIN) 452 INSTALL(FILES ${_location_we}.pdb 453 DESTINATION ${PLUGIN_INSTALL_DIRECTORY} 454 CONFIGURATIONS ${_config} 455 ) 430 456 ELSE() 431 457 INSTALL(FILES ${_location_we}.pdb … … 441 467 442 468 443 # Creates a helper file with name <name_of_the_library> ${ORXONOX_MODULE_EXTENSION}444 # This helps finding dynamically loadable modules at runtime445 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 472 FUNCTION(ADD_MODULE_OR_PLUGIN _target _output_dir _install_dir _extension) 447 473 # We use the properties to get the name because the librarys name may differ from 448 474 # the target name (for example orxonox <-> liborxonox) … … 459 485 IF(CMAKE_CONFIGURATION_TYPES) 460 486 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}) 464 490 465 491 INSTALL( 466 FILES ${_ module_filename}467 DESTINATION ${ MODULE_INSTALL_DIRECTORY}492 FILES ${_helper_filename} 493 DESTINATION ${_install_dir} 468 494 CONFIGURATIONS ${_config} 469 495 ) 470 496 ENDFOREACH() 471 497 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}) 475 501 476 502 INSTALL( 477 FILES ${_ module_filename}478 DESTINATION ${ MODULE_INSTALL_DIRECTORY}503 FILES ${_helper_filename} 504 DESTINATION ${_install_dir} 479 505 ) 480 506 ENDIF() 481 ENDFUNCTION(ADD_MODULE )507 ENDFUNCTION(ADD_MODULE_OR_PLUGIN) -
code/branches/core7/src/CMakeLists.txt
r10268 r10547 39 39 ADD_SUBDIRECTORY(orxonox) 40 40 SET(ORXONOX_MODULES CACHE INTERNAL "") 41 SET(ORXONOX_PLUGINS CACHE INTERNAL "") 41 42 ADD_SUBDIRECTORY(modules) 42 43 … … 72 73 OUTPUT_NAME orxonox 73 74 ) 74 # Main executable should depend on all modules 75 # Main executable should depend on all modules (but not on plugins) 75 76 ADD_DEPENDENCIES(orxonox-main ${ORXONOX_MODULES}) 76 77 -
code/branches/core7/src/SpecialConfig.h.in
r8351 r10547 60 60 const char defaultArchivePath[] = "@DEFAULT_ARCHIVE_PATH@"; 61 61 const char defaultModulePath[] = "@DEFAULT_MODULE_PATH@"; 62 const char defaultPluginPath[] = "@DEFAULT_PLUGIN_PATH@"; 62 63 const char defaultDocPath[] = "@DEFAULT_DOC_PATH@"; 63 64 const char defaultDataPath[] = "@DEFAULT_DATA_PATH@"; … … 69 70 const char dataInstallDirectory[] = "@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIRECTORY@"; 70 71 const char moduleInstallDirectory[] = "@CMAKE_INSTALL_PREFIX@/@MODULE_INSTALL_DIRECTORY@"; 72 const char pluginInstallDirectory[] = "@CMAKE_INSTALL_PREFIX@/@PLUGIN_INSTALL_DIRECTORY@"; 71 73 #endif 72 74 … … 76 78 #ifdef CMAKE_CONFIGURATION_TYPES 77 79 const char moduleDevDirectory[] = "@CMAKE_MODULE_OUTPUT_DIRECTORY@/" CMAKE_INTDIR; 80 const char pluginDevDirectory[] = "@CMAKE_PLUGIN_OUTPUT_DIRECTORY@/" CMAKE_INTDIR; 78 81 const char configDevDirectory[] = "@CMAKE_CONFIG_OUTPUT_DIRECTORY@/" CMAKE_INTDIR; 79 82 const char logDevDirectory[] = "@CMAKE_LOG_OUTPUT_DIRECTORY@/" CMAKE_INTDIR; 80 83 #else 81 84 const char moduleDevDirectory[] = "@CMAKE_MODULE_OUTPUT_DIRECTORY@"; 85 const char pluginDevDirectory[] = "@CMAKE_PLUGIN_OUTPUT_DIRECTORY@"; 82 86 const char configDevDirectory[] = "@CMAKE_CONFIG_OUTPUT_DIRECTORY@"; 83 87 const char logDevDirectory[] = "@CMAKE_LOG_OUTPUT_DIRECTORY@"; … … 88 92 #endif 89 93 90 // Module extension94 // Module and plugin extension 91 95 const char moduleExtension[] = "@ORXONOX_MODULE_EXTENSION@"; 96 const char pluginExtension[] = "@ORXONOX_PLUGIN_EXTENSION@"; 92 97 93 98 // OGRE PLUGINS -
code/branches/core7/src/libraries/core/ApplicationPaths.cc
r10509 r10547 74 74 , executablePath_(*(new bf::path())) 75 75 , modulePath_(*(new bf::path())) 76 , pluginPath_(*(new bf::path())) 76 77 , bBuildDirectoryRun_(false) 77 78 { … … 121 122 executablePath_ = bf::path(buffer).branch_path(); 122 123 123 ///////////////////// 124 // SET MODULE PATH//125 ///////////////////// 124 ///////////////////////////////// 125 // SET MODULE AND PLUGIN PATHS // 126 ///////////////////////////////// 126 127 127 128 if (bf::exists(executablePath_ / "orxonox_dev_build.keep_me")) … … 130 131 ApplicationPaths::bBuildDirectoryRun_ = true; 131 132 modulePath_ = specialConfig::moduleDevDirectory; 133 pluginPath_ = specialConfig::pluginDevDirectory; 132 134 } 133 135 else … … 144 146 ThrowException(General, "Could not derive a root directory. Might the binary installation directory contain '..' when taken relative to the installation prefix path?"); 145 147 146 // Module path isfixed as well148 // Module and plugin paths are fixed as well 147 149 modulePath_ = rootPath_ / specialConfig::defaultModulePath; 150 pluginPath_ = rootPath_ / specialConfig::defaultPluginPath; 148 151 149 152 #else 150 153 151 154 // There is no root path, so don't set it at all 152 // Module path isfixed as well155 // Module and plugin paths are fixed as well 153 156 modulePath_ = specialConfig::moduleInstallDirectory; 157 pluginPath_ = specialConfig::pluginInstallDirectory; 154 158 155 159 #endif … … 162 166 delete &executablePath_; 163 167 delete &modulePath_; 168 delete &pluginPath_; 164 169 } 165 170 166 171 std::vector<std::string> ApplicationPaths::getModulePaths() 167 172 { 168 std::vector<std::string> modulePaths; 173 return this->getModuleOrPluginPaths(modulePath_, specialConfig::moduleExtension); 174 } 175 176 std::vector<std::string> ApplicationPaths::getPluginPaths() 177 { 178 return this->getModuleOrPluginPaths(pluginPath_, specialConfig::pluginExtension); 179 } 180 181 std::vector<std::string> ApplicationPaths::getModuleOrPluginPaths(boost::filesystem::path& directory, const std::string& extension) 182 { 183 std::vector<std::string> paths; 169 184 170 185 // We search for helper files with the following extension 171 const std::string& moduleextension = specialConfig::moduleExtension; 172 size_t moduleextensionlength = moduleextension.size(); 173 174 // Make sure the path exists, otherwise don't load modules 175 if (!boost::filesystem::exists(modulePath_)) 176 return modulePaths; 177 178 boost::filesystem::directory_iterator file(modulePath_); 186 size_t extensionlength = extension.size(); 187 188 // Make sure the path exists, otherwise don't load modules/plugins 189 if (!boost::filesystem::exists(directory)) 190 return paths; 191 192 boost::filesystem::directory_iterator file(directory); 179 193 boost::filesystem::directory_iterator end; 180 194 … … 185 199 186 200 // Check if the file ends with the extension in question 187 if (filename.size() > moduleextensionlength)201 if (filename.size() > extensionlength) 188 202 { 189 if (filename.substr(filename.size() - moduleextensionlength) == moduleextension)203 if (filename.substr(filename.size() - extensionlength) == extension) 190 204 { 191 205 // We've found a helper file 192 const std::string& library = filename.substr(0, filename.size() - moduleextensionlength);193 modulePaths.push_back(getModulePathString()+ library);206 const std::string& library = filename.substr(0, filename.size() - extensionlength); 207 paths.push_back(directory.BF_GENERIC_STRING() + '/' + library); 194 208 } 195 209 } … … 197 211 } 198 212 199 return modulePaths;213 return paths; 200 214 } 201 215 … … 214 228 return getInstance().modulePath_.BF_GENERIC_STRING() + '/'; 215 229 } 230 231 /*static*/ std::string ApplicationPaths::getPluginPathString() 232 { 233 return getInstance().pluginPath_.BF_GENERIC_STRING() + '/'; 234 } 216 235 } -
code/branches/core7/src/libraries/core/ApplicationPaths.h
r10509 r10547 49 49 The ApplicationPaths class is a singleton which provides static paths of the application. 50 50 @details 51 The class provides information about the executable, root and module path.51 The class provides information about the executable, root and module/plugin path. 52 52 It determines those by the use of platform specific functions. 53 53 @remarks … … 63 63 /** 64 64 @brief 65 Retrieves the executable path and sets all hard coded fixed paths (currently only the module path)65 Retrieves the executable path and sets all hard coded fixed paths (currently only the module and the plugin paths) 66 66 Also checks for "orxonox_dev_build.keep_me" in the executable directory. 67 67 If found it means that this is not an installed run, hence we … … 82 82 static const boost::filesystem::path& getModulePath() 83 83 { return getInstance().modulePath_; } 84 //! Returns the path to the plugins as boost::filesystem::path 85 static const boost::filesystem::path& getPluginPath() 86 { return getInstance().pluginPath_; } 84 87 85 88 //! Returns the path to the root folder as std::string … … 89 92 //! Returns the path to the modules as std::string 90 93 static std::string getModulePathString(); 94 //! Returns the path to the plugins as std::string 95 static std::string getPluginPathString(); 91 96 92 97 //! Return true for runs in the build directory (not installed) … … 95 100 //! Returns a list with all modules declared by a *.module file in the module folder. 96 101 std::vector<std::string> getModulePaths(); 102 //! Returns a list with all plugins declared by a *.plugin file in the plugin folder. 103 std::vector<std::string> getPluginPaths(); 97 104 98 105 private: 99 106 ApplicationPaths(const ApplicationPaths&); //!< Don't use (undefined symbol) 107 108 std::vector<std::string> getModuleOrPluginPaths(boost::filesystem::path& directory, const std::string& extension); 100 109 101 110 //! Path to the parent directory of the ones above if program was installed with relative paths … … 103 112 boost::filesystem::path& executablePath_; //!< Path to the executable 104 113 boost::filesystem::path& modulePath_; //!< Path to the modules 114 boost::filesystem::path& pluginPath_; //!< Path to the plugins 105 115 106 116 bool bBuildDirectoryRun_; //!< True for runs in the build directory (not installed) -
code/branches/core7/src/libraries/core/Core.cc
r10544 r10547 142 142 orxout(internal_info) << "Executable path: " << ApplicationPaths::getExecutablePathString() << endl; 143 143 orxout(internal_info) << "Modules path: " << ApplicationPaths::getModulePathString() << endl; 144 orxout(internal_info) << "Plugins path: " << ApplicationPaths::getPluginPathString() << endl; 144 145 145 146 orxout(internal_info) << "Data path: " << ConfigurablePaths::getDataPathString() << endl;
Note: See TracChangeset
for help on using the changeset viewer.