Skip to content

Commit

Permalink
added build option GENERATE_CMAKE_CONFIG [skip ci]
Browse files Browse the repository at this point in the history
also:
- minor cleanup
  • Loading branch information
marzer committed Apr 7, 2020
1 parent ee35432 commit 45c0fe2
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 40 deletions.
10 changes: 5 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- run:
name: Building and testing with clang 9
command: |
CXX=clang++-9 meson build --buildtype=debug
CXX=clang++-9 meson build --buildtype=debug -DGENERATE_CMAKE_CONFIG=disabled
cd build && ninja -v -j 4 && ninja test
- run:
name: Generating documentation
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
- run:
name: Building and testing with clang 9
command: |
CXX=clang++-9 meson build --buildtype=debug
CXX=clang++-9 meson build --buildtype=debug -DGENERATE_CMAKE_CONFIG=disabled
cd build && ninja -v -j 4 && ninja test
Expand All @@ -84,7 +84,7 @@ jobs:
- run:
name: Building and testing with clang 9
command: |
CXX=clang++-9 meson build --buildtype=release
CXX=clang++-9 meson build --buildtype=release -DGENERATE_CMAKE_CONFIG=disabled
cd build && ninja -v -j 4 && ninja test
Expand All @@ -106,7 +106,7 @@ jobs:
- run:
name: Building and testing with gcc9
command: |
CXX=g++-9 meson build --buildtype=debug
CXX=g++-9 meson build --buildtype=debug -DGENERATE_CMAKE_CONFIG=disabled
cd build && ninja -v -j 4 && ninja test
Expand All @@ -128,7 +128,7 @@ jobs:
- run:
name: Building and testing with gcc9
command: |
CXX=g++-9 meson build --buildtype=release
CXX=g++-9 meson build --buildtype=release -DGENERATE_CMAKE_CONFIG=disabled
cd build && ninja -v -j 4 && ninja test
Expand Down
2 changes: 1 addition & 1 deletion include/toml++/toml_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ TOML_DISABLE_ALL_WARNINGS
TOML_POP_WARNINGS

#if TOML_CHAR_8_STRINGS
#if !defined(__cpp_lib_char8_t)
#ifndef __cpp_lib_char8_t
#error toml++ requires implementation support to use char8_t strings, but yours does not provide it.
#endif

Expand Down
2 changes: 1 addition & 1 deletion include/toml++/toml_default_formatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ namespace toml
base::clear_naked_newline();
}

inline void print_inline(const table& /*tbl*/);
void print_inline(const table& /*tbl*/);

void print(const array& arr)
{
Expand Down
2 changes: 1 addition & 1 deletion include/toml++/toml_json_formatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace toml
private:
using base = impl::formatter<Char>;

inline void print(const toml::table& tbl);
void print(const toml::table& tbl);

void print(const array& arr)
{
Expand Down
8 changes: 4 additions & 4 deletions include/toml++/toml_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ namespace toml
[[nodiscard]] TOML_API
parse_result parse(std::string_view doc, std::string&& source_path) TOML_MAY_THROW;

#if defined(__cpp_lib_char8_t)
#ifdef __cpp_lib_char8_t

/// \brief Parses a TOML document from a char8_t string view.
///
Expand Down Expand Up @@ -379,7 +379,7 @@ namespace toml
[[nodiscard]] TOML_API
parse_result parse(std::u8string_view doc, std::string&& source_path) TOML_MAY_THROW;

#endif // defined(__cpp_lib_char8_t)
#endif // __cpp_lib_char8_t

/// \brief Parses a TOML document from a stream.
///
Expand Down Expand Up @@ -553,7 +553,7 @@ namespace toml
[[nodiscard]] TOML_API
parse_result operator"" _toml(const char* str, size_t len) TOML_MAY_THROW;

#if defined(__cpp_lib_char8_t)
#ifdef __cpp_lib_char8_t

/// \brief Parses TOML data from a string.
///
Expand All @@ -579,7 +579,7 @@ namespace toml
[[nodiscard]] TOML_API
parse_result operator"" _toml(const char8_t* str, size_t len) TOML_MAY_THROW;

#endif
#endif // __cpp_lib_char8_t

#if TOML_ABI_NAMESPACES
} //end abi namespace for TOML_EXCEPTIONS
Expand Down
8 changes: 4 additions & 4 deletions include/toml++/toml_parser_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3305,7 +3305,7 @@ namespace toml
return impl::do_parse(impl::utf8_reader{ doc, std::move(source_path) });
}

#if defined(__cpp_lib_char8_t)
#ifdef __cpp_lib_char8_t

TOML_API
TOML_FUNC_EXTERNAL_LINKAGE
Expand All @@ -3321,7 +3321,7 @@ namespace toml
return impl::do_parse(impl::utf8_reader{ doc, std::move(source_path) });
}

#endif // defined(__cpp_lib_char8_t)
#endif // __cpp_lib_char8_t

#if TOML_ABI_NAMESPACES
} //end abi namespace for TOML_EXCEPTIONS
Expand All @@ -3344,7 +3344,7 @@ namespace toml
return parse(std::string_view{ str, len });
}

#if defined(__cpp_lib_char8_t)
#ifdef __cpp_lib_char8_t

TOML_API
TOML_FUNC_EXTERNAL_LINKAGE
Expand All @@ -3353,7 +3353,7 @@ namespace toml
return parse(std::u8string_view{ str, len });
}

#endif // defined(__cpp_lib_char8_t)
#endif // __cpp_lib_char8_t

#if TOML_ABI_NAMESPACES
} //end abi namespace for TOML_EXCEPTIONS
Expand Down
28 changes: 17 additions & 11 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,20 @@ pkgc.generate (
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,
)
# meson cmake stuff requires at least 0.50
if meson.version().version_compare('>= 0.50')
if get_option('GENERATE_CMAKE_CONFIG').enabled() or (get_option('GENERATE_CMAKE_CONFIG').auto() and not meson.is_subproject())
cmake = import('cmake')
cmake.write_basic_package_version_file(
name: meson.project_name(),
version: meson.project_version()
)

cmake_conf = configuration_data()
cmake.configure_package_config_file(
name: meson.project_name(),
input: 'cmake/tomlplusplus.cmake.in',
configuration: cmake_conf,
)
endif
endif
5 changes: 3 additions & 2 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
option('BUILD_TESTS', type : 'feature', value : 'auto', description : 'Whether to build tests (defaults to auto: only if not a subproject)')
option('BUILD_EXAMPLES', type : 'feature', value : 'auto', description : 'Whether to build examples (defaults to auto: only if not a subproject)')
option('BUILD_TESTS', type : 'feature', value : 'auto', description : 'Whether to build tests (default: auto - only if not a subproject)')
option('BUILD_EXAMPLES', type : 'feature', value : 'auto', description : 'Whether to build examples (default: auto - only if not a subproject)')
option('GENERATE_CMAKE_CONFIG', type : 'feature', value : 'auto', description : 'Whether to generate a cmake package config file (default: auto - only if not a subproject)')
22 changes: 11 additions & 11 deletions toml.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ TOML_DISABLE_ALL_WARNINGS
TOML_POP_WARNINGS

#if TOML_CHAR_8_STRINGS
#if !defined(__cpp_lib_char8_t)
#ifndef __cpp_lib_char8_t
#error toml++ requires implementation support to use char8_t strings, but yours does not provide it.
#endif

Expand Down Expand Up @@ -5107,15 +5107,15 @@ namespace toml
[[nodiscard]] TOML_API
parse_result parse(std::string_view doc, std::string&& source_path) TOML_MAY_THROW;

#if defined(__cpp_lib_char8_t)
#ifdef __cpp_lib_char8_t

[[nodiscard]] TOML_API
parse_result parse(std::u8string_view doc, std::string_view source_path = {}) TOML_MAY_THROW;

[[nodiscard]] TOML_API
parse_result parse(std::u8string_view doc, std::string&& source_path) TOML_MAY_THROW;

#endif // defined(__cpp_lib_char8_t)
#endif // __cpp_lib_char8_t

template <typename Char>
[[nodiscard]]
Expand Down Expand Up @@ -5189,12 +5189,12 @@ namespace toml
[[nodiscard]] TOML_API
parse_result operator"" _toml(const char* str, size_t len) TOML_MAY_THROW;

#if defined(__cpp_lib_char8_t)
#ifdef __cpp_lib_char8_t

[[nodiscard]] TOML_API
parse_result operator"" _toml(const char8_t* str, size_t len) TOML_MAY_THROW;

#endif
#endif // __cpp_lib_char8_t

#if TOML_ABI_NAMESPACES
} //end abi namespace for TOML_EXCEPTIONS
Expand Down Expand Up @@ -5421,7 +5421,7 @@ namespace toml
base::clear_naked_newline();
}

inline void print_inline(const table& /*tbl*/);
void print_inline(const table& /*tbl*/);
void print(const array& arr)
{
if (arr.empty())
Expand Down Expand Up @@ -5743,7 +5743,7 @@ namespace toml
private:
using base = impl::formatter<Char>;

inline void print(const toml::table& tbl);
void print(const toml::table& tbl);
void print(const array& arr)
{
if (arr.empty())
Expand Down Expand Up @@ -9697,7 +9697,7 @@ namespace toml
return impl::do_parse(impl::utf8_reader{ doc, std::move(source_path) });
}

#if defined(__cpp_lib_char8_t)
#ifdef __cpp_lib_char8_t

TOML_API
TOML_FUNC_EXTERNAL_LINKAGE
Expand All @@ -9713,7 +9713,7 @@ namespace toml
return impl::do_parse(impl::utf8_reader{ doc, std::move(source_path) });
}

#endif // defined(__cpp_lib_char8_t)
#endif // __cpp_lib_char8_t

#if TOML_ABI_NAMESPACES
} //end abi namespace for TOML_EXCEPTIONS
Expand All @@ -9736,7 +9736,7 @@ namespace toml
return parse(std::string_view{ str, len });
}

#if defined(__cpp_lib_char8_t)
#ifdef __cpp_lib_char8_t

TOML_API
TOML_FUNC_EXTERNAL_LINKAGE
Expand All @@ -9745,7 +9745,7 @@ namespace toml
return parse(std::u8string_view{ str, len });
}

#endif // defined(__cpp_lib_char8_t)
#endif // __cpp_lib_char8_t

#if TOML_ABI_NAMESPACES
} //end abi namespace for TOML_EXCEPTIONS
Expand Down
1 change: 1 addition & 0 deletions vs/toml++.props
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
<PreprocessorDefinitions>%(PreprocessorDefinitions);NDEBUG</PreprocessorDefinitions>
<InlineFunctionExpansion Condition="$(PlatformToolsetVersion) &lt;= 141">AnySuitable</InlineFunctionExpansion> <!-- /Ob2 -->
<AdditionalOptions Condition="$(PlatformToolsetVersion) &gt;= 142">%(AdditionalOptions) /Ob3</AdditionalOptions> <!-- /Ob3 -->
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> <!-- /Ot -->
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
Expand Down

0 comments on commit 45c0fe2

Please sign in to comment.