diff --git a/CMakeLists.txt b/CMakeLists.txt index 2429881..a816142 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,7 +30,7 @@ message(STATUS "xtl v${${PROJECT_NAME}_VERSION}") # ============ if(NOT TARGET nlohmann_json) - find_package(nlohmann_json QUIET) + find_package(nlohmann_json CONFIG REQUIRED) endif() # Build @@ -85,6 +85,7 @@ set_target_properties(xtl endif() target_compile_features(xtl INTERFACE cxx_std_14) +target_link_libraries(xtl INTERFACE nlohmann_json::nlohmann_json) option(BUILD_TESTS "xtl test suite" OFF) option(DOWNLOAD_GTEST "build gtest from downloaded sources" OFF) @@ -119,7 +120,7 @@ install(FILES ${XTL_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/xtl) endif() -set(XTL_CMAKECONFIG_INSTALL_DIR "${CMAKE_INSTALL_DATAROOTDIR}/cmake/${PROJECT_NAME}" CACHE +set(XTL_CMAKECONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" CACHE STRING "install path for xtlConfig.cmake") configure_package_config_file(${PROJECT_NAME}Config.cmake.in @@ -154,4 +155,4 @@ configure_file(${PROJECT_NAME}.pc.in "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc" @ONLY) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc" - DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig/") + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig/") diff --git a/xtlConfig.cmake.in b/xtlConfig.cmake.in index 936eef1..ef392c6 100644 --- a/xtlConfig.cmake.in +++ b/xtlConfig.cmake.in @@ -13,6 +13,8 @@ # xtl_INCLUDE_DIRS - the directory containing xtl headers # xtl_LIBRARY - empty +include(CMakeFindDependencyMacro) +find_dependency(nlohmann_json) @PACKAGE_INIT@ if(NOT TARGET @PROJECT_NAME@)