diff options
| author | Mehmet Samet Duman <yongdohyun@projecttick.org> | 2026-04-02 18:44:05 +0300 |
|---|---|---|
| committer | Mehmet Samet Duman <yongdohyun@projecttick.org> | 2026-04-02 18:44:05 +0300 |
| commit | 0b24459ac12b6cf9fd5a401d647796ca254a8fa8 (patch) | |
| tree | f2fd66e2476976a51e2a51330fd95dc6e87b24c1 /tomlplusplus/src | |
| parent | b85e90fc3480da0e6a48da73201a0b22488cc650 (diff) | |
| parent | 1c8b7466e4946fcc3bf20484c0e1d001202cca5a (diff) | |
| download | Project-Tick-0b24459ac12b6cf9fd5a401d647796ca254a8fa8.tar.gz Project-Tick-0b24459ac12b6cf9fd5a401d647796ca254a8fa8.zip | |
Add 'tomlplusplus/' from commit '1c8b7466e4946fcc3bf20484c0e1d001202cca5a'
git-subtree-dir: tomlplusplus
git-subtree-mainline: b85e90fc3480da0e6a48da73201a0b22488cc650
git-subtree-split: 1c8b7466e4946fcc3bf20484c0e1d001202cca5a
Diffstat (limited to 'tomlplusplus/src')
| -rw-r--r-- | tomlplusplus/src/meson.build | 88 | ||||
| -rw-r--r-- | tomlplusplus/src/modules/CMakeLists.txt | 44 | ||||
| -rw-r--r-- | tomlplusplus/src/modules/tomlplusplus.cppm | 88 | ||||
| -rw-r--r-- | tomlplusplus/src/toml.cpp | 13 |
4 files changed, 233 insertions, 0 deletions
diff --git a/tomlplusplus/src/meson.build b/tomlplusplus/src/meson.build new file mode 100644 index 0000000000..3b3b537253 --- /dev/null +++ b/tomlplusplus/src/meson.build @@ -0,0 +1,88 @@ +# This file is a part of toml++ and is subject to the the terms of the MIT license. +# Copyright (c) Mark Gillard <mark.gillard@outlook.com.au> +# See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text. +# SPDX-License-Identifier: MIT + +assert(build_lib) # not header-only mode + +# These are the arguments needed to compile and consume the library, and +# are exposed to users with the `compile_args` kwarg of declare_dependency() +lib_args = cpp.get_supported_arguments('-DTOML_HEADER_ONLY=0') +if get_option('default_library') != 'static' + lib_args += cpp.get_supported_arguments('-DTOML_SHARED_LIB=1') +endif +if unreleased_features + lib_args += cpp.get_supported_arguments('-DTOML_ENABLE_UNRELEASED_FEATURES=1') +endif + +# these are the _internal_ args, just for compiling the lib +lib_internal_args = [] +lib_internal_args += global_args +lib_internal_args += lib_args +if is_pedantic and is_release + lib_internal_args += cpp.get_supported_arguments( + '-Wsuggest-attribute=const', + '-Wsuggest-attribute=pure' + ) +endif + +tomlplusplus_lib = library( + meson.project_name(), + files('toml.cpp'), + cpp_args: lib_internal_args, + gnu_symbol_visibility: get_option('default_library') == 'static' ? '' : 'hidden', + include_directories: include_dir, + install: not is_subproject, + version: meson.project_version(), + override_options: global_overrides +) + +tomlplusplus_dep = declare_dependency( + compile_args: lib_args, + include_directories: include_dir, + link_with: tomlplusplus_lib +) + +if not is_subproject + import('pkgconfig').generate( + tomlplusplus_lib, + description: 'TOML config file parser and serializer for C++', + extra_cflags: lib_args, + url: 'https://marzer.github.io/tomlplusplus' + ) +endif + +# cmake +if get_option('generate_cmake_config') and not is_subproject and not is_devel + cmake = import('cmake') + cmake.write_basic_package_version_file( + name: meson.project_name(), + version: meson.project_version(), + ) + + # This gets the full path of the library, then considers just the last + # component (i.e. the actual file name), and finally removes the + # version suffix from it, because users _should_ link against the .so + # file, as opposed to the .so.x.y.z one. + lib_name = tomlplusplus_lib.full_path().split('/')[-1] + lib_name = lib_name.replace('.' + meson.project_version(), '') + + # CMake needs space-separated values since it doesn't have types + cmake_compile_options = '' + foreach arg : lib_args + cmake_compile_options += arg + ' ' + endforeach + cmake_compile_options = cmake_compile_options.strip() + + cmake.configure_package_config_file( + name: meson.project_name(), + input: '..'/'cmake'/'tomlplusplusConfig.cmake.meson.in', + configuration: configuration_data({ + 'compile_library': true, + 'compile_options': cmake_compile_options, + 'includedir': get_option('includedir'), + 'libdir': get_option('libdir'), + 'lib_name': lib_name + }) + ) +endif diff --git a/tomlplusplus/src/modules/CMakeLists.txt b/tomlplusplus/src/modules/CMakeLists.txt new file mode 100644 index 0000000000..5315390175 --- /dev/null +++ b/tomlplusplus/src/modules/CMakeLists.txt @@ -0,0 +1,44 @@ +file(GLOB_RECURSE TOMLPLUSPLUS_MODULES *.cppm) + +add_library(tomlplusplus_modules) +target_sources(tomlplusplus_modules + PUBLIC + FILE_SET CXX_MODULES FILES + ${TOMLPLUSPLUS_MODULES} +) + +cmake_minimum_required(VERSION 3.28) + +if(NOT COMMAND configure_cpp_module_target) + function(configure_cpp_module_target target) + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.28) + target_sources(${target} PUBLIC FILE_SET CXX_MODULES FILES ${TOMLPLUSPLUS_MODULES}) + else() + message(WARNING "C++ modules require CMake 3.28+. Using standard compilation.") + target_sources(${target} PRIVATE ${TOMLPLUSPLUS_MODULES}) + endif() + endfunction() +endif() + +configure_cpp_module_target(tomlplusplus_modules) + +target_link_libraries(tomlplusplus_modules + PUBLIC + tomlplusplus::tomlplusplus +) + +target_include_directories(tomlplusplus_modules + PRIVATE + ${tomlplusplus_SOURCE_DIR}/include +) + +target_compile_features(tomlplusplus_modules PUBLIC cxx_std_20) + +if(TOMLPLUSPLUS_ENABLE_INSTALL) + install(TARGETS tomlplusplus_modules + EXPORT tomlplusplus-targets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + FILE_SET CXX_MODULES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/tomlplusplus/modules + ) +endif() diff --git a/tomlplusplus/src/modules/tomlplusplus.cppm b/tomlplusplus/src/modules/tomlplusplus.cppm new file mode 100644 index 0000000000..e1860c4878 --- /dev/null +++ b/tomlplusplus/src/modules/tomlplusplus.cppm @@ -0,0 +1,88 @@ +/** + * @file tomlpp.cppm + * @brief File containing the module declaration for toml++. + */ + +module; + +#define TOML_UNDEF_MACROS 0 +#include <toml++/toml.hpp> + +export module tomlplusplus; + +/** + * @namespace toml + * @brief The toml++ namespace toml:: + */ +export namespace toml { + /** + * @namespace literals + * @brief The toml++ namespace toml::literals:: + */ + inline namespace literals { + using TOML_NAMESPACE::literals::operator""_toml; + using TOML_NAMESPACE::literals::operator""_tpath; + } + + using TOML_NAMESPACE::array; + using TOML_NAMESPACE::date; + using TOML_NAMESPACE::date_time; + using TOML_NAMESPACE::inserter; + using TOML_NAMESPACE::json_formatter; + using TOML_NAMESPACE::key; + using TOML_NAMESPACE::node; + using TOML_NAMESPACE::node_view; + using TOML_NAMESPACE::parse_error; + using TOML_NAMESPACE::parse_result; + using TOML_NAMESPACE::path; + using TOML_NAMESPACE::path_component; + using TOML_NAMESPACE::source_position; + using TOML_NAMESPACE::source_region; + using TOML_NAMESPACE::table; + using TOML_NAMESPACE::time; + using TOML_NAMESPACE::time_offset; + using TOML_NAMESPACE::toml_formatter; + using TOML_NAMESPACE::value; + using TOML_NAMESPACE::yaml_formatter; + using TOML_NAMESPACE::format_flags; + using TOML_NAMESPACE::node_type; + using TOML_NAMESPACE::path_component_type; + using TOML_NAMESPACE::value_flags; + using TOML_NAMESPACE::array_iterator; + using TOML_NAMESPACE::const_array_iterator; + using TOML_NAMESPACE::const_table_iterator; + using TOML_NAMESPACE::default_formatter; + using TOML_NAMESPACE::inserted_type_of; + using TOML_NAMESPACE::optional; + using TOML_NAMESPACE::source_index; + using TOML_NAMESPACE::source_path_ptr; + using TOML_NAMESPACE::table_iterator; + + using TOML_NAMESPACE::at_path; + using TOML_NAMESPACE::get_line; + using TOML_NAMESPACE::operator""_toml; + using TOML_NAMESPACE::operator""_tpath; + using TOML_NAMESPACE::operator<<; + using TOML_NAMESPACE::parse; + using TOML_NAMESPACE::parse_file; + + using TOML_NAMESPACE::is_array; + using TOML_NAMESPACE::is_boolean; + using TOML_NAMESPACE::is_chronological; + using TOML_NAMESPACE::is_container; + using TOML_NAMESPACE::is_date; + using TOML_NAMESPACE::is_date_time; + using TOML_NAMESPACE::is_floating_point; + using TOML_NAMESPACE::is_integer; + using TOML_NAMESPACE::is_key; + using TOML_NAMESPACE::is_key_or_convertible; + using TOML_NAMESPACE::is_node; + using TOML_NAMESPACE::is_node_view; + using TOML_NAMESPACE::is_number; + using TOML_NAMESPACE::is_string; + using TOML_NAMESPACE::is_table; + using TOML_NAMESPACE::is_time; + using TOML_NAMESPACE::is_value; + + using TOML_NAMESPACE::preserve_source_value_flags; +} diff --git a/tomlplusplus/src/toml.cpp b/tomlplusplus/src/toml.cpp new file mode 100644 index 0000000000..8cc1877ff0 --- /dev/null +++ b/tomlplusplus/src/toml.cpp @@ -0,0 +1,13 @@ +// This file is a part of toml++ and is subject to the the terms of the MIT license. +// Copyright (c) Mark Gillard <mark.gillard@outlook.com.au> +// See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text. +// SPDX-License-Identifier: MIT + +#ifndef TOML_IMPLEMENTATION +#define TOML_IMPLEMENTATION +#endif +#ifndef TOML_HEADER_ONLY +#define TOML_HEADER_ONLY 0 +#endif + +#include <toml++/toml.hpp> |
