Commit Graph

48 Commits

Author SHA1 Message Date
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
Florian Albrechtskirchinger
f208a9c19b
Fix C++20/gcc-12 issues (Part 1) (#3379)
* 🔧 use proper GCC binary

* 🔧 add more GCC warning flags

* ⚗️ try fix from https://github.com/nlohmann/json/issues/3138#issuecomment-1015562666

* Fix custom allocator test build failures (C++20)

Allocator tests fail to compile in C++20 mode with clang+MS STL due
to missing copy constructors.

* Fix test build failures due to missing noexcept (gcc-12)

* alt_string has multiple member functions that should be marked noexcept.
* nlohmann::ordered_map constructors can be noexcept.

Compilation failures result from the warning flag -Werror=noexcept and
gcc-12.

* Disable broken comparison tests in C++20 mode

Co-authored-by: Niels Lohmann <mail@nlohmann.me>
2022-03-07 22:19:28 +01:00
Niels Lohmann
1aca6cb949
Add build step for NVCC and fix a warning (#3227)
* 👷 add step for NVCC build #2676
* 🚨 fix warning (code taken from #2736)
* 👷 use version 2.2.0 of the CI image
2021-12-30 13:40:15 +01:00
Niels Lohmann
6d3115924c
Add C++17 copies of the test binaries (#3101)
* ⚗️ add C++17 copies of the test binaries
* ⚗️ use proper header for filesystem
* 🚨 fix warnings
* ⚗️ do not use too old compilers with C++17
*  add test
* 🔨 add more constraints #3097
* ⚗️ use fix from https://github.com/nlohmann/json/pull/3101#issuecomment-998788786
* ⚗️ use fix from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90050
* 👷 use published CI image
2021-12-29 09:47:05 +01:00
Niels Lohmann
7440786b81
Update CI (#3088)
* 👷 prepare GitHub actions for new Docker image

* 👷 use experimental docker image

* 👷 use Clang-Analyzer 14

* 🔇 suppress readability-identifier-length

* 🔇 suppress more Clang-Tidy warnings

* ♻️ simplify code

* 🔇 suppress more Clang-Tidy warnings

* 🔇 suppress more Clang-Tidy warnings

* 🚨 fix warning

* 🚨 fix warning

* 🚨 fix warning

* 👷 use new Docker image
2021-10-29 21:27:34 +02:00
Niels Lohmann
e0b02c355e
Use new Docker image (#2981) 2021-08-29 18:05:31 +02:00
Niels Lohmann
8cae9d7cd2
Overwork warning flags (#2936)
* ⚗️ update warning flags
2021-08-17 14:43:43 +02:00
Ferry Huberts
832cee5b77 Adjust warnings flags, as requested
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
2021-08-12 19:49:54 +02:00
Niels Lohmann
7feb2c20cf
🚨 fix useless-cast warnings 2021-07-30 14:48:25 +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
835749efcc
add test for JSON_SystemInclude flag 2021-07-16 12:34:15 +02:00
Niels Lohmann
249688037f
⚗️ fix coverage 2021-07-11 09:33:43 +02:00
Niels Lohmann
7442c24662
🚨 suppress missingReturn warnings 2021-07-10 13:44:13 +02:00
Niels Lohmann
f6e9654aaa
🔇 suppress unsigned integer warnings 2021-04-25 14:33:12 +02:00
Niels Lohmann
0638a27ed3
👷 add step for Infer 2021-04-24 13:50:30 +02:00
Niels Lohmann
10fc5162e7
⬆️ use Clang 12 where available 2021-04-24 13:24:36 +02:00
Doron Behar
53a9850eeb
pkg-config.pc.in: Don't concatenate paths
See: https://github.com/jtojnar/cmake-snips#assuming-cmake_install_dir-is-relative-path
2021-03-29 21:43:49 +00:00
Niels Lohmann
ae99a31bea
🚧 add more CI tests 2021-03-28 14:48:58 +02:00
Niels Lohmann
1f1fa9f30e
🔥 remove some Travis builds 2021-03-27 14:44:39 +01:00
Niels Lohmann
9d57351175
🐛 set correct value for JSON_ImplicitConversions in ci_test_noimplicitconversions 2021-03-24 20:27:12 +01: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
Jun Jie
41a99567e0 fix cmake script overwriting compiler path
This fixes #2343
2020-08-07 16:08:02 +08: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
Niels Lohmann
e4675887a6
Merge branch 'develop' of https://github.com/nlohmann/json into issue2189 2020-06-20 09:47:12 +02:00
Niels Lohmann
cd115cbc33
update test suite 2020-06-18 12:50:32 +02:00
Niels Lohmann
4d96f4cf6a
🔧 overwork CMake files 2020-06-16 20:23:01 +02:00
Niels Lohmann
f4c4bab600
add option JSON_TestDataDirectory to set path with test data #2189 2020-06-16 12:55:36 +02:00
Niels Lohmann
ad32f576bd
Merge branch 'develop' of https://github.com/nlohmann/json into release_cleanup 2020-05-16 13:22:23 +02:00
Niels Lohmann
fc267af909
📝 update CI list 2020-05-14 17:53:00 +02:00
Niels Lohmann
f4cc729054
🔊 add compiler version output 2020-05-14 13:37:59 +02:00
Niels Lohmann
e91236e6d3
🔊 add compiler version output 2020-05-14 13:33:10 +02:00
chenguoping
8f5b5c7469 use json_test_data version 2.0.0 2020-05-14 15:11:38 +08:00
Niels Lohmann
f6f350a5c7
🔊 add operating system output 2020-05-13 14:25:51 +02:00
Niels Lohmann
5bfb27c865
🚨 fix some warnings 2020-05-08 12:32:28 +02:00
Niels Lohmann
2304629a3f
📌 use JSON test data v1.0.0 2020-05-04 16:00:00 +02:00
Niels Lohmann
bec554936c
🔨 fix paths 2020-05-02 10:56:01 +02:00
Niels Lohmann
cfb2f34ebb
🔨 fix benchmarks 2020-05-01 20:59:47 +02:00
Hubert Chathi
2b0e4c7a94 add comments 2020-04-17 15:44:12 -04:00
Hubert Chathi
cade804c1a make CMake's version config file architecture-independent 2019-09-10 23:41:38 -04:00
Chuck Atkins
1729db85c1 cmake: fix package config to deal with versioning and namespaces 2018-09-30 09:56:33 -04:00
Chuck Atkins
3b1a5cafad Use a version check to provide backwards comatible imported target names. 2018-09-18 13:59:19 -04:00
Chuck Atkins
33a2154f8d Enable target namespaces and build dir project config
CMake convention is to use a project namespace, i.e. Foo::, for imported
targets.  When multiple targets are imported from a project, this looks
like Foo::Bar1 Foo::Bar2, etc.  This adds the nlohmann_json:: namespace to
the exported target names.

This also allows the generated project config files to be used from the
build directory instead of just the install directory.
2018-04-10 09:08:38 -04:00
Niels Lohmann
99ee4c1eaf
🔨 cleaned up Makefiles and docs #698 2017-10-04 19:27:35 +02:00
dan-42
f434942371 REFACTOR: rewrite CMakeLists.txt for better inlcude and reuse
The rewrite uses more cmake build-in automatisms and build-in generates
variables to allow better generic reuse.
* cmake  files are installed to
``` <install_prefix>/lib/cmake/nlohmann_json/ ``` for best support on
most systems
* include path is set to ``` include ```  for usage as ``` #include
<nlohmann/json.hpp> ```
2017-07-29 11:59:09 +02:00
Tushar Maheshwari
85ce4d7b53 cmake compile time reduce using cotire
- Add prefix header
  - Include catch.hpp
  - Include json.hpp
    - Replace private with public for all json_unit files
- Move `unit.cpp` to an object library
- cotire issue: strip whitespace from CMAKE_INCLUDE_SYSTEM_FLAG_CXX
2017-02-19 13:35:54 +05:30
Christoph Jud
e1b6a23049 relocation of install-include directory for other packages 2016-09-26 12:15:03 +02:00
Robert Marki
b1a2e9a715 Create an install target for the project
- define the project's version in the cmake listfile
- create a config and config version file for the cmake package
- install the json.hpp file and the package's targets, config and
config version files
2016-04-25 10:27:19 +02:00