Skip to content

Commit

Permalink
Merge pull request #35 from robotology/devel
Browse files Browse the repository at this point in the history
master update (minor revision)
  • Loading branch information
Iaxama authored Oct 17, 2019
2 parents 07475dc + 38c1b1c commit 23f9cc6
Show file tree
Hide file tree
Showing 148 changed files with 4,524 additions and 3,795 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ CMakeLists.txt.user.*

#ignore the build directory
build/
build-debug/
build-x86_64/
build-ubuntu/

Expand Down
112 changes: 84 additions & 28 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,40 +1,96 @@
# Copyright: (C) 2015 iCub Facility - Istituto Italiano di Tecnologia
# Authors: Arren Glover
# CopyPolicy: Released under the terms of the GNU GPL v2.0.
# Copyright: (C) 2019 EDPR - Istituto Italiano di Tecnologia
# Authors: Arren Glover, Daniele Domenichelli
# CopyPolicy: Released under the terms of the GNU GPL v3.0.

cmake_minimum_required(VERSION 2.6)
set(CONTEXT_DIR eventdriven)
set(PROJECTNAME icub-event-driven)
project(${PROJECTNAME})
cmake_minimum_required(VERSION 3.5)
project(event-driven
LANGUAGES CXX C
VERSION 1.3)

include(GNUInstallDirs)
include(FeatureSummary)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-strict-aliasing -std=c++11 -fPIC")
set(EVENTDRIVENLIBS_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/libraries/include)
set(EVENTDRIVEN_LIBRARIES eventdriven)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")

set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

if(MSVC)
set(CMAKE_DEBUG_POSTFIX "d")
endif()

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_CXX_EXTENSIONS OFF)

find_package(YCM QUIET)
set_package_properties(YCM PROPERTIES TYPE RECOMMENDED)

if(NOT YCM_FOUND)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
endif()

option(BUILD_SHARED_LIBS "Build libraries as shared as opposed to static" ON)

# option(BUILD_TESTING "Create tests using CMake" OFF)
# if(BUILD_TESTING)
# enable_testing()
# endif()

include(AddInstallRPATHSupport)
add_install_rpath_support(BIN_DIRS "${CMAKE_INSTALL_FULL_BINDIR}"
LIB_DIRS "${CMAKE_INSTALL_FULL_LIBDIR}"
INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}"
USE_LINK_PATH)

if(NOT CMAKE_CONFIGURATION_TYPES)
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "Setting build type to 'Release' as none was specified.")
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Release")
endif()
endif()

set(CONTEXT_DIR event-driven)
set(EVENTDRIVEN_LIBRARY event-driven)

#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-strict-aliasing -std=c++11 -fPIC")
#set(EVENTDRIVENLIBS_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/libraries/include)

option(ADD_DOCS_TO_IDE "Add apps/documentation to IDE" OFF)

#YARP
find_package(YARP REQUIRED)

#ICUBCONTRIB
find_package(ICUBcontrib)
if(ICUBcontrib_FOUND)
list(APPEND CMAKE_MODULE_PATH ${ICUBCONTRIB_MODULE_PATH})
include(ICUBcontribOptions)
include(ICUBcontribHelpers)
icubcontrib_set_default_prefix()
else(ICUBcontrib_FOUND)
message("Warning: ICUBcontrib not found. Make Install may not install to the correct location")
endif(ICUBcontrib_FOUND)

add_subdirectory(libraries)

find_package(YARP COMPONENTS OS sig math dev cv REQUIRED)
yarp_configure_external_installation(event-driven)

find_package(OpenCV)
set_package_properties(OpenCV PROPERTIES TYPE OPTIONAL)

feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES)

add_subdirectory(lib)
add_subdirectory(src)
add_subdirectory(bindings)
# add_subdirectory(bindings)
# if(BUILD_TESTING)
# add_subdirectory(test)
# endif()

