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

Export a modern CMake target instead of variables and install includes to include/${PROJECT_NAME} #218

Merged
merged 11 commits into from
Dec 24, 2021
33 changes: 17 additions & 16 deletions camera_calibration_parsers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,30 @@ find_package(rcpputils REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(yaml_cpp_vendor REQUIRED)

include_directories(include)

# define the library
add_library(${PROJECT_NAME}
src/parse.cpp
src/parse_ini.cpp
src/parse_yml.cpp
)
target_link_libraries(${PROJECT_NAME} PUBLIC
${sensor_msgs_TARGETS}
${yaml_cpp_vendor_TARGETS})
target_link_libraries(${PROJECT_NAME} PRIVATE
rclcpp::rclcpp
rcpputils::rcpputils)

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

target_compile_definitions(${PROJECT_NAME} PRIVATE "CAMERA_CALIBRATION_PARSERS_BUILDING_DLL")

if(CMAKE_COMPILER_IS_GNUCXX)
target_link_libraries(${PROJECT_NAME} stdc++fs)
target_link_libraries(${PROJECT_NAME} PUBLIC stdc++fs)
endif()

ament_target_dependencies(
${PROJECT_NAME}
rclcpp
rcpputils
sensor_msgs
yaml_cpp_vendor
)
ament_export_targets(export_${PROJECT_NAME})

# TODO: Reenable Python Wrapper with new serialization technique.
#find_package(PythonLibs REQUIRED)
Expand All @@ -59,10 +61,12 @@ ament_target_dependencies(

# define the exe to convert
add_executable(convert src/convert.cpp)
target_link_libraries(convert ${PROJECT_NAME})
target_link_libraries(convert
${PROJECT_NAME}
rclcpp::rclcpp)

install(
TARGETS ${PROJECT_NAME}
TARGETS ${PROJECT_NAME} EXPORT export_${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
Expand All @@ -75,14 +79,11 @@ install(

install(
DIRECTORY include/
DESTINATION include
DESTINATION include/${PROJECT_NAME}
)

ament_export_include_directories(include)
ament_export_libraries(${PROJECT_NAME})
ament_export_dependencies(rclcpp rcpputils sensor_msgs yaml_cpp_vendor)


if(BUILD_TESTING)
#TODO(mjcarroll) switch back to this once I can fix copyright check
#find_package(ament_lint_auto REQUIRED)
Expand Down
31 changes: 13 additions & 18 deletions camera_info_manager/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,37 +23,32 @@ find_package(rclcpp REQUIRED)
find_package(rcpputils REQUIRED)
find_package(sensor_msgs REQUIRED)

include_directories(include)

# add a library
add_library(${PROJECT_NAME} src/camera_info_manager.cpp)

target_include_directories(${PROJECT_NAME} PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>")
target_compile_definitions(${PROJECT_NAME} PRIVATE "CAMERA_INFO_MANAGER_BUILDING_DLL")

ament_target_dependencies(
${PROJECT_NAME}
ament_index_cpp
camera_calibration_parsers
rclcpp
rcpputils
sensor_msgs
)
target_link_libraries(${PROJECT_NAME} PUBLIC
rclcpp::rclcpp
${sensor_msgs_TARGETS})
target_link_libraries(${PROJECT_NAME} PRIVATE
ament_index_cpp::ament_index_cpp
camera_calibration_parsers::camera_calibration_parsers
rcpputils::rcpputils)

install(
TARGETS ${PROJECT_NAME}
EXPORT export_${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)

install(
DIRECTORY include/
DESTINATION include
)
install(DIRECTORY include/ DESTINATION include/${PROJECT_NAME})

ament_export_include_directories(include)
ament_export_dependencies(ament_index_cpp camera_calibration_parsers rclcpp rcpputils sensor_msgs)
ament_export_libraries(${PROJECT_NAME})
ament_export_targets(export_${PROJECT_NAME})

if(BUILD_TESTING)
#TODO(mjcarroll) switch back to this once I can fix copyright check
Expand Down
40 changes: 21 additions & 19 deletions image_transport/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ find_package(pluginlib REQUIRED)
find_package(rclcpp REQUIRED)
find_package(sensor_msgs REQUIRED)

include_directories(include)

# Build image_transport library
add_library(${PROJECT_NAME}
src/camera_common.cpp
Expand All @@ -30,14 +28,15 @@ add_library(${PROJECT_NAME}
src/camera_subscriber.cpp
src/image_transport.cpp
)

ament_target_dependencies(
${PROJECT_NAME}
message_filters
pluginlib
rclcpp
sensor_msgs
)
target_include_directories(${PROJECT_NAME} PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>")
target_link_libraries(${PROJECT_NAME} PUBLIC
message_filters::message_filters
rclcpp::rclcpp
${sensor_msgs_TARGETS})
target_link_libraries(${PROJECT_NAME} PRIVATE
pluginlib::pluginlib)

target_compile_definitions(${PROJECT_NAME} PUBLIC "PLUGINLIB__DISABLE_BOOST_FUNCTIONS")
target_compile_definitions(${PROJECT_NAME} PRIVATE "IMAGE_TRANSPORT_BUILDING_DLL")
Expand All @@ -46,15 +45,21 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE "IMAGE_TRANSPORT_BUILDING_DLL
add_library(${PROJECT_NAME}_plugins
src/manifest.cpp
)
target_link_libraries(${PROJECT_NAME}_plugins ${PROJECT_NAME})
target_link_libraries(${PROJECT_NAME}_plugins PRIVATE
${PROJECT_NAME}
pluginlib::pluginlib)

# Build list_transports
add_executable(list_transports src/list_transports.cpp)
target_link_libraries(list_transports ${PROJECT_NAME})
target_link_libraries(list_transports
${PROJECT_NAME}
pluginlib::pluginlib)

# Build republish
add_executable(republish src/republish.cpp)
target_link_libraries(republish ${PROJECT_NAME})
target_link_libraries(republish
${PROJECT_NAME}
pluginlib::pluginlib)

# Install plugin descriptions
pluginlib_export_plugin_description_file(image_transport default_plugins.xml)
Expand All @@ -66,6 +71,7 @@ install(
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
install(TARGETS ${PROJECT_NAME} EXPORT export_${PROJECT_NAME})

# Install executables
install(
Expand All @@ -74,13 +80,9 @@ install(
)

# Install include directories
install(
DIRECTORY include/
DESTINATION include
)
install(DIRECTORY include/ DESTINATION include/${PROJECT_NAME})

ament_export_include_directories(include)
ament_export_libraries(${PROJECT_NAME})
ament_export_targets(export_${PROJECT_NAME})

ament_export_dependencies(message_filters rclcpp sensor_msgs pluginlib)

Expand Down