diff --git a/debian/patches/0002-Fix-to-be-able-to-use-the-library-either-from-build-.patch b/debian/patches/0002-Fix-to-be-able-to-use-the-library-either-from-build-.patch new file mode 100644 index 0000000000000000000000000000000000000000..0fa7167b120f947407ab652020ae2d2b0e3ab363 --- /dev/null +++ b/debian/patches/0002-Fix-to-be-able-to-use-the-library-either-from-build-.patch @@ -0,0 +1,377 @@ +From a3de4582022b3e71a5ccfda7bca517af104624c7 Mon Sep 17 00:00:00 2001 +From: Fabien Spindler <Fabien.Spindler@inria.fr> +Date: Sun, 15 Mar 2015 10:22:11 +0100 +Subject: [PATCH 2/2] Fix to be able to use the library either from build dir + of from install dir. Now VISP_SCENES_DIR, VISP_ROBOT_ARMS_DIR, + VISP_HAVE_OGRE_PLUGINS_PATH, VISP_HAVE_OGRE_RESOURCES_PATH defined in + vpConfig.h may contain multiple path locations separated with ; character. + These locations are the one to found the resources in the build tree, and the + one to found the resources in the install tree. + +--- + CMakeLists.txt | 21 +++---- + CMakeModules/VISPGenerateConfig.cmake | 3 - + src/robot/simulator-robot/vpSimulatorAfma6.cpp | 28 +++++++-- + src/robot/simulator-robot/vpSimulatorViper850.cpp | 26 +++++++-- + src/simulator/ogre-simulator/vpAROgre.cpp | 50 ++++++++++++---- + .../wireframe-simulator/vpWireFrameSimulator.cpp | 13 ++++- + src/tools/io/vpIoTools.cpp | 68 ++++++++++++++++++++++ + src/tools/io/vpIoTools.h | 1 + + 8 files changed, 172 insertions(+), 38 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index d10e231..1f129e6 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -2180,11 +2180,6 @@ set(VISP_ROOT_DIR_DATA_CONFIGCMAKE "${VISP_BINARY_DIR}") + SET(VISP_SCENES_DIR ${VISP_ROOT_DIR_DATA_CONFIGCMAKE}/data/wireframe-simulator) + SET(VISP_ROBOT_ARMS_DIR ${VISP_ROOT_DIR_DATA_CONFIGCMAKE}/data/robot-simulator) + +-# Generate the package dependent file include/visp/vpConfig.h +-CONFIGURE_FILE(${VISP_SOURCE_DIR}/include/vpConfig.h.cmake +- ${VISP_INCLUDE_DIR}/vpConfig.h +-) +- + # case 2: when ViSP is build with make install; files are used in <install dir> + #-------------- + IF(UNIX) +@@ -2193,17 +2188,23 @@ ELSE() + set(VISP_ROOT_DIR_DATA_CONFIGCMAKE "${CMAKE_INSTALL_PREFIX}") + ENDIF() + +-SET(VISP_SCENES_DIR ${VISP_ROOT_DIR_DATA_CONFIGCMAKE}/data/wireframe-simulator) +-SET(VISP_ROBOT_ARMS_DIR ${VISP_ROOT_DIR_DATA_CONFIGCMAKE}/data/robot-simulator) ++list(APPEND VISP_SCENES_DIR ${VISP_ROOT_DIR_DATA_CONFIGCMAKE}/data/wireframe-simulator) ++list(APPEND VISP_ROBOT_ARMS_DIR ${VISP_ROOT_DIR_DATA_CONFIGCMAKE}/data/robot-simulator) + # Only if resources.cfg created by hand, we change the path to resources.cfg in install/vpConfig.h + if(VISP_INSTALL_DIR_OGRE_RESOURCES) +- SET(VISP_HAVE_OGRE_RESOURCES_PATH ${VISP_ROOT_DIR_DATA_CONFIGCMAKE}/data/ogre-simulator) ++ list(APPEND VISP_HAVE_OGRE_RESOURCES_PATH "${VISP_ROOT_DIR_DATA_CONFIGCMAKE}/data/ogre-simulator") + endif() +-# Only if plugins.cfg created by hand, we change the path to plugins.cfg in install/vpConfig.h ++# append to VISP_HAVE_OGRE_PLUGINS_PATH the path of the installed plugins.cfg file ++# to be able to use ViSP from build tree or install tree + if(VISP_INSTALL_DIR_OGRE_RESOURCES) +- SET(VISP_HAVE_OGRE_PLUGINS_PATH ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/visp/data/ogre-simulator) ++ list(APPEND VISP_HAVE_OGRE_PLUGINS_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/visp/data/ogre-simulator") + endif() + ++# Generate the package dependent file include/visp/vpConfig.h ++CONFIGURE_FILE(${VISP_SOURCE_DIR}/include/vpConfig.h.cmake ++ ${VISP_INCLUDE_DIR}/vpConfig.h ++) ++ + #---------------------------------------------------------------------- + # Generate the ViSP-third-party.txt information file + #---------------------------------------------------------------------- +diff --git a/CMakeModules/VISPGenerateConfig.cmake b/CMakeModules/VISPGenerateConfig.cmake +index d7d2ef5..d64c568 100755 +--- a/CMakeModules/VISPGenerateConfig.cmake ++++ b/CMakeModules/VISPGenerateConfig.cmake +@@ -120,9 +120,6 @@ if(UNIX) + ${VISP_BINARY_DIR}/unix-install/VISPUse.cmake + IMMEDIATE @ONLY) + +- configure_file(${VISP_SOURCE_DIR}/include/vpConfig.h.cmake +- ${VISP_BINARY_DIR}/unix-install/vpConfig.h @ONLY) +- + install(FILES + ${VISP_BINARY_DIR}/unix-install/VISPConfig.cmake + ${VISP_BINARY_DIR}/unix-install/VISPConfigVersion.cmake +diff --git a/src/robot/simulator-robot/vpSimulatorAfma6.cpp b/src/robot/simulator-robot/vpSimulatorAfma6.cpp +index 2a38013..b794825 100644 +--- a/src/robot/simulator-robot/vpSimulatorAfma6.cpp ++++ b/src/robot/simulator-robot/vpSimulatorAfma6.cpp +@@ -196,9 +196,16 @@ void + vpSimulatorAfma6::init() + { + // set arm_dir from #define VISP_ROBOT_ARMS_DIR if it exists +- if (vpIoTools::checkDirectory(VISP_ROBOT_ARMS_DIR) == true) // directory exists +- arm_dir = VISP_ROBOT_ARMS_DIR; +- else { ++ // VISP_ROBOT_ARMS_DIR may contain multiple locations separated by ";" ++ std::vector<std::string> arm_dirs = vpIoTools::splitChain(std::string(VISP_ROBOT_ARMS_DIR), std::string(";")); ++ bool armDirExists = false; ++ for(size_t i=0; i < arm_dirs.size(); i++) ++ if (vpIoTools::checkDirectory(arm_dirs[i]) == true) { // directory exists ++ arm_dir = arm_dirs[i]; ++ armDirExists = true; ++ break; ++ } ++ if (! armDirExists) { + try { + arm_dir = vpIoTools::getenv("VISP_ROBOT_ARMS_DIR"); + std::cout << "The simulator uses data from VISP_ROBOT_ARMS_DIR=" << arm_dir << std::endl; +@@ -2298,10 +2305,17 @@ void + vpSimulatorAfma6::initArms() + { + // set scene_dir from #define VISP_SCENE_DIR if it exists ++ // VISP_SCENES_DIR may contain multiple locations separated by ";" + std::string scene_dir_; +- if (vpIoTools::checkDirectory(VISP_SCENES_DIR) == true) // directory exists +- scene_dir_ = VISP_SCENES_DIR; +- else { ++ std::vector<std::string> scene_dirs = vpIoTools::splitChain(std::string(VISP_SCENES_DIR), std::string(";")); ++ bool sceneDirExists = false; ++ for(size_t i=0; i < scene_dirs.size(); i++) ++ if (vpIoTools::checkDirectory(scene_dirs[i]) == true) { // directory exists ++ scene_dir_ = scene_dirs[i]; ++ sceneDirExists = true; ++ break; ++ } ++ if (! sceneDirExists) { + try { + scene_dir_ = vpIoTools::getenv("VISP_SCENES_DIR"); + std::cout << "The simulator uses data from VISP_SCENES_DIR=" << scene_dir_ << std::endl; +@@ -2311,6 +2325,7 @@ vpSimulatorAfma6::initArms() + } + } + ++ + unsigned int name_length = 30; // the size of this kind of string "/afma6_arm2.bnd" + if (scene_dir_.size() > FILENAME_MAX) + throw vpException (vpException::dimensionError, "Cannot initialize Afma6 simulator"); +@@ -2333,6 +2348,7 @@ vpSimulatorAfma6::initArms() + char *name_arm = new char [full_length]; + strcpy(name_arm, arm_dir.c_str()); + strcat(name_arm,"/afma6_gate.bnd"); ++ std::cout <<"name arm: " << name_arm << std::endl; + set_scene(name_arm, robotArms, 1.0); + strcpy(name_arm, arm_dir.c_str()); + strcat(name_arm,"/afma6_arm1.bnd"); +diff --git a/src/robot/simulator-robot/vpSimulatorViper850.cpp b/src/robot/simulator-robot/vpSimulatorViper850.cpp +index 9286b2a..85ea1c0 100644 +--- a/src/robot/simulator-robot/vpSimulatorViper850.cpp ++++ b/src/robot/simulator-robot/vpSimulatorViper850.cpp +@@ -195,9 +195,16 @@ void + vpSimulatorViper850::init() + { + // set arm_dir from #define VISP_ROBOT_ARMS_DIR if it exists +- if (vpIoTools::checkDirectory(VISP_ROBOT_ARMS_DIR) == true) // directory exists +- arm_dir = VISP_ROBOT_ARMS_DIR; +- else { ++ // VISP_ROBOT_ARMS_DIR may contain multiple locations separated by ";" ++ std::vector<std::string> arm_dirs = vpIoTools::splitChain(std::string(VISP_ROBOT_ARMS_DIR), std::string(";")); ++ bool armDirExists = false; ++ for(size_t i=0; i < arm_dirs.size(); i++) ++ if (vpIoTools::checkDirectory(arm_dirs[i]) == true) { // directory exists ++ arm_dir = arm_dirs[i]; ++ armDirExists = true; ++ break; ++ } ++ if (! armDirExists) { + try { + arm_dir = vpIoTools::getenv("VISP_ROBOT_ARMS_DIR"); + std::cout << "The simulator uses data from VISP_ROBOT_ARMS_DIR=" << arm_dir << std::endl; +@@ -2290,10 +2297,17 @@ void + vpSimulatorViper850::initArms() + { + // set scene_dir from #define VISP_SCENE_DIR if it exists ++ // VISP_SCENES_DIR may contain multiple locations separated by ";" + std::string scene_dir_; +- if (vpIoTools::checkDirectory(VISP_SCENES_DIR) == true) // directory exists +- scene_dir_ = VISP_SCENES_DIR; +- else { ++ std::vector<std::string> scene_dirs = vpIoTools::splitChain(std::string(VISP_SCENES_DIR), std::string(";")); ++ bool sceneDirExists = false; ++ for(size_t i=0; i < scene_dirs.size(); i++) ++ if (vpIoTools::checkDirectory(scene_dirs[i]) == true) { // directory exists ++ scene_dir_ = scene_dirs[i]; ++ sceneDirExists = true; ++ break; ++ } ++ if (! sceneDirExists) { + try { + scene_dir_ = vpIoTools::getenv("VISP_SCENES_DIR"); + std::cout << "The simulator uses data from VISP_SCENES_DIR=" << scene_dir_ << std::endl; +diff --git a/src/simulator/ogre-simulator/vpAROgre.cpp b/src/simulator/ogre-simulator/vpAROgre.cpp +index 074a0e6..52400ac 100644 +--- a/src/simulator/ogre-simulator/vpAROgre.cpp ++++ b/src/simulator/ogre-simulator/vpAROgre.cpp +@@ -222,14 +222,31 @@ void vpAROgre::init(bool + ) + { + // Create the root ++ // mPluginsPath may contain more than one folder location separated by ";" ++ bool pluginsFileExists = false; ++ std::string pluginFile; ++ std::vector<std::string> plugingsPaths = vpIoTools::splitChain(std::string(mPluginsPath), std::string(";")); ++ for (size_t i=0; i<plugingsPaths.size(); i++) { + #if defined(NDEBUG) || !defined(_WIN32) +- std::string pluginFile = mPluginsPath+"/plugins.cfg"; ++ pluginFile = plugingsPaths[i]+"/plugins.cfg"; + #else +- std::string pluginFile = mPluginsPath+"/plugins_d.cfg"; ++ pluginFile = plugingsPaths[i]+"/plugins_d.cfg"; + #endif +- if(!vpIoTools::checkFilename(pluginFile)){ +- std::string errorMsg = "Error: the requested plugins file \"" +- + pluginFile + "\" doesn't exist."; ++ ++ if(vpIoTools::checkFilename(pluginFile)) { ++ pluginsFileExists = true; ++ break; ++ } ++ } ++ if (! pluginsFileExists) { ++ std::string errorMsg = std::string("Error: the requested plugins file \"") ++#if defined(NDEBUG) || !defined(_WIN32) ++ + std::string("plugins.cfg") ++#else ++ + std::string("plugins_d.cfg") ++#endif ++ + std::string("\" doesn't exist in ") ++ + std::string(mPluginsPath); + std::cout << errorMsg << std::endl; + + throw (vpException(vpException::ioError, errorMsg)); +@@ -251,16 +268,29 @@ void vpAROgre::init(bool + // [General] + // FileSystem=media/ + // Zip=packages/level1.zip +- Ogre::ConfigFile cf; +- std::string resourceFile = mResourcePath+"/resources.cfg"; +- if(!vpIoTools::checkFilename(resourceFile)){ +- std::string errorMsg = "Error: the requested resource file \"" +- + resourceFile + "\" doesn't exist."; ++ ++ // mResourcePath may contain more than one folder location separated by ";" ++ bool resourcesFileExists = false; ++ std::string resourceFile; ++ std::vector<std::string> resourcesPaths = vpIoTools::splitChain(std::string(mResourcePath), std::string(";")); ++ for (size_t i=0; i<resourcesPaths.size(); i++) { ++ resourceFile = resourcesPaths[i]+"/resources.cfg"; ++ if(vpIoTools::checkFilename(resourceFile)) { ++ resourcesFileExists = true; ++ break; ++ } ++ } ++ if (! resourcesFileExists) { ++ std::string errorMsg = std::string("Error: the requested resource file \"resources.cfg\"") ++ + std::string("doesn't exist in ") ++ + std::string(mResourcePath); ++ + std::cout << errorMsg << std::endl; + + throw (vpException(vpException::ioError, errorMsg)); + } + std::cout << "######################### Load resource file: " << resourceFile << std::endl; ++ Ogre::ConfigFile cf; + cf.load(resourceFile); + + // Go through all sections & settings in the file +diff --git a/src/simulator/wireframe-simulator/vpWireFrameSimulator.cpp b/src/simulator/wireframe-simulator/vpWireFrameSimulator.cpp +index e5e38dd..e015dab 100644 +--- a/src/simulator/wireframe-simulator/vpWireFrameSimulator.cpp ++++ b/src/simulator/wireframe-simulator/vpWireFrameSimulator.cpp +@@ -522,9 +522,16 @@ vpWireFrameSimulator::vpWireFrameSimulator() + cameraFactor(1.), camTrajType(CT_LINE), extCamChanged(false), rotz(), thickness_(1), scene_dir() + { + // set scene_dir from #define VISP_SCENE_DIR if it exists +- if (vpIoTools::checkDirectory(VISP_SCENES_DIR) == true) // directory exists +- scene_dir = VISP_SCENES_DIR; +- else { ++ // VISP_SCENES_DIR may contain multiple locations separated by ";" ++ std::vector<std::string> scene_dirs = vpIoTools::splitChain(std::string(VISP_SCENES_DIR), std::string(";")); ++ bool sceneDirExists = false; ++ for(size_t i=0; i < scene_dirs.size(); i++) ++ if (vpIoTools::checkDirectory(scene_dirs[i]) == true) { // directory exists ++ scene_dir = scene_dirs[i]; ++ sceneDirExists = true; ++ break; ++ } ++ if (! sceneDirExists) { + try { + scene_dir = vpIoTools::getenv("VISP_SCENES_DIR"); + std::cout << "The simulator uses data from VISP_SCENES_DIR=" << scene_dir << std::endl; +diff --git a/src/tools/io/vpIoTools.cpp b/src/tools/io/vpIoTools.cpp +index ae85396..5ccc1a8 100644 +--- a/src/tools/io/vpIoTools.cpp ++++ b/src/tools/io/vpIoTools.cpp +@@ -1405,3 +1405,71 @@ std::pair<std::string, std::string> vpIoTools::splitDrive(const std::string& pat + return std::pair<std::string, std::string>("", pathname); + #endif + } ++ ++/*! ++ Split a chain. ++ \param chain : Input chain to split. ++ \param sep : Character separator. ++ \return A vector that contains all the subchains. ++ ++ The following code shows how to use this function: ++ \code ++#include <visp/vpIoTools.h> ++ ++int main() ++{ ++ { ++ std::string chain("/home/user;/usr/local/include;/usr/include"); ++ std::string sep = ";"; ++ ++ std::vector<std::string> subChain = vpIoTools::splitChain(chain, sep); ++ std::cout << "Found the following subchains: " << std::endl; ++ for (size_t i=0; i < subChain.size(); i++) ++ std::cout << subChain[i] << std::endl; ++ } ++ ++ { ++ std::string chain("This is an other example"); ++ std::string sep = " "; ++ ++ std::vector<std::string> subChain = vpIoTools::splitChain(chain, sep); ++ std::cout << "Found the following subchains: " << std::endl; ++ for (size_t i=0; i < subChain.size(); i++) ++ std::cout << subChain[i] << std::endl; ++ } ++} ++ \endcode ++ ++ It produces the following output: ++ \code ++Found the following subchains: ++/home/user ++/usr/local/include ++/usr/include ++Found the following subchains: ++This ++is ++an ++other ++example ++ \endcode ++ */ ++std::vector<std::string> vpIoTools::splitChain(const std::string & chain, const std::string & sep) ++{ ++ size_t startIndex = 0; ++ ++ std::string chainToSplit = chain; ++ std::vector<std::string> subChain; ++ size_t sepIndex = chainToSplit.find(sep); ++ ++ while(sepIndex != std::string::npos) { ++ ++ subChain.push_back( chainToSplit.substr(startIndex, sepIndex) ); ++ chainToSplit = chainToSplit.substr(sepIndex+1, chain.size()-1); ++ ++ sepIndex = chainToSplit.find(sep); ++ } ++ subChain.push_back(chainToSplit); ++ ++ return subChain; ++} +diff --git a/src/tools/io/vpIoTools.h b/src/tools/io/vpIoTools.h +index 7d7ef70..38ac58a 100644 +--- a/src/tools/io/vpIoTools.h ++++ b/src/tools/io/vpIoTools.h +@@ -195,6 +195,7 @@ public: + static std::string createFilePath(const std::string& parent, const std::string child); + static bool isAbsolutePathname(const std::string& pathname); + static std::pair<std::string, std::string> splitDrive(const std::string& pathname); ++ static std::vector<std::string> splitChain(const std::string & chain, const std::string & sep); + + // read configuration file + static bool loadConfigFile(const std::string &confFile); +-- +2.1.4 + diff --git a/debian/patches/series b/debian/patches/series index e9c0987162ff69a56de31ad01e3e189c01d47a0b..b3c4cf804fbabe9994138813ac3818b7e67c83eb 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1 +1,2 @@ 0001-Install-headers-in-include-architecture-triplet.patch +0002-Fix-to-be-able-to-use-the-library-either-from-build-.patch