Add the Cmake configuration files support (#22) [skip ci]

This commit is contained in:
Giulio Romualdi 2020-04-07 17:33:00 +02:00 committed by GitHub
parent dce20a7e2d
commit ee35432b71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,14 @@
@PACKAGE_INIT@
# If tomlplusplus::tomlplusplus target is not defined it will be included
if(NOT TARGET tomlplusplus::tomlplusplus)
# Import tomlplusplus interface library
add_library(tomlplusplus::tomlplusplus INTERFACE IMPORTED)
set_target_properties(tomlplusplus::tomlplusplus PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${PACKAGE_PREFIX_DIR}/include")
# Require C++17
target_compile_features(tomlplusplus::tomlplusplus INTERFACE cxx_std_17)
endif()

View File

@ -17,6 +17,7 @@ tomlplusplus_dep = declare_dependency(
version : meson.project_version(),
)
build_tests = false
if get_option('BUILD_TESTS').auto()
build_tests = (not meson.is_subproject())
@ -109,3 +110,15 @@ pkgc.generate (
version: meson.project_version(),
description: 'Header-only TOML config file parser and serializer for modern C++'
)
cmake = import('cmake')
cmake.write_basic_package_version_file(
name: 'tomlplusplus',
version: meson.project_version())
conf = configuration_data()
cmake.configure_package_config_file(
name: 'tomlplusplus',
input: 'cmake/tomlplusplus.cmake.in',
configuration: conf,
)