Skip to content

Commit

Permalink
chore: make compatible with ament
Browse files Browse the repository at this point in the history
  • Loading branch information
dracad-greenroom committed Sep 11, 2024
1 parent e3429b2 commit 79a04a0
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 26 deletions.
55 changes: 33 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,17 @@ project("dbcppp" VERSION 3.8.0)

set(CMAKE_CXX_STANDARD 17)
option(build_kcd "Enable support for KCD parsing" ON)
option(build_tools "Build dbcppp utility application" ON)
option(build_tools "Build dbcppp utility application" OFF)

option(build_tests "Build tests" ON)
option(build_examples "Build examples" ON)
option(build_tests "Build tests" OFF)
option(build_examples "Build examples" OFF)


# DEPENDENCIES & Requirements

find_package(Boost)

if(NOT Boost_FOUND)
message(WARNING "Boost not found. Using libdbcppp boost (third-party/boost)")
include_directories("third-party/boost")
endif()
find_package(ament_cmake REQUIRED)
find_package(Boost REQUIRED)
find_package(cxxopts REQUIRED)

# kcd is an xml based can database
message("kcd enabled: ${build_kcd}")
Expand All @@ -31,6 +28,8 @@ if(build_kcd)

find_package(LibXml2)

include_directories(${LIBXML2_INCLUDE_DIR})

if (NOT LibXml2_FOUND)
message(WARNING "LibXml2 was not found. Using libdbcppp LibXml2 (third-party/libxml2)")
set(LIBXML2_WITH_ICONV OFF)
Expand All @@ -42,9 +41,10 @@ if(build_kcd)
endif()

# libxmlmm (no find package because it is certainly not installed
find_package(libxmlmm REQUIRED)

add_subdirectory("third-party/libxmlmm")
target_include_directories(libxmlmm PUBLIC third-party/libxmlmm/libxmlmm ${LIBXML2_INCLUDE_DIR})
# add_subdirectory("third-party/libxmlmm")
# target_include_directories(libxmlmm PUBLIC third-party/libxmlmm/libxmlmm ${LIBXML2_INCLUDE_DIR})
endif()


Expand All @@ -59,8 +59,14 @@ add_library(${PROJECT_NAME} SHARED ${include} ${headers} ${sources})

# CONFIGURE LIBRARY

target_link_libraries(${PROJECT_NAME} ${LIBXML2_LIBRARIES} )

if (build_kcd)
target_link_libraries(${PROJECT_NAME} PUBLIC libxmlmm)

ament_target_dependencies(${PROJECT_NAME}
libxmlmm
)

endif()

set_target_properties(${PROJECT_NAME} PROPERTIES
Expand All @@ -69,25 +75,26 @@ set_target_properties(${PROJECT_NAME} PROPERTIES
)

target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/dbcppp>
$<INSTALL_INTERFACE:include/dbcppp>
include/
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)

# INSTALL LIBRARY

install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
PUBLIC_HEADER DESTINATION include/dbcppp
install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION lib/${PROJECT_NAME}
)


install(
DIRECTORY include/
DESTINATION include
)
# ADDITIONAL: Tools, Tests & Examples

if (build_tools)
add_subdirectory(third-party/cxxopts)
# add_subdirectory(third-party/cxxopts)
add_subdirectory(tools/dbcppp)
endif()

Expand All @@ -106,3 +113,7 @@ set(CPACK_VERBATIM_VARIABLES YES)
set(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_SOURCE_IGNORE_FILES \\.git/ build/ ".*~$")
include(CPack)

ament_export_include_directories(include)
ament_export_targets(${PROJECT_NAME})
ament_package()
10 changes: 6 additions & 4 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
href="http://download.ros.org/schema/package_format2.xsd"
schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="2">
<name>dbccpp</name>
<name>dbcppp</name>
<version>1.0.0</version>
<description>A C/C++ DBC file parser based on `boost.spirit`.</description>
<maintainer email="[email protected]">Russ Webber</maintainer>
<license>BSL</license>

<url type="website">https://github.com/Greenroom-Robotics/dbcppp</url>

<!-- <depend>asio</depend> -->
<!-- <depend>libboost-system-dev</depend> -->
<depend>libxml2</depend>
<depend>boost</depend>
<depend>libxmlmm</depend>
<depend>libcxxopts</depend>

<export>
<build_type>cmake</build_type>
</export>
</package>
</package>

0 comments on commit 79a04a0

Please sign in to comment.