diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e931239..a4fd827 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,7 +9,12 @@ if (NOT DEFINED CMAKE_MACOSX_RPATH) endif() add_library(cbor ${SOURCES}) -target_include_directories(cbor PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +target_include_directories(cbor PUBLIC + $ + $ + $ +) +set_target_properties(cbor PROPERTIES EXPORT_NAME libcbor) # Explicitly link math.h if necessary check_function_exists(ldexp LDEXP_AVAILABLE) @@ -19,7 +24,6 @@ endif() include(GenerateExportHeader) generate_export_header(cbor EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/cbor/cbor_export.h) -target_include_directories(cbor PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cbor/cbor_export.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/cbor) if (NOT ${CBOR_VERSION_MAJOR} EQUAL 0) @@ -37,6 +41,7 @@ configure_file(libcbor.pc.in libcbor.pc @ONLY) # http://www.cmake.org/Wiki/CMake:Install_Commands install(TARGETS cbor + EXPORT libcborTargets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) @@ -68,3 +73,6 @@ install( DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libcbor ) +install(EXPORT libcborTargets + NAMESPACE libcbor:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libcbor) diff --git a/src/libcborConfig.cmake.in b/src/libcborConfig.cmake.in index 565bed3..ef99a74 100644 --- a/src/libcborConfig.cmake.in +++ b/src/libcborConfig.cmake.in @@ -2,7 +2,11 @@ set(CBOR_VERSION @CBOR_VERSION@) @PACKAGE_INIT@ +include("${CMAKE_CURRENT_LIST_DIR}/libcborTargets.cmake") + +# legacy set_and_check(CBOR_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@") set_and_check(CBOR_INCLUDE_DIRS "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@") +set(CBOR_LIBRARIES "libcbor::libcbor") check_required_components(libcbor)