Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for the ROS build system #88

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,41 @@ if (WIN32)
endif()
endif()

set(INSTALL_CMAKE_DIR share/EIPScanner/cmake CACHE PATH
"Installation directory for CMake files")
# ... for the build tree
set(INSTALL_INCLUDE_DIR include/EIPScanner CACHE PATH
"Installation directory for header files")
# ... for the build tree
set(INSTALL_LIB_DIR lib CACHE PATH
"Installation directory for header files")
# Make relative paths absolute (needed later on)
# foreach(p LIB BIN INCLUDE CMAKE)
foreach(p LIB INCLUDE CMAKE)
set(var INSTALL_${p}_DIR)
if(NOT IS_ABSOLUTE "${${var}}")
set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}")
endif()
endforeach()

file(RELATIVE_PATH REL_INCLUDE_DIR "${INSTALL_CMAKE_DIR}"
"${INSTALL_INCLUDE_DIR}")
set(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}")
configure_file(EIPScannerConfig.cmake.in
"${PROJECT_BINARY_DIR}/EIPScannerConfig.cmake" @ONLY)
# ... for the install tree
set(CONF_INCLUDE_DIRS "\${EIPScanner_CMAKE_DIR}/${REL_INCLUDE_DIR}")
configure_file(EIPScannerConfig.cmake.in
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/EIPScannerConfig.cmake" @ONLY)
# ... for both
configure_file(EIPScannerConfigVersion.cmake.in
"${PROJECT_BINARY_DIR}/EIPScannerConfigVersion.cmake" @ONLY)
# Install the EIPScannerConfig.cmake and EIPScannerConfigVersion.cmake
install(FILES
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/EIPScannerConfig.cmake"
"${PROJECT_BINARY_DIR}/EIPScannerConfigVersion.cmake"
DESTINATION "${INSTALL_CMAKE_DIR}" COMPONENT dev)

add_subdirectory(src)
if (EXAMPLE_ENABLED)
add_subdirectory(examples)
Expand All @@ -31,3 +66,6 @@ if (TEST_ENABLED)
add_subdirectory(test)
endif()

include(GNUInstallDirs)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/package.xml
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME})
36 changes: 36 additions & 0 deletions EIPScannerConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# - Config file for the EIPScanner package
# It defines the following variables
# EIPScanner_INCLUDE_DIRS - include directories for EIPScanner
# EIPscanner_LIBRARIES - libraries to link against
# EIPScanner_EXECUTABLE - the executable

# Compute paths
get_filename_component(EIPScanner_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)

set(_include_directories "@CONF_INCLUDE_DIRS@")
if(NOT _include_directories STREQUAL "")
foreach(_include_dir ${_include_directories})
if(NOT IS_DIRECTORY "${_include_dir}")
message(WARNING "Package '@PROJECT_NAME@' exports the
include directory '${_include_dir}' which doesn't exist")
endif()
list(APPEND @PROJECT_NAME@_INCLUDE_DIRS "${_include_dir}")
endforeach()
endif()

# Our library dependencies (contains definitions for IMPORTED targets)
# include("${EIPSCANNER_CMAKE_DIR}/EIPScannerTargets.cmake")

# These are IMPORTED targets created by FooBarTargets.cmake
set(EIPScanner_LIBRARIES EIPScanner)

set(_lib_dirs "@INSTALL_LIB_DIR@")
if(NOT _lib_dirs STREQUAL "")
foreach(_lib_dir ${_lib_dirs})
if(NOT IS_DIRECTORY "${_lib_dir}")
message(WARNING "Package '@PROJECT_NAME@' exports the
include directory '${_lib_dir}' which doesn't exist")
endif()
list(APPEND @PROJECT_NAME@_LIBRARY_DIRS "${_lib_dir}")
endforeach()
endif()
13 changes: 13 additions & 0 deletions EIPScannerConfigVersion.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
set(PACKAGE_VERSION "@EIPSCANNER_FULL_VERSION@")

# Check whether the requested PACKAGE_FIND_VERSION is compatible
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_EXACT TRUE)
endif()
endif()


22 changes: 22 additions & 0 deletions package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>

<!-- A package.xml in the root of a cmake projects allows it to be built using catkin or colcon (the ROS build system) -->

<package format="2">
<name>EIPScanner</name>
<version>1.3.0</version>
<description>
Free implementation of EtherNet/IP in C++
</description>

<maintainer email="[email protected]">Aleksey Timin</maintainer>

<license>MIT</license>

<buildtool_depend>cmake</buildtool_depend>

<export>
<build_type>cmake</build_type>
</export>
</package>
8 changes: 4 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ set_target_properties(

install(TARGETS EIPScanner EIPScannerS
LIBRARY
DESTINATION lib
DESTINATION "${INSTALL_LIB_DIR}"
ARCHIVE
DESTINATION lib)
DESTINATION "${INSTALL_LIB_DIR}")

install(DIRECTORY ${PROJECT_SOURCE_DIR}/src/
DESTINATION include/EIPScanner
install(DIRECTORY "${PROJECT_SOURCE_DIR}/src/"
DESTINATION "${INSTALL_INCLUDE_DIR}"
FILES_MATCHING PATTERN "*.h*")