valgrind is not present on all architectures (eg riscv64) and might
not be installed even on supported architectures.
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
When trying to import rapidjson with for exemple :
fetchcontent_declare(rapidjson GIT_REPOSITORY https://github.com/Tencent/rapidjson.git)
if your CMake/Clang is "bare metal", exemple given :
set(CMAKE_SYSTEM_NAME none)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
set(CMAKE_C_COMPILER_TARGET x86_64-elf-none)
set(CMAKE_CXX_COMPILER_TARGET x86_64-elf-none)
CMake fails to process CMakeLists.txt because of the switch on UNIX/CYGWIN/WIN32 for install directory.
Error is:
CMake Error at cmake-build-debug-clang/_deps/rapidjson-src/CMakeLists.txt:244 (INSTALL):
INSTALL FILES given no DESTINATION!
When RAPIDJSON_USE_MEMBERSMAP is defined, an object Value will store
its members in an (re)allocated array of Members like before, but also
in an std::multimap<GenericValue::Data,SizeType> where the key and value
reference the corresponding Member by its Data and index in the array,
respectively, and in a relocatable manner.
The layout of the members map/array is now:
{multimap*}<>{capacity}<>{Member[capacity]}<>{multimap::iterator[capacity]}
where <> stands for the RAPIDJSON_ALIGN-ment of each part, if needed.
This layout needs to be reallocated when the current capacity is
exhausted, which requires to take care of the multimap and its iterators
explicitely. The multimap is allocated separately and only its pointer is
saved in this layout, so it can easily be restored in its new position.
As for the old/alive iterators, they must move to their new offset according
to the new capacity.
With this in place, it's immediate to get the multimap::iterator from a
MemberIterator and vice versa, thus the same complexity applies for the
operations with MemberIterator or MapIterator.
For FindMember() and RemoveMember(), the complexity drops from O(n) to
the multimap/rbtree's O(log n).
For EraseMember() it drops from O(n-m) to O((log n)-m), m representing
the move/copy of the trailing members.
For AddMember() though, the complexity grows from O(1) to O(log n) due to
the insertion in the multimap too.
Consequently parsing will be slower, up to ~20% measured in perftests on
my laptop (since it's mainly composed of insertions). But later work on
the Document (usually the goal of parsing...) will be much faster; the
new DocumentFind perftest included in this commit is 8 times faster with
RAPIDJSON_USE_MEMBERSMAP (still on my laptop). Overall the tests are 4%
slower (mainly composed of parsing), and notably 15% slower for schemas
parsing/validation (which supposedly comes from the larger JSON files
parsing, still). As a side note, when RAPIDJSON_USE_MEMBERSMAP is not
defined, this commit does nothing (same results for perftest with regard
to previous versions).
Finally, the multimap is allocated and constructed using StdAllocator,
so they will use the same Allocator than for any other Value allocation,
and thus will benefit from the same performance/safety/security/whatever
provided by the user given Allocator.
Currently this path is hardcoded to lib/cmake.
Some distributions have different library path (like lib64).
So reuse LIB_INSTALL_DIR for that to make CMAKECONFIG_INSTALL_DIR
configurable and usable in such distros.
Signed-off-by: Ruslan Bilovol <rbilovol@cisco.com>
This will introduce RAPIDJSON_BUILD_THIRDPARTY_GTEST option. If it is set to
TRUE, cmake will look for GTest installation in `thirdparty/gtest` before
looking in other places.
Current default value (OFF) for RAPIDJSON_BUILD_THIRDPARTY_GTEST represents
previous behaviour when system-wide gtest installation is used whenever
possible.
This commit will as well eliminate problem described in #309 when source
directory found is `thirdparty/gtest` while include files are found
system-wide. This however won't give the user possibility to select gtest
installation to use.