From c4ed36e8dba9241c3547143e7826a56fe87cc958 Mon Sep 17 00:00:00 2001 From: Dirk Thomas Date: Thu, 30 Apr 2020 15:52:32 -0700 Subject: [PATCH] export modern CMake interface target Signed-off-by: Dirk Thomas --- CMakeLists.txt | 11 +++++++++++ cmake/urdfdom_headers-config.cmake.in | 2 ++ 2 files changed, 13 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a651cd..b9170ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,6 +56,17 @@ if (NOT MSVC) install(FILES "${CMAKE_BINARY_DIR}/${pkg_conf_file}" DESTINATION lib/pkgconfig/ COMPONENT pkgconfig) endif() +add_library(${PROJECT_NAME} INTERFACE) +target_include_directories(${PROJECT_NAME} INTERFACE + "$") +install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}) +install( + EXPORT ${PROJECT_NAME} + DESTINATION ${CMAKE_CONFIG_INSTALL_DIR} + NAMESPACE "${PROJECT_NAME}::" + FILE "${PROJECT_NAME}Export.cmake" +) + # Add uninstall target # Ref: http://www.cmake.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F configure_file("${PROJECT_SOURCE_DIR}/cmake/uninstall.cmake.in" "${PROJECT_BINARY_DIR}/uninstall.cmake" IMMEDIATE @ONLY) diff --git a/cmake/urdfdom_headers-config.cmake.in b/cmake/urdfdom_headers-config.cmake.in index e3ec895..912ca2e 100644 --- a/cmake/urdfdom_headers-config.cmake.in +++ b/cmake/urdfdom_headers-config.cmake.in @@ -4,3 +4,5 @@ endif() set(@PACKAGE_NAME@_CONFIG_INCLUDED TRUE) set(@PACKAGE_NAME@_INCLUDE_DIRS "${@PROJECT_NAME@_DIR}/@RELATIVE_PATH_CMAKE_DIR_TO_PREFIX@/include") + +include("${@PROJECT_NAME@_DIR}/@PROJECT_NAME@Export.cmake")