Skip to content
This repository has been archived by the owner on Feb 21, 2021. It is now read-only.

Commit

Permalink
Merge pull request #531 from lr-morales/libs/easyiceconfig/485-cmake_…
Browse files Browse the repository at this point in the history
…paths

[Issue #485] Refactor easyiceconfig to use CMAKE_INSTALL_PREFIX
  • Loading branch information
chanfr authored Sep 5, 2016
2 parents a086235 + d04ea85 commit 1ac191b
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 41 deletions.
30 changes: 15 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,40 +137,40 @@ add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR}/src)
# #
###################

INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/src/interfaces/libJderobotInterfaces.so DESTINATION /usr/local/lib/jderobot COMPONENT core)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/src/interfaces/libJderobotInterfaces.so DESTINATION ${CMAKE_INSTALL_PREFIX}/jderobot COMPONENT core)

# Install python files
FILE(GLOB_RECURSE HEADERS_FILES ${CMAKE_CURRENT_BINARY_DIR}/src/interfaces/python/*py)
FOREACH(header ${HEADERS_FILES})
INSTALL(FILES ${header} DESTINATION /usr/lib/python2.7/jderobot/ COMPONENT core)
INSTALL(FILES ${header} DESTINATION ${PYTHON_MODULE_PATH}/jderobot/ COMPONENT core)
ENDFOREACH(header)

INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/src/interfaces/python/jderobot/__init__.py DESTINATION /usr/lib/python2.7/jderobot/ COMPONENT core)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/src/interfaces/python/jderobot/__init__.py DESTINATION ${PYTHON_MODULE_PATH}/jderobot/ COMPONENT core)

# install all libraries
FILE(GLOB LIB_FILES ${CMAKE_CURRENT_BINARY_DIR}/src/libs/*/*.so*)
FOREACH (lib ${LIB_FILES})
INSTALL (FILES ${lib} DESTINATION /usr/local/lib/jderobot COMPONENT core)
INSTALL (FILES ${lib} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/jderobot COMPONENT core)
ENDFOREACH(lib)

FILE(GLOB LIB_FILES ${CMAKE_CURRENT_BINARY_DIR}/src/libs/visionlib/*/*.so*)
FOREACH (lib ${LIB_FILES})
INSTALL (FILES ${lib} DESTINATION /usr/local/lib/jderobot COMPONENT core)
INSTALL (FILES ${lib} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/jderobot COMPONENT core)
ENDFOREACH(lib)


FILE(GLOB_RECURSE HEADERS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/libs/*.h)
FOREACH(currentSourceFile ${HEADERS_FILES})
string(REGEX REPLACE "(.*/).*.h" "\\1" new_source1 ${currentSourceFile})
string(REGEX REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/src/libs" "" new_source2 ${new_source1})
INSTALL (FILES ${currentSourceFile} DESTINATION /usr/local/include/jderobot/${new_source2} COMPONENT core)
INSTALL (FILES ${currentSourceFile} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/jderobot/${new_source2} COMPONENT core)
ENDFOREACH(currentSourceFile)

# Install libraries headers
FILE(GLOB_RECURSE HEADERS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/libs/*.h)
FOREACH(currentSourceFile ${HEADERS_FILES})
string(REGEX REPLACE ".*/(.*/).*.h" "\\1" new_source1 ${currentSourceFile})
INSTALL (FILES ${currentSourceFile} DESTINATION /usr/local/include/jderobot/${new_source1} COMPONENT core)
INSTALL (FILES ${currentSourceFile} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/jderobot/${new_source1} COMPONENT core)
ENDFOREACH(currentSourceFile)

# Install Executables
Expand All @@ -179,46 +179,46 @@ list_subdirectories2( LIST_TOOLS ${CMAKE_CURRENT_SOURCE_DIR}/src/tools/ 1)

FOREACH (currentBin ${LIST_DRIVERS})
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/drivers/${currentBin}/${currentBin})
INSTALL (PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/src/drivers/${currentBin}/${currentBin} DESTINATION /usr/local/bin OPTIONAL COMPONENT core)
INSTALL (PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/src/drivers/${currentBin}/${currentBin} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin OPTIONAL COMPONENT core)
else()
INSTALL (PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/src/drivers/${currentBin}/${currentBin} DESTINATION /usr/local/bin OPTIONAL COMPONENT core)
INSTALL (PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/src/drivers/${currentBin}/${currentBin} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin OPTIONAL COMPONENT core)
endif()
ENDFOREACH(currentBin)

FOREACH (currentBin ${LIST_TOOLS})
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/tools/${currentBin}/${currentBin})
INSTALL (PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/src/tools/${currentBin}/${currentBin} DESTINATION /usr/local/bin OPTIONAL COMPONENT core)
INSTALL (PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/src/toolss/${currentBin}/${currentBin} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin OPTIONAL COMPONENT core)
else()
INSTALL (PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/src/tools/${currentBin}/${currentBin} DESTINATION /usr/local/bin OPTIONAL COMPONENT core)
INSTALL (PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/src/tools/${currentBin}/${currentBin} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin OPTIONAL COMPONENT core)
endif()
ENDFOREACH(currentBin)



