Skip to content

Commit befc608

Browse files
authored
Install headers to include\${PROJECT_NAME} (ros2#351)
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
1 parent 093ca35 commit befc608

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

CMakeLists.txt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ add_library(
120120
target_include_directories(${PROJECT_NAME} PUBLIC
121121
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
122122
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>"
123-
"$<INSTALL_INTERFACE:include>")
123+
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>")
124124

125125
# Causes the visibility macros to use dllexport rather than dllimport,
126126
# which is appropriate when building the dll but not consuming it.
@@ -572,26 +572,29 @@ if(BUILD_TESTING)
572572
add_performance_test(benchmark_logging test/benchmark/benchmark_logging.cpp)
573573
if(TARGET benchmark_logging)
574574
target_link_libraries(benchmark_logging ${PROJECT_NAME})
575-
target_include_directories(benchmark_logging PUBLIC include)
576575
endif()
577576

578577
add_performance_test(benchmark_err_handle test/benchmark/benchmark_error_handling.cpp)
579578
if(TARGET benchmark_err_handle)
580579
target_link_libraries(benchmark_err_handle ${PROJECT_NAME})
581-
target_include_directories(benchmark_err_handle PUBLIC include)
582580
endif()
583581

584582
if(TARGET test_macros)
585583
target_link_libraries(test_macros ${PROJECT_NAME})
586584
endif()
587585
endif()
588586

589-
ament_export_dependencies(ament_cmake)
590-
ament_export_include_directories(include)
587+
# Export old-style CMake variables
588+
ament_export_include_directories("include/${PROJECT_NAME}")
591589
ament_export_libraries(${PROJECT_NAME} ${CMAKE_DL_LIBS})
590+
591+
# Export modern CMake targets
592592
ament_export_targets(${PROJECT_NAME})
593+
594+
ament_export_dependencies(ament_cmake)
595+
593596
ament_package()
594597

595598
install(
596599
DIRECTORY include/ ${CMAKE_CURRENT_BINARY_DIR}/include/
597-
DESTINATION include)
600+
DESTINATION include/${PROJECT_NAME})

0 commit comments

Comments
 (0)