Add build files
This commit is contained in:
parent
cb6dc3367f
commit
ad8894d12b
2 changed files with 113 additions and 0 deletions
94
tracetools/CMakeLists.txt
Normal file
94
tracetools/CMakeLists.txt
Normal file
|
@ -0,0 +1,94 @@
|
|||
cmake_minimum_required(VERSION 3.5)
|
||||
project(tracetools)
|
||||
|
||||
# Default to C++14
|
||||
if(NOT CMAKE_CXX_STANDARD)
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
add_compile_options(-Wall -Wextra -Wpedantic -fPIC)
|
||||
endif()
|
||||
|
||||
find_package(ament_cmake REQUIRED)
|
||||
|
||||
option(WITH_LTTNG "Include support for tracing with LTTng" OFF)
|
||||
if(WITH_LTTNG)
|
||||
# Try to find LTTng
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(LTTNG REQUIRED lttng-ust)
|
||||
endif()
|
||||
if(LTTNG_FOUND)
|
||||
# Generate necessary LTTng files
|
||||
# If successful, enable tracing
|
||||
add_custom_command(OUTPUT ${PROJECT_SOURCE_DIR}/src/tp_call.c
|
||||
COMMAND lttng-gen-tp tp_call.tp -o ../src/tp_call.c -o ../src/tp_call.h
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/lttng
|
||||
DEPENDS ${PROJECT_SOURCE_DIR}/lttng/tp_call.tp
|
||||
)
|
||||
set(LTTNG_GENERATED
|
||||
src/tp_call.h
|
||||
src/tp_call.c
|
||||
)
|
||||
set(TRACING_ENABLED TRUE)
|
||||
message("LTTng found: tracing enabled")
|
||||
elseif(WITH_LTTNG)
|
||||
message("LTTng NOT found: tracing disabled")
|
||||
endif()
|
||||
|
||||
include_directories(include)
|
||||
|
||||
# Status checking tool
|
||||
add_executable(${PROJECT_NAME}_status
|
||||
src/status.c
|
||||
src/tracetools.c
|
||||
)
|
||||
target_link_libraries(${PROJECT_NAME}_status
|
||||
${PROJECT_NAME}
|
||||
)
|
||||
ament_target_dependencies(${PROJECT_NAME}_status
|
||||
${PROJECT_NAME}
|
||||
)
|
||||
install(TARGETS
|
||||
${PROJECT_NAME}_status
|
||||
DESTINATION lib/${PROJECT_NAME}
|
||||
)
|
||||
|
||||
# Tracetools lib
|
||||
set(SOURCES
|
||||
src/tracetools.c
|
||||
)
|
||||
if(TRACING_ENABLED)
|
||||
list(APPEND SOURCES ${LTTNG_GENERATED})
|
||||
endif()
|
||||
|
||||
add_library(${PROJECT_NAME} ${SOURCES})
|
||||
if(TRACING_ENABLED)
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC WITH_LTTNG)
|
||||
target_link_libraries(${PROJECT_NAME} ${LTTNG_LIBRARIES} -ldl)
|
||||
else()
|
||||
target_link_libraries(${PROJECT_NAME})
|
||||
endif()
|
||||
|
||||
ament_export_interfaces(${PROJECT_NAME}_export HAS_LIBRARY_TARGET)
|
||||
install(
|
||||
DIRECTORY include/
|
||||
DESTINATION include
|
||||
)
|
||||
install(
|
||||
TARGETS ${PROJECT_NAME}
|
||||
EXPORT ${PROJECT_NAME}_export
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib
|
||||
RUNTIME DESTINATION bin
|
||||
INCLUDES DESTINATION include
|
||||
)
|
||||
|
||||
ament_export_include_directories(include)
|
||||
if(TRACING_ENABLED)
|
||||
ament_export_libraries(${PROJECT_NAME} ${LTTNG_LIBRARIES})
|
||||
else()
|
||||
ament_export_libraries(${PROJECT_NAME})
|
||||
endif()
|
||||
|
||||
ament_package()
|
19
tracetools/package.xml
Normal file
19
tracetools/package.xml
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
||||
<package format="2">
|
||||
<name>tracetools</name>
|
||||
<version>0.0.1</version>
|
||||
<description>ROS 2 wrapper for instrumentation</description>
|
||||
<author email="bedard.christophe@gmail.com">Christophe Bedard</author>
|
||||
<maintainer email="bedard.christophe@gmail.com">Christophe Bedard</maintainer>
|
||||
<license>APLv2</license>
|
||||
|
||||
<buildtool_depend>ament_cmake</buildtool_depend>
|
||||
<buildtool_depend>pkg-config</buildtool_depend>
|
||||
|
||||
<!-- explicitly not depending on LTTng -->
|
||||
|
||||
<export>
|
||||
<build_type>ament_cmake</build_type>
|
||||
</export>
|
||||
</package>
|
Loading…
Add table
Add a link
Reference in a new issue