# Install interfaces headers
INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/src/interfaces/cpp/jderobot/
DESTINATION /usr/local/include/jderobot
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/jderobot
COMPONENT core
FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp"
)

# Install slice
FILE(GLOB SLICE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/interfaces/slice/jderobot/*.ice)
INSTALL (FILES ${SLICE_FILES} DESTINATION /usr/local/include/jderobot/slice COMPONENT core)
INSTALL (FILES ${SLICE_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/jderobot/slice COMPONENT core)

# Install CONF
FILE(GLOB_RECURSE CONF_DRIVER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/drivers/*.cfg)
FILE(GLOB_RECURSE CONF_TOOL_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/tools/*.cfg)

SET(CONF_FILES ${CONF_COMPONENT_FILES} ${CONF_DRIVER_FILES} ${CONF_TOOL_FILES})
INSTALL (FILES ${CONF_FILES} DESTINATION /usr/local/share/jderobot/conf COMPONENT core)
INSTALL (FILES ${CONF_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/jderobot/conf COMPONENT core)

# Install Glade
FILE(GLOB_RECURSE GLADE_DRIVER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/drivers/*.glade)
FILE(GLOB_RECURSE GLADE_TOOL_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/tools/*.glade)

SET(GLADE_FILES ${GLADE_COMPONENT_FILES} ${GLADE_DRIVER_FILES} ${GLADE_TOOL_FILES})
INSTALL (FILES ${GLADE_FILES} DESTINATION /usr/local/share/jderobot/glade COMPONENT core)
INSTALL (FILES ${GLADE_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/jderobot/glade COMPONENT core)

# Install Deps cmake's tree
INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Deps DESTINATION ${CMAKE_INSTALL_PREFIX}/share/jderobot)
Expand Down
15 changes: 15 additions & 0 deletions Deps/python2/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
find_package(PythonInterp 2 REQUIRED)

execute_process(
COMMAND ${PYTHON_EXECUTABLE} -c "import os;print(os.path.dirname(os.__file__))"
RESULT_VARIABLE _RESULT
OUTPUT_VARIABLE PYTHON_MODULE_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE
)

if(_RESULT)
message(FATAL_ERROR "Failed to determine python information")
endif(_RESULT)
unset(_RESULT)

message(${PYTHON_MODULE_PATH})
14 changes: 11 additions & 3 deletions src/libs/easyiceconfig_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,20 @@ list(APPEND Ice_LIBRARIES Ice IceUtil)


### Project config
include_directories(include)
include_directories(
include
${CMAKE_CURRENT_BINARY_DIR}/include
)

configure_file(
include/easyiceconfig/hardcodedlocations.h.in
include/easyiceconfig/hardcodedlocations.h
@ONLY
)

set(HEADERS
include/easyiceconfig/EasyIce.h
include/easyiceconfig/hardcoredlocations.h

${CMAKE_CURRENT_BINARY_DIR}/include/easyiceconfig/hardcodedlocations.h
include/easyiceconfig/loader.hpp
include/easyiceconfig/initializer.hpp
include/easyiceconfig/injector.hpp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 1997-2015 JDE Developers Team
* Copyright (C) 1997-2016 JDE Developers Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -14,22 +14,22 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
* Authors :
* Victor Arribas Raigadas <.varribas.urjc@gmail.com>
* Victor Arribas Raigadas <varribas.urjc@gmail.com>
*/


#ifndef HARDCOREDLOCATIONS_H
#define HARDCOREDLOCATIONS_H

const char* HARDCORED_LOCATIONS =
"/usr/local/share/jderobot/conf\
:/usr/local/share/jderobot/gazebo/plugins/car\
:/usr/local/share/jderobot/gazebo/plugins/flyingKinect\
:/usr/local/share/jderobot/gazebo/plugins/kinect\
:/usr/local/share/jderobot/gazebo/plugins/nao\
:/usr/local/share/jderobot/gazebo/plugins/pioneer\
:/usr/local/share/jderobot/gazebo/plugins/quadrotor\
:/usr/local/share/jderobot/gazebo/plugins/turtlebot\
"@CMAKE_INSTALL_PREFIX@/share/jderobot/conf\
:@CMAKE_INSTALL_PREFIX@/share/jderobot/gazebo/plugins/car\
:@CMAKE_INSTALL_PREFIX@/share/jderobot/gazebo/plugins/flyingKinect\
:@CMAKE_INSTALL_PREFIX@/share/jderobot/gazebo/plugins/kinect\
:@CMAKE_INSTALL_PREFIX@/share/jderobot/gazebo/plugins/nao\
:@CMAKE_INSTALL_PREFIX@/share/jderobot/gazebo/plugins/pioneer\
:@CMAKE_INSTALL_PREFIX@/share/jderobot/gazebo/plugins/quadrotor\
:@CMAKE_INSTALL_PREFIX@/share/jderobot/gazebo/plugins/turtlebot\
";


Expand Down
2 changes: 1 addition & 1 deletion src/libs/easyiceconfig_cpp/src/loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


#include "easyiceconfig/loader.hpp"
#include "easyiceconfig/hardcoredlocations.h"
#include "easyiceconfig/hardcodedlocations.h"

namespace easyiceconfig{
namespace loader{
Expand Down
26 changes: 23 additions & 3 deletions src/libs/easyiceconfig_py/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
cmake_minimum_required(VERSION 2.8)

configure_file(
easyiceconfig/hardcodedpaths.py.in
easyiceconfig/hardcodedpaths.py
@ONLY
)

file(GLOB ModuleFiles
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/easyiceconfig
${CMAKE_CURRENT_SOURCE_DIR}/easyiceconfig/*)

string(REGEX REPLACE "[^;]+\\.in;?" "" ModuleFiles "${ModuleFiles}")


add_custom_target(easyiceconfig_py ALL)
foreach(ModuleFile ${ModuleFiles})
add_custom_command(TARGET easyiceconfig_py
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/easyiceconfig/${ModuleFile} ${CMAKE_CURRENT_BINARY_DIR}/easyiceconfig/${ModuleFile}
)
endforeach(ModuleFile ${ModuleFiles})

### Install
install(DIRECTORY easyiceconfig
DESTINATION /usr/lib/python2.7/
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/easyiceconfig
DESTINATION ${PYTHON_MODULE_PATH}
COMPONENT core
)

8 changes: 4 additions & 4 deletions src/libs/easyiceconfig_py/easyiceconfig/easyiceconfig.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (C) 1997-2015 JDE Developers Team
# Copyright (C) 1997-2016 JDE Developers Team
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -22,7 +22,7 @@
import re
import Ice

from hardcoredpaths import HARDCORED_PATHS
from hardcodedpaths import HARDCODED_PATHS


ENV_PATH_NAME = "ICE_CONFIG_PATH"
Expand All @@ -33,8 +33,8 @@ def findConfigFile(filename):
env_paths = os.getenv(ENV_PATH_NAME)
if env_paths:
paths = paths+":"+env_paths
if HARDCORED_PATHS:
paths = paths+":"+HARDCORED_PATHS
if HARDCODED_PATHS:
paths = paths+":"+HARDCODED_PATHS

for path in paths.split(":"):
file_path = os.path.join(path, filename)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (C) 1997-2015 JDE Developers Team
# Copyright (C) 1997-2016 JDE Developers Team
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -20,12 +20,12 @@


# JdeRobot main Ice.Config path
JDEROBOT_PATHS = "/usr/local/share/jderobot/conf"
JDEROBOT_PATHS = "@CMAKE_INSTALL_PREFIX@/share/jderobot/conf"


# JdeRobot Gazebo's plugins Ice.Config path
import os
JDEROBOT_GAZEBO_PLUGINS_BASE_PATH = '/usr/local/share/jderobot/gazebo/plugins'
JDEROBOT_GAZEBO_PLUGINS_BASE_PATH = '@CMAKE_INSTALL_PREFIX@/share/jderobot/gazebo/plugins'

gazebo_plugins = list()
for dir in os.listdir(JDEROBOT_GAZEBO_PLUGINS_BASE_PATH):
Expand All @@ -35,5 +35,5 @@
JDEROBOT_GAZEBO_PLUGINS_PATHS = ':'.join(str(x) for x in gazebo_plugins)


# "Hardcored" PATHS
HARDCORED_PATHS = "%s:%s" %(JDEROBOT_PATHS, JDEROBOT_GAZEBO_PLUGINS_PATHS)
# "Hardcoded" PATHS
HARDCODED_PATHS = "%s:%s" %(JDEROBOT_PATHS, JDEROBOT_GAZEBO_PLUGINS_PATHS)

0 comments on commit 1ac191b

Please sign in to comment.