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

Plain cmake #69

Merged
merged 19 commits into from
May 20, 2020
Merged
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
11 changes: 6 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
sudo: required
language: generic
dist: trusty
services:
- docker

env:
global:
- BEFORE_SCRIPT='./setup_poco_ppa.sh'
- AFTER_INIT='./setup_poco_ppa.sh'
matrix:
- ROS_DISTRO="kinetic" ROS_REPO=ros NOT_TEST_INSTALL=true CATKIN_LINT=true
- ROS_DISTRO="kinetic" ROS_REPO=ros CATKIN_LINT=true
- ROS_DISTRO="dashing" ROS_REPO=ros

install:
- git clone --depth=1 https://github.com/ros-industrial/industrial_ci.git .ci_config
- git clone --depth=1 -b master https://github.com/ros-industrial/industrial_ci.git .ci_config

script:
- .ci_config/travis.sh
130 changes: 106 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,45 +1,127 @@
cmake_minimum_required(VERSION 2.8.12)
project(abb_librws)
cmake_minimum_required(VERSION 3.5)

find_package(catkin REQUIRED COMPONENTS cmake_modules)
# Read version from the package.xml file.
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/package.xml package_xml_str)
if(NOT package_xml_str MATCHES "<version>([0-9]+.[0-9]+.[0-9]+)</version>")
message(FATAL_ERROR "Could not parse project version from package.xml. Aborting.")
endif()

# At this point we either have a proper version string, or we've errored
# out with a FATAL_ERROR above. So assume CMAKE_MATCH_1 contains our
# package's version.
project(abb_librws VERSION ${CMAKE_MATCH_1} LANGUAGES CXX)

include(GNUInstallDirs)

list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/third_party")

if(WIN32)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif()

########################
## POCO C++ Libraries ##
########################
# we need at least 1.4.3 because of websocket support
find_package(Poco 1.4.3 REQUIRED COMPONENTS Net Util Foundation XML)

###################################
## catkin specific configuration ##
###################################
catkin_package(INCLUDE_DIRS include
LIBRARIES ${PROJECT_NAME}
DEPENDS Poco)
# We need at least 1.4.3 because of WebSocket support.
find_package(Poco 1.4.3 REQUIRED COMPONENTS Foundation Net Util XML)

###########
## Build ##
###########
set(SRC_FILES
if(NOT DEFINED BUILD_SHARED_LIBS)
option(BUILD_SHARED_LIBS "Build dynamically-linked binaries" ON)
endif()

set(
SRC_FILES
src/rws_client.cpp
src/rws_common.cpp
src/rws_interface.cpp
src/rws_poco_client.cpp
src/rws_rapid.cpp
src/rws_state_machine_interface.cpp)

include_directories(include
${Poco_INCLUDE_DIRS}
${catkin_INCLUDE_DIRS})
src/rws_state_machine_interface.cpp
)

add_library(${PROJECT_NAME} ${SRC_FILES})
target_link_libraries(${PROJECT_NAME} ${Poco_LIBRARIES} ${catkin_LIBRARIES})
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})

include(GenerateExportHeader)
generate_export_header(${PROJECT_NAME})

target_include_directories(${PROJECT_NAME} PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include;${CMAKE_CURRENT_BINARY_DIR}>"
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>
${Poco_INCLUDE_DIRS}
gavanderhoorn marked this conversation as resolved.
Show resolved Hide resolved
)

target_link_libraries(${PROJECT_NAME} PUBLIC
${Poco_LIBRARIES}
)

if(NOT BUILD_SHARED_LIBS)
target_compile_definitions(${PROJECT_NAME} PUBLIC "ABB_LIBRWS_STATIC_DEFINE")
endif()

#############
## Install ##
#############
install(TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION})
install(
DIRECTORY include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_export.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
)

install(
DIRECTORY cmake/modules/third_party/
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake
)

install(
TARGETS ${PROJECT_NAME}
EXPORT export_${PROJECT_NAME}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

include(CMakePackageConfigHelpers)

# Create the ${PROJECT_NAME}Config.cmake.
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/${PROJECT_NAME}Config.cmake.in
"${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${PROJECT_NAME}Config.cmake" @ONLY
)

# Create the ${PROJECT_NAME}ConfigVersion.cmake.
write_basic_package_version_file(
${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
COMPATIBILITY AnyNewerVersion
)

install(
FILES
"${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${PROJECT_NAME}Config.cmake"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/package.xml"
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}
)

# Export targets.
set(export_targets ${export_targets};${PROJECT_NAME})
export(
EXPORT export_${PROJECT_NAME}
FILE "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake"
NAMESPACE ${PROJECT_NAME}::
)

install(DIRECTORY include
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
FILES_MATCHING PATTERN "*.h")
install(
EXPORT export_${PROJECT_NAME}
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}
FILE ${PROJECT_NAME}Targets.cmake
NAMESPACE ${PROJECT_NAME}::
)
16 changes: 16 additions & 0 deletions cmake/abb_librwsConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# - Config file for the abb_librws package
# It defines the following variable
# abb_librws_LIBRARIES - libraries to link against

include(CMakeFindDependencyMacro)

list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

# Find dependencies
find_dependency(Poco 1.4.3 REQUIRED COMPONENTS Foundation Net Util XML)

# Our library dependencies (contains definitions for IMPORTED targets)
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")

# These are IMPORTED targets created by @PROJECT_NAME@Targets.cmake
set(abb_librws_LIBRARIES @PROJECT_NAME@::@PROJECT_NAME@)
207 changes: 207 additions & 0 deletions cmake/modules/third_party/FindPoco.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
# - Find the Poco includes and libraries.
# The following variables are set if Poco is found. If Poco is not
# found, Poco_FOUND is set to false.
# Poco_FOUND - True when the Poco include directory is found.
# Poco_INCLUDE_DIRS - the path to where the poco include files are.
# Poco_LIBRARY_DIR - The path to where the poco library files are.
# Poco_BINARY_DIRS - The path to where the poco dlls are.
# Poco_LIBRARIES - list of all libs from requested components.

# ----------------------------------------------------------------------------
# If you have installed Poco in a non-standard location.
# Then you have three options.
# In the following comments, it is assumed that <Your Path>
# points to the root directory of the include directory of Poco. e.g
# If you have put poco in C:\development\Poco then <Your Path> is
# "C:/development/Poco" and in this directory there will be two
# directories called "include" and "lib".
# 1) After CMake runs, set Poco_INCLUDE_DIR to <Your Path>/poco<-version>
# 2) Use CMAKE_INCLUDE_PATH to set a path to <Your Path>/poco<-version>. This will allow FIND_PATH()
# to locate Poco_INCLUDE_DIR by utilizing the PATH_SUFFIXES option. e.g.
# SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "<Your Path>/include")
# 3) Set an environment variable called ${POCO_ROOT} that points to the root of where you have
# installed Poco, e.g. <Your Path>. It is assumed that there is at least a subdirectory called
# Foundation/include/Poco in this path.
#
# Note:
# 1) If you are just using the poco headers, then you do not need to use
# Poco_LIBRARY_DIR in your CMakeLists.txt file.
# 2) If Poco has not been installed, then when setting Poco_LIBRARY_DIR
# the script will look for /lib first and, if this fails, then for /stage/lib.
#
# Usage:
# In your CMakeLists.txt file do something like this:
# ...
# # Poco
# FIND_PACKAGE(Poco COMPONENTS XML Net Data...)
# ...
# INCLUDE_DIRECTORIES(${Poco_INCLUDE_DIRS})
# LINK_DIRECTORIES(${Poco_LIBRARY_DIR})
#
# In Windows, we make the assumption that, if the Poco files are installed, the default directory
# will be C:\poco or C:\Program Files\Poco or C:\Programme\Poco.

MESSAGE(STATUS "Searching for Poco library...")

SET(POCO_INCLUDE_PATH_DESCRIPTION "top-level directory containing the poco include directories. E.g /usr/local/include/ or c:\\poco\\include\\poco-1.3.2")
SET(POCO_INCLUDE_DIR_MESSAGE "Set the Poco_INCLUDE_DIR cmake cache entry to the ${POCO_INCLUDE_PATH_DESCRIPTION}")
SET(POCO_LIBRARY_PATH_DESCRIPTION "top-level directory containing the poco libraries.")
SET(POCO_LIBRARY_DIR_MESSAGE "Set the Poco_LIBRARY_DIR cmake cache entry to the ${POCO_LIBRARY_PATH_DESCRIPTION}")


SET(POCO_DIR_SEARCH $ENV{POCO_ROOT})
IF(POCO_DIR_SEARCH)
FILE(TO_CMAKE_PATH ${POCO_DIR_SEARCH} POCO_DIR_SEARCH)
ENDIF(POCO_DIR_SEARCH)


IF(WIN32)
SET(POCO_DIR_SEARCH
${POCO_DIR_SEARCH}
C:/poco
D:/poco
"C:/Program Files/poco"
"C:/Programme/poco"
"D:/Program Files/poco"
"D:/Programme/poco"
)
ENDIF(WIN32)

# Add in some path suffixes. These will have to be updated whenever a new Poco version comes out.
SET(SUFFIX_FOR_INCLUDE_PATH
poco-1.3.2
poco-1.3.3
poco-1.3.4
poco-1.3.5
poco-1.3.6
)

SET(SUFFIX_FOR_LIBRARY_PATH
poco-1.3.2/lib
poco-1.3.2/lib/Linux/i686
poco-1.3.2/lib/Linux/x86_64
poco-1.3.3/lib
poco-1.3.3/lib/Linux/i686
poco-1.3.3/lib/Linux/x86_64
poco-1.3.4/lib
poco-1.3.4/lib/Linux/i686
poco-1.3.4/lib/Linux/x86_64
poco-1.3.5/lib
poco-1.3.5/lib/Linux/i686
poco-1.3.5/lib/Linux/x86_64
poco-1.3.6/lib
poco-1.3.6/lib/Linux/i686
poco-1.3.6/lib/Linux/x86_64
lib
lib/Linux/i686
lib/Linux/x86_64
)

#
# Look for an installation.
#
FIND_PATH(Poco_INCLUDE_DIR NAMES Foundation/include/Poco/SharedLibrary.h PATH_SUFFIXES ${SUFFIX_FOR_INCLUDE_PATH} PATHS

# Look in other places.
${POCO_DIR_SEARCH}

# Help the user find it if we cannot.
DOC "The ${POCO_INCLUDE_PATH_DESCRIPTION}"
)

IF(NOT Poco_INCLUDE_DIR)

# Look for standard unix include paths
FIND_PATH(Poco_INCLUDE_DIR Poco/Poco.h DOC "The ${POCO_INCLUDE_PATH_DESCRIPTION}")

ENDIF(NOT Poco_INCLUDE_DIR)

# Assume we didn't find it.
SET(Poco_FOUND 0)

# Now try to get the include and library path.
IF(Poco_INCLUDE_DIR)
IF(EXISTS "${Poco_INCLUDE_DIR}/Foundation/include/Poco/SharedLibrary.h")
SET(Poco_INCLUDE_DIRS
${Poco_INCLUDE_DIR}/CppUnit/include
${Poco_INCLUDE_DIR}/Foundation/include
${Poco_INCLUDE_DIR}/Net/include
${Poco_INCLUDE_DIR}/Util/include
${Poco_INCLUDE_DIR}/XML/include
)
SET(Poco_FOUND 1)
ELSEIF(EXISTS "${Poco_INCLUDE_DIR}/Poco/Poco.h")
SET(Poco_INCLUDE_DIRS
${Poco_INCLUDE_DIR}
)
SET(Poco_FOUND 1)
ENDIF()

IF(NOT Poco_LIBRARY_DIR)

FIND_LIBRARY(Poco_FOUNDATION_LIB NAMES PocoFoundation PocoFoundationd PATH_SUFFIXES ${SUFFIX_FOR_LIBRARY_PATH} PATHS

# Look in other places.
${Poco_INCLUDE_DIR}
${POCO_DIR_SEARCH}

# Help the user find it if we cannot.
DOC "The ${POCO_LIBRARY_PATH_DESCRIPTION}"
)
SET(Poco_LIBRARY_DIR "" CACHE PATH POCO_LIBARARY_PATH_DESCRIPTION)
GET_FILENAME_COMPONENT(Poco_LIBRARY_DIR ${Poco_FOUNDATION_LIB} PATH)
SET(Poco_LIBRARIES "")
SET(Comp_List "")
IF(Poco_LIBRARY_DIR AND Poco_FOUNDATION_LIB)
# Look for the poco binary path.
SET(Poco_BINARY_DIR ${Poco_INCLUDE_DIR})
IF(Poco_BINARY_DIR AND EXISTS "${Poco_BINARY_DIR}/bin")
SET(Poco_BINARY_DIRS ${Poco_BINARY_DIR}/bin)
ENDIF(Poco_BINARY_DIR AND EXISTS "${Poco_BINARY_DIR}/bin")
ENDIF(Poco_LIBRARY_DIR AND Poco_FOUNDATION_LIB)
SET(DBG "")
IF(Poco_FOUNDATION_LIB)
IF ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
# Check that separate debug libraries are actually present.
FIND_LIBRARY(LIBFoundation "PocoFoundationd" Poco_LIBRARY_DIR)
IF(LIBFoundation)
SET(DBG "d")
ENDIF(LIBFoundation)
ENDIF ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
SET(Comp_List "Foundation${DBG}")
FOREACH(COMPONENT ${Poco_FIND_COMPONENTS})
FIND_LIBRARY(LIB${COMPONENT} "Poco${COMPONENT}${DBG}" Poco_LIBRARY_DIR)
IF (LIB${COMPONENT})
LIST(APPEND Poco_LIBRARIES "${LIB${COMPONENT}}")
LIST(APPEND Comp_List "${COMPONENT}${DBG}")
ENDIF(LIB${COMPONENT})
ENDFOREACH(COMPONENT)
LIST(REMOVE_DUPLICATES Comp_List)
ENDIF(Poco_FOUNDATION_LIB)
ENDIF(NOT Poco_LIBRARY_DIR)
ENDIF(Poco_INCLUDE_DIR)

IF(NOT Poco_FOUND)
IF(Poco_FIND_QUIETLY)
MESSAGE(STATUS "Poco was not found. ${POCO_INCLUDE_DIR_MESSAGE}")
ELSE(Poco_FIND_QUIETLY)
IF(Poco_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Poco was not found. ${POCO_INCLUDE_DIR_MESSAGE}")
ENDIF(Poco_FIND_REQUIRED)
ENDIF(Poco_FIND_QUIETLY)
ELSE(NOT Poco_FOUND)
MESSAGE(STATUS " Found Poco!")
SET(COMPONENT_STR "components found:")
FOREACH(comp ${Comp_List})
SET(COMPONENT_STR "${COMPONENT_STR}, ${comp}")

ENDFOREACH(comp ${Comp_List})
STRING(REPLACE ":," ":" COMPONENT_LSTR ${COMPONENT_STR})
MESSAGE(STATUS "${COMPONENT_LSTR}.")
ENDIF(NOT Poco_FOUND)

#I added this in to add "libdl" on non-Windows systems. Technically dl is only neded if the "Foundation" component is used,
#but i doesn't hurt to add it in anyway - mas
if(Poco_FOUND AND NOT WIN32)
LIST(APPEND Poco_LIBRARIES "dl")
endif(Poco_FOUND AND NOT WIN32)
Loading