if(ADD_DOCS_TO_IDE)
file(GLOB tutorialfiles documentation/*.md)
file(GLOB tutorialfiles documentation/*.md
documentation/application_instructions/*.md)
add_custom_target(project_documentation SOURCES README.md ${tutorialfiles})
endif(ADD_DOCS_TO_IDE)

icubcontrib_add_uninstall_target() #macro added 13/11/2013

include(InstallBasicPackageFiles)
install_basic_package_files(${PROJECT_NAME}
EXPORT eventdriven
VERSION ${${PROJECT_NAME}_VERSION}
COMPATIBILITY SameMajorVersion
LOWERCASE_FILENAMES
NAMESPACE ev::
DEPENDENCIES "YARP COMPONENTS OS sig"
INCLUDE_CONTENT "yarp_configure_external_installation(event-driven NO_PATH_D)")

include(AddUninstallTarget)
14 changes: 1 addition & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,7 @@ Datasets for use in running some of the tutorials off-line can be found on the s

## How to Install:

Comprehensive instructions available if you are a first-time user of YARP [here](http://robotology.github.io/event-driven/doxygen/doc/html/pages.html).

Quick instructions:

1. Install [YARP](https://github.com/robotology/yarp) and [icub-contrib-common](https://github.com/robotology/icub-contrib-common) following these [instructions](http://wiki.icub.org/wiki/Linux:Installation_from_sources).
2. git clone https://github.com/robotology/event-driven.git
3. cd event-driven
4. mkdir build && cd build
5. ccmake ..
6. ensure the install path is as configured in icub-contrib-common
7. turn on desired modules and applications (e.g. processing)
8. configure (c) and generate (g)
9. make install
[Comprehensive instructions available for installation](http://robotology.github.io/event-driven/doxygen/doc/html/pages.html).

## References

Expand Down
2 changes: 1 addition & 1 deletion bindings/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if(BUILD_BINDINGS)
set_source_files_properties(event_driven.i PROPERTIES SWIG_FLAGS "-includeall")

swig_add_library(event_driven LANGUAGE python SOURCES event_driven.i)
swig_link_libraries(event_driven ${PYTHON_LIBRARIES} ${YARP_LIBRARIES} ${EVENTDRIVEN_LIBRARIES})
swig_link_libraries(event_driven ${PYTHON_LIBRARIES} ${YARP_LIBRARIES} ${EVENTDRIVEN_LIBRARY})

execute_process(COMMAND python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())" OUTPUT_VARIABLE PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE)
#INSTALL ( FILES ${CMAKE_CURRENT_BINARY_DIR}/lib/_event_driven.so DESTINATION ${PYTHON_SITE_PACKAGES} )
Expand Down
169 changes: 169 additions & 0 deletions cmake/AddInstallRPATHSupport.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
#.rst:
# AddInstallRPATHSupport
# ----------------------
#
# Add support to RPATH during installation to your project::
#
# add_install_rpath_support([BIN_DIRS dir [dir]]
# [LIB_DIRS dir [dir]]
# [INSTALL_NAME_DIR [dir]]
# [DEPENDS condition [condition]]
# [USE_LINK_PATH])
#
# Normally (depending on the platform) when you install a shared
# library you can either specify its absolute path as the install name,
# or leave just the library name itself. In the former case the library
# will be correctly linked during run time by all executables and other
# shared libraries, but it must not change its install location. This
# is often the case for libraries installed in the system default
# library directory (e.g. ``/usr/lib``).
# In the latter case, instead, the library can be moved anywhere in the
# file system but at run time the dynamic linker must be able to find
# it. This is often accomplished by setting environmental variables
# (i.e. ``LD_LIBRARY_PATH`` on Linux).
# This procedure is usually not desirable for two main reasons:
#
# - by setting the variable you are changing the default behaviour
# of the dynamic linker thus potentially breaking executables (not as
# destructive as ``LD_PRELOAD``)
# - the variable will be used only by applications spawned by the shell
# and not by other processes.
#
# RPATH aims in solving the issues introduced by the second
# installation method. Using run-path dependent libraries you can
# create a directory structure containing executables and dependent
# libraries that users can relocate without breaking it.
# A run-path dependent library is a dependent library whose complete
# install name is not known when the library is created.
# Instead, the library specifies that the dynamic loader must resolve
# the library’s install name when it loads the executable that depends
# on the library. The executable or the other shared library will
# hardcode in the binary itself the additional search directories
# to be passed to the dynamic linker. This works great in conjunction
# with relative paths.
# This command will enable support to RPATH to your project.
# It will enable the following things:
#
# - If the project builds shared libraries it will generate a run-path
# enabled shared library, i.e. its install name will be resolved
# only at run time.
# - In all cases (building executables and/or shared libraries)
# dependent shared libraries with RPATH support will have their name
# resolved only at run time, by embedding the search path directly
# into the built binary.
#
# The command has the following parameters:
#
# Options:
# - ``USE_LINK_PATH``: if passed the command will automatically adds to
# the RPATH the path to all the dependent libraries.
#
# Arguments:
# - ``BIN_DIRS`` list of directories when the targets (executable and
# plugins) will be installed.
# - ``LIB_DIRS`` list of directories to be added to the RPATH. These
# directories will be added "relative" w.r.t. the ``BIN_DIRS`` and
# ``LIB_DIRS``.
# - ``INSTALL_NAME_DIR`` directory where the libraries will be installed.
# This variable will be used only if ``CMAKE_SKIP_RPATH`` or
# ``CMAKE_SKIP_INSTALL_RPATH`` is set to ``TRUE`` as it will set the
# ``INSTALL_NAME_DIR`` on all targets
# - ``DEPENDS`` list of conditions that should be ``TRUE`` to enable
# RPATH, for example ``FOO; NOT BAR``.
#
# Note: see https://gitlab.kitware.com/cmake/cmake/issues/16589 for further
# details.

#=======================================================================
# Copyright 2014 Istituto Italiano di Tecnologia (IIT)
# @author Francesco Romano <[email protected]>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=======================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)


include(CMakeParseArguments)


function(ADD_INSTALL_RPATH_SUPPORT)

set(_options USE_LINK_PATH)
set(_oneValueArgs INSTALL_NAME_DIR)
set(_multiValueArgs BIN_DIRS
LIB_DIRS
DEPENDS)

cmake_parse_arguments(_ARS "${_options}"
"${_oneValueArgs}"
"${_multiValueArgs}"
"${ARGN}")

# if either RPATH or INSTALL_RPATH is disabled
# and the INSTALL_NAME_DIR variable is set, then hardcode the install name
if(CMAKE_SKIP_RPATH OR CMAKE_SKIP_INSTALL_RPATH)
if(DEFINED _ARS_INSTALL_NAME_DIR)
set(CMAKE_INSTALL_NAME_DIR ${_ARS_INSTALL_NAME_DIR} PARENT_SCOPE)
endif()
endif()

if (CMAKE_SKIP_RPATH OR (CMAKE_SKIP_INSTALL_RPATH AND CMAKE_SKIP_BUILD_RPATH))
return()
endif()


set(_rpath_available 1)
if(DEFINED _ARS_DEPENDS)
foreach(_dep ${_ARS_DEPENDS})
string(REGEX REPLACE " +" ";" _dep "${_dep}")
if(NOT (${_dep}))
set(_rpath_available 0)
endif()
endforeach()
endif()

if(_rpath_available)

# Enable RPATH on OSX.
set(CMAKE_MACOSX_RPATH TRUE PARENT_SCOPE)

# Find system implicit lib directories
set(_system_lib_dirs ${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES})
if(EXISTS "/etc/debian_version") # is this a debian system ?
if(CMAKE_LIBRARY_ARCHITECTURE)
list(APPEND _system_lib_dirs "/lib/${CMAKE_LIBRARY_ARCHITECTURE}"
"/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}")
endif()
endif()
# This is relative RPATH for libraries built in the same project
foreach(lib_dir ${_ARS_LIB_DIRS})
list(FIND _system_lib_dirs "${lib_dir}" isSystemDir)
if("${isSystemDir}" STREQUAL "-1")
foreach(bin_dir ${_ARS_LIB_DIRS} ${_ARS_BIN_DIRS})
file(RELATIVE_PATH _rel_path ${bin_dir} ${lib_dir})
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
list(APPEND CMAKE_INSTALL_RPATH "@loader_path/${_rel_path}")
else()
list(APPEND CMAKE_INSTALL_RPATH "\$ORIGIN/${_rel_path}")
endif()
endforeach()
endif()
endforeach()
if(NOT "${CMAKE_INSTALL_RPATH}" STREQUAL "")
list(REMOVE_DUPLICATES CMAKE_INSTALL_RPATH)
endif()
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH} PARENT_SCOPE)

# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ${_ARS_USE_LINK_PATH} PARENT_SCOPE)

endif()

endfunction()
Loading

0 comments on commit 23f9cc6

Please sign in to comment.