Commit Graph

130 Commits (c35d260c2fb91b8a53e585d480607a0f088cbbbb)

Author SHA1 Message Date
Niels Lohmann 9cca280a4d
JSON for Modern C++ 3.11.3 (#4222) 2023-11-28 22:36:31 +01:00
Benjamin Buch cdb29069da
fix cmake header path in install with custom CMAKE_INSTALL_INCLUDEDIR (#4194) 2023-10-31 19:52:54 +01:00
Craig Scott fac07e22c5
Accept NEW CMake policies up to CMake 3.14 (#4112)
Starting with CMake 3.27, deprecation warnings are issued
when asking for policy settings for CMake 3.4 or earlier.
The cmake_minimum_required() command accepts a version
range, which allows NEW policy settings up to the upper end
of that range to be used, but without raising the minimum
CMake version above the bottom of that range. This means
NEW policy settings will be used where available, without
requiring them. This change updates the project's
cmake_minimum_required() calls to use a version range to
extend the upper policy version to 3.14 where it wasn't already
at that version or higher. This prevents the deprecation warning
from CMake 3.27, and gives breathing space before a future
CMake release will start issuing similar deprecation warnings
again.
2023-09-25 09:31:26 +02:00
Vertexwahn 2d1f9b6a7d
Add Bazel build support (#3709) 2022-09-18 08:15:12 +02:00
Niels Lohmann 9d69186291
🔖 set version to 3.11.2 2022-08-12 15:04:06 +02:00
Niels Lohmann f2020da0dd
🔖 set version to 3.11.1 2022-08-01 23:27:58 +02:00
Niels Lohmann ce0e13ccea
🔖 set version to 3.11.0 2022-07-31 23:19:06 +02:00
Florian Albrechtskirchinger 9aafcbe965
Move UDLs out of the global namespace (#3605)
* Move UDLs into nlohmann::literals::json_literals namespace

* Add 'using namespace' to unit tests

* Add 'using namespace' to examples

* Add 'using namespace' to README

* Move UDL mkdocs pages out of basic_json/

* Update documentation

* Update docset index

* Add JSON_GlobalUDLs CMake option

* Add unit test

* Build examples without global UDLs

* Add CI target
2022-07-31 17:38:52 +02:00
Andrea Pappacoda 6576c3f776
build: install .pc and .cmake files to share/ (#3619)
As nlohmann_json is a header-only library, its pkg-config and cmake
config files should be installed to `share/` (GNUInstallDirs' DATADIR),
as `share/` is the canonical directory where architecture-independent
files should be stored, while `lib/` is for architecture-dependent stuff
(see the [FHS][]).

Apart from being technically correct, installing to `share/` can help
with cross-compiling, for example in Debian-based environments. If
you're interested, I'd suggest reading this [thread][].

Related to #1697

[FHS]: https://refspecs.linuxfoundation.org/FHS_3.0/fhs-3.0.html#usrshareArchitectureindependentData
[thread]: https://github.com/marzer/tomlplusplus/pull/165#issuecomment-1193146210
2022-07-29 07:43:22 +02:00
Richard Hozák f6acdbec2c
Allow disabling default enum conversions (#3536) 2022-06-16 19:34:32 +02:00
Florian Albrechtskirchinger e80945da2c
CI: Enable 32bit unit test (3) (#3532)
* Enable JSON_MultipleHeaders by default

* CI: Add single-header build

* CI: Enable 32bit unit test

* Fix "-Wuseless-cast" warnings

* Remove coverage exclusion

* Fix 32bit test case
2022-06-14 08:54:12 +02:00
Florian Albrechtskirchinger 6b97599a27
Fix C++20/gcc-12 issues (Part 2) (#3446)
* Add C++20 3-way comparison operator and fix broken comparisons

Fixes #3207.
Fixes #3409.

* Fix iterators to meet (more) std::ranges requirements

Fixes #3130.
Related discussion: #3408

* Add note about CMake standard version selection to unit tests

Document how CMake chooses which C++ standard version to use when
building tests.

* Update documentation

* CI: add legacy discarded value comparison

* Fix internal linkage errors when building a module
2022-05-29 13:08:06 +02:00
Niels Lohmann b21c345179
Reorganize directories (#3462)
* 🚚 move files
* 🚚 rename doc folder to docs
* 🚚 rename test folder to tests
2022-05-01 09:41:50 +02:00
Florian Albrechtskirchinger ad103e5b45
Improve unit testing (Part 1) (#3380)
* Refactor unit test creation

Add functions for creating tests and to supply test- and
standard-specific build settings.

Raises minimum CMake version to 3.13 in test directory.

json_test_add_test_for(
    <file>
    MAIN <main>
    [CXX_STANDARDS <version_number>...] [FORCE])

Given a <file> unit-foo.cpp, produces

    test-foo_cpp<version_number>

if C++ standard <version_number> is supported by the compiler and
thesource file contains JSON_HAS_CPP_<version_number>.  Use FORCE to
create the test regardless of the file containing
JSON_HAS_CPP_<version_number>.  Test targets are linked against <main>.
CXX_STANDARDS defaults to "11".

json_test_set_test_options(
    all|<tests>
    [CXX_STANDARDS all|<args>...]
    [COMPILE_DEFINITIONS <args>...]
    [COMPILE_FEATURES <args>...]
    [COMPILE_OPTIONS <args>...]
    [LINK_LIBRARIES <args>...]
    [LINK_OPTIONS <args>...])

Supply test- and standard-specific build settings.
Specify multiple tests using a list e.g., "test-foo;test-bar".

Must be called BEFORE the test is created.

* Use CMAKE_MODULE_PATH

* Don't undef some macros if JSON_TEST_KEEP_MACROS is defined

* Use JSON_TEST_KEEP_MACROS

Incidentally enables the regression tests for #2546 and #3070.

A CHECK_THROWS_WITH_AS in #3070 was disabled which is tracked in #3377
and a line in from_json(..., std_fs::path&) was marked with LCOV_EXCL_LINE.

* Add three-way comparison feature test macro

* Disable broken comparison if JSON_HAS_THREE_WAY_COMPARISON

* Fix redefinition of inline constexpr statics

Redelcaration of inline constexpr static data members in namespace scope
was deprecated in C++17. Fixes -Werror=deprecated compilation failures.

* Fix more test build failures due to missing noexcept

* CI: update cmake_flags test to use CMake 3.13 in test directory

Also change default for JSON_BuildTests option to depend on CMake
version.

* CI: turn *_CXXFLAGS into CMake lists

* CI: use JSON_TestStandards to set CXX_STANDARD

* CI: pass extra CXXFLAGS to standards tests
2022-03-24 07:54:07 +01:00
Niels Lohmann b5364faf9d
🔖 set version to 3.10.5 2022-01-02 22:35:35 +01:00
Niels Lohmann a09bfa5faa
🔖 set version to 3.10.4 2021-10-16 13:34:31 +02:00
Niels Lohmann ab6a2c7425
🔖 set version to 3.10.3 2021-10-08 13:58:48 +02:00
Niels Lohmann 33b674b4b2
🔖 set version to 3.10.2 2021-08-26 08:13:04 +02:00
Niels Lohmann 8ad66e9136
🔖 set version to 3.10.1 2021-08-24 20:19:55 +02:00
Niels Lohmann 1de378f580
🔖 set version to 3.10.0 2021-08-17 15:23:23 +02:00
Niels Lohmann 19a5e12136
CMake cleanup (#2885)
* 🔥 clean CMake files and Makefile
* 💡 update documentation
2021-07-22 09:25:55 +02:00
Niels Lohmann b2d21067d1
Merge pull request #2762 from jpl-mac/no.tidy.warnings.dev
Add a cmake option to use SYSTEM in target_include_directories
2021-07-16 12:06:26 +02:00
Jason Dsouza f118091eaa
Update CMakeLists.txt 2021-05-15 23:39:15 +05:30
Jason Dsouza 6d7959e05d
Keep consistent formatting 2021-05-12 19:25:06 +05:30
Jean-Philippe Lemieux afbb84b2c8 Add a cmake option to use SYSTEM in target_include_directories
Without SYSTEM static analysis like clang-tidy raise warnings on
json.hpp.  This is not desirable for projects embedding nlohmann_json

Tests:
- Validated that without the option OFF the warnings are raised as
  before
- Validated that with the option ON the warnings are silenced
2021-05-05 16:19:24 -04:00
Niels Lohmann 6f551930e5
🚨 add new CI and fix warnings (#2561)
* ⚗️ move CI targets to CMake
* ♻️ add target for cpplint
* ♻️ add target for self-contained binaries
* ♻️ add targets for iwyu and infer
* 🔊 add version output
* ♻️ add target for oclint
* 🚨 fix warnings
* ♻️ rename targets
* ♻️ use iwyu properly
* 🚨 fix warnings
* ♻️ use iwyu properly
* ♻️ add target for benchmarks
* ♻️ add target for CMake flags
* 👷 use GitHub Actions
* ⚗️ try to install Clang 11
* ⚗️ try to install GCC 11
* ⚗️ try to install Clang 11
* ⚗️ try to install GCC 11
* ⚗️ add clang analyze target
* 🔥 remove Google Benchmark
* ⬆️ Google Benchmark 1.5.2
* 🔥 use fetchcontent
* 🐧 add target to download a Linux version of CMake
* 🔨 fix dependency
* 🚨 fix includes
* 🚨 fix comment
* 🔧 adjust flags for GCC 11.0.0 20210110 (experimental)
* 🐳 user Docker image to run CI
* 🔧 add target for Valgrind
* 👷 add target for Valgrind tests
* ⚗️ add Dart
*  remove Dart
* ⚗️ do not call ctest in test subdirectory
* ⚗️ download test data explicitly
* ⚗️ only execute Valgrind tests
* ⚗️ fix labels
* 🔥 remove unneeded jobs
* 🔨 cleanup
* 🐛 fix OCLint call
*  add targets for offline and git-independent tests
*  add targets for C++ language versions and reproducible tests
* 🔨 clean up
* 👷 add CI steps for cppcheck and cpplint
* 🚨 fix warnings from Clang-Tidy
* 👷 add CI steps for Clang-Tidy
* 🚨 fix warnings
* 🔧 select proper binary
* 🚨 fix warnings
* 🚨 suppress some unhelpful warnings
* 🚨 fix warnings
* 🎨 fix format
* 🚨 fix warnings
* 👷 add CI steps for Sanitizers
* 🚨 fix warnings
*  add optimization to sanitizer build
* 🚨 fix warnings
* 🚨 add missing header
* 🚨 fix warnings
* 👷 add CI step for coverage
* 👷 add CI steps for disabled exceptions and implicit conversions
* 🚨 fix warnings
* 👷 add CI steps for checking indentation
* 🐛 fix variable use
* 💚 fix build
*  remove CircleCI
* 👷 add CI step for diagnostics
* 🚨 fix warning
* 🔥 clean Travis
2021-03-24 07:15:18 +01:00
Niels Lohmann ec0b1798bc
🚧 implement more parent relations 2021-01-02 21:36:11 +01:00
Niels Lohmann ecaab32ef0
🚧 add switch for diagnostics 2021-01-02 13:45:00 +01:00
Martin Stump 1771e9249f
Remove comment on CTest inclusion
Co-authored-by: Niels Lohmann <niels.lohmann@gmail.com>
2020-12-14 10:59:38 +01:00
Martin Stump ea759d0360
Compare to CMAKE_CURRENT_SOURCE_DIR for main project check 2020-12-13 20:34:51 +01:00
Martin Stump 790508887e
Set MAIN_PROJECT=OFF initially 2020-12-09 12:39:44 +01:00
Martin Stump 5c589dd138
Add MAIN_PROJECT check for test and install options 2020-12-09 11:37:01 +01:00
Niels Lohmann b3e5cb7f20
🔖 set version to 3.9.1 2020-08-06 13:45:29 +02:00
Niels Lohmann 7d01a9e875
Merge branch 'develop' into installfix 2020-07-28 13:24:54 +02:00
Eli Schwartz aa06a4761e
cmake: install pkg-config file relative to current_binary_dir
When the testsuite is enabled, the "cmake_add_subdirectory" test
adds a second copy of the project into the build configuration, and the
project files are installed twice.

This becomes super problematic when it tries to install a file from
CMAKE_BINARY_DIR which is only available in CMAKE_CURRENT_BINARY_DIR
and bombs out with the following error message:

```
[...]
-- Installing: <DESTDIR>/usr/lib/cmake/nlohmann_json/nlohmann_jsonTargets.cmake
CMake Error at test/cmake_add_subdirectory/nlohmann_json/cmake_install.cmake:73 (file):
  file INSTALL cannot find
  "......./nlohmann-json/builddir/test/cmake_add_subdirectory/nlohmann_json.pc":
  No such file or directory.
Call Stack (most recent call first):
  test/cmake_add_subdirectory/cmake_install.cmake:47 (include)
  test/cmake_install.cmake:49 (include)
  cmake_install.cmake:94 (include)
```
2020-07-27 18:15:18 -04:00
Vitaly Zaitsev 8f9dc7eabe
Fixed installation of pkg-config file on other than Ubuntu
distributions.

Signed-off-by: Vitaly Zaitsev <vitaly@easycoding.org>
2020-07-27 16:54:16 +02:00
Niels Lohmann e110667d21
🔖 set version to 3.9.0 2020-07-27 15:48:09 +02:00
Niels Lohmann fb22233f34
🔊 add message if implicit conversions are switched off 2020-07-23 13:11:48 +02:00
Théo DELRIEU 74b446f5fd
add a switch to enable implicit conversions (defaults to true)
wrap implicit conversions tests around the JSON_USE_IMPLICIT_CONVERSIONS
macro
2020-07-22 10:49:01 +02:00
Niels Lohmann cbafed3494
⬇️ require CMake 3.1 2020-07-10 12:53:48 +02:00
Palmer Dabbelt c7d18c1625 cmake: Generate and install a pkg-config file.
The meson builds install a pkg-config file, but the cmake builds don't.
This adds a pkg-config file to the cmake builds that is functionally
equivalent to the one generated from meson.
2020-07-09 03:59:53 -03:00
Alex Reinking ec43371e07
Enable CMake policy CMP0077
Projects that import json via [FetchContent](https://cmake.org/cmake/help/latest/module/FetchContent.html) or `add_subdirectory` pointed at a git submodule may want to set `JSON_BuildTests` to "NO". However, this doesn't work without creating an identical `option()` in the importing project. Enabling CMP0077 in supported versions of CMake changes the behavior of `option()` to allow importing projects to set default values for the variables without touching the cache.

See the documentation for CMP0077 here: https://cmake.org/cmake/help/latest/policy/CMP0077.html
2020-06-26 11:47:36 -07:00
Niels Lohmann 5f862710fe
🔖 set version to 3.8.0 2020-06-14 17:16:45 +02:00
Niels Lohmann c92a696852
📝 update documentation 2020-05-22 18:21:37 +02:00
Niels Lohmann be137609df
Merge pull request #1746 from uhoreg/cmake_arch_indep
make CMake's version config file architecture-independent
2020-04-19 10:09:28 +02:00
Hubert Chathi 2b0e4c7a94 add comments 2020-04-17 15:44:12 -04:00
Niels Lohmann c5eafe74e8
🔖 set version to 3.7.3 2019-11-17 12:09:12 +01:00
Niels Lohmann 56109eacd7
🔖 set version to 3.7.2 2019-11-10 21:23:39 +01:00
Niels Lohmann aacdc6bbe3
🔖 set version to 3.7.1 2019-11-06 18:37:26 +01:00
Hubert Chathi cade804c1a make CMake's version config file architecture-independent 2019-09-10 23:41:38 -04:00