mirror of
https://github.com/nlohmann/json.git
synced 2026-10-03 21:20:30 +00:00
A Meson installation only provided the headers and a pkg-config file, so consumers using find_package(nlohmann_json) could not find the library. Meson now also installs nlohmann_jsonConfig.cmake and nlohmann_jsonConfigVersion.cmake from the existing templates, plus a static nlohmann_jsonTargets.cmake that defines the header-only imported target with a relocatable include path. A new CI job installs with Meson and builds tests/cmake_import/project against the result. Closes #3885 Signed-off-by: Niels Lohmann <mail@nlohmann.me>
29 lines
1.1 KiB
CMake
29 lines
1.1 KiB
CMake
# Imported target for installations made with Meson (see meson.build).
|
|
#
|
|
# CMake installations generate this file with install(EXPORT ...). Meson cannot
|
|
# do that, but as the library is header-only, the target only needs an include
|
|
# directory and the C++ standard. Paths are computed relative to this file so
|
|
# that the installation can be relocated (e.g., into a sysroot).
|
|
|
|
if(TARGET @PROJECT_NAME@::@NLOHMANN_JSON_TARGET_NAME@)
|
|
return()
|
|
endif()
|
|
|
|
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_DIR}/@NLOHMANN_JSON_CONFIG_TO_PREFIX@" ABSOLUTE)
|
|
|
|
add_library(@PROJECT_NAME@::@NLOHMANN_JSON_TARGET_NAME@ INTERFACE IMPORTED)
|
|
set_target_properties(@PROJECT_NAME@::@NLOHMANN_JSON_TARGET_NAME@ PROPERTIES
|
|
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/@NLOHMANN_JSON_INCLUDE_INSTALL_DIR@"
|
|
)
|
|
if(CMAKE_VERSION VERSION_LESS 3.8)
|
|
set_target_properties(@PROJECT_NAME@::@NLOHMANN_JSON_TARGET_NAME@ PROPERTIES
|
|
INTERFACE_COMPILE_FEATURES cxx_range_for
|
|
)
|
|
else()
|
|
set_target_properties(@PROJECT_NAME@::@NLOHMANN_JSON_TARGET_NAME@ PROPERTIES
|
|
INTERFACE_COMPILE_FEATURES cxx_std_11
|
|
)
|
|
endif()
|
|
|
|
unset(_IMPORT_PREFIX)
|