Skip to content

Commit

Permalink
ROS2 packaging (#48)
Browse files Browse the repository at this point in the history
* comply ROS2

* install to lib

* fix for non-ros environments
  • Loading branch information
koide3 authored Jul 26, 2024
1 parent 59251e1 commit a7e91e7
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 13 deletions.
35 changes: 28 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ add_library(glim SHARED
target_include_directories(glim PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/json/include>
$<INSTALL_INTERFACE:include>
$<INSTALL_INTERFACE:include/glim>
${OpenCV_INCLUDE_DIRS}
)
target_link_libraries(glim
Expand Down Expand Up @@ -166,18 +166,38 @@ endif()
## Install ##
#############

include(GNUInstallDirs)
if(DEFINED ENV{ROS_VERSION})
if($ENV{ROS_VERSION} EQUAL 1)
# No idea
set(CMAKE_INSTALL_INCLUDEDIR "include/glim")
set(CMAKE_INSTALL_LIBDIR "lib")
set(CMAKE_INSTALL_BINDIR "bin/glim")
set(CMAKE_INSTALL_DATADIR "share/glim")
set(CMAKE_CONFIG_INSTALL_DIR "share/glim")
elseif($ENV{ROS_VERSION} EQUAL 2)
set(CMAKE_INSTALL_INCLUDEDIR "include/glim")
set(CMAKE_INSTALL_LIBDIR "lib")
set(CMAKE_INSTALL_BINDIR "bin/glim")
set(CMAKE_INSTALL_DATADIR "share/glim")
set(CMAKE_CONFIG_INSTALL_DIR "share/glim")
else()
message(FATAL_ERROR "Unsupported ROS version")
endif()
else()
include(GNUInstallDirs)
set(CMAKE_CONFIG_INSTALL_DIR
"${CMAKE_INSTALL_LIBDIR}/cmake/glim"
CACHE PATH "Install directory for CMake config files"
)
endif()

install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(TARGETS ${glim_LIBRARIES}
EXPORT glim-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
set(CMAKE_CONFIG_INSTALL_DIR
"${CMAKE_INSTALL_LIBDIR}/cmake/glim"
CACHE PATH "Install directory for CMake config files"
)
include(CMakePackageConfigHelpers)
install(EXPORT glim-targets
FILE glim-targets.cmake
Expand Down Expand Up @@ -210,7 +230,8 @@ if(DEFINED ENV{ROS_VERSION})
install(DIRECTORY config DESTINATION share/glim)
ament_export_include_directories(include ${EIGEN3_INCLUDE_DIR} ${OpenCV_INCLUDE_DIRS})
ament_export_libraries(${glim_LIBRARIES} ${GTSAM_LIBRARIES} fmt spdlog::spdlog)
ament_package()
ament_export_interfaces(glim-targets HAS_LIBRARY_TARGET)
ament_package(CONFIG_EXTRAS "cmake/glim-config.cmake.in")
elseif($ENV{ROS_VERSION} EQUAL 1)
# ROS1
find_package(catkin REQUIRED)
Expand Down
12 changes: 7 additions & 5 deletions include/glim/util/config_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,13 @@ T Config::param_cast_nested(const std::vector<std::string>& nested_module_names,
return *found;
}

#define DEFINE_CONFIG_IO_SPECIALIZATION(TYPE) \
template TYPE Config::param(const std::string&, const std::string&, const TYPE&) const; \
template TYPE Config::param_cast(const std::string&, const std::string&) const; \
template TYPE Config::param_nested(const std::vector<std::string>&, const std::string&, const TYPE&) const; \
template TYPE Config::param_cast_nested(const std::vector<std::string>&, const std::string&) const; \
#define DEFINE_CONFIG_IO_SPECIALIZATION(TYPE) \
template std::optional<TYPE> Config::param(const std::string& module_name, const std::string& param_name) const; \
template TYPE Config::param(const std::string&, const std::string&, const TYPE&) const; \
template TYPE Config::param_cast(const std::string&, const std::string&) const; \
template std::optional<TYPE> Config::param_nested(const std::vector<std::string>& nested_module_names, const std::string& param_name) const; \
template TYPE Config::param_nested(const std::vector<std::string>&, const std::string&, const TYPE&) const; \
template TYPE Config::param_cast_nested(const std::vector<std::string>&, const std::string&) const; \
template bool Config::override_param(const std::string&, const std::string&, const TYPE&);

} // namespace glim
2 changes: 1 addition & 1 deletion package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>glim</name>
<version>0.0.0</version>
<version>1.0.1</version>
<description>3D LiDAR-IMU mapping framework</description>
<maintainer email="[email protected]">k.koide</maintainer>
<license>MIT</license>
Expand Down

0 comments on commit a7e91e7

Please sign in to comment.