Installation Guide
This document describes how to compile and install the RapidJSON optimized for Kunpeng.
Environment Requirements
| Software | Version Requirement | Description |
|---|---|---|
| OS | openEuler 22.03 LTS SP3 | Linux distribution |
| Compiler | Clang 16.0.6 or later GCC 9.0 or later |
C++03 or later. C++11 or later is recommended. |
| CMake | 3.5 or later | Build tool |
| Git | 2.0 or later | Version control |
| Doxygen | 1.8 or later (optional) | Documentation generator tool |
Obtaining Code
Run the following commands to obtain code:
git clone -b dev https://gitcode.com/boostkit/rapidjson.git cd rapidjsonIf integrating the optimization via a patch, you can first obtain the upstream RapidJSON source code and then apply the optimization patch from the master branch.
git clone https://github.com/Tencent/rapidjson.git cd rapidjson git checkout 24b5e7a git apply /path/to/kunpeng_opti_v1.0.0.patch
Compilation and Installation
Create a custom installation directory. You can change the directory as required.
mkdir -p /path/to/install/rapidjson-bin export RAPIDJSON_INSTALL_DIR=/path/to/install/rapidjson-binConfigure the build.
Create a
builddirectory.mkdir build cd buildConfigure and build. RapidJSON is a header-only library, so the installation primarily copies header files and CMake configurations.
cmake -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_CXX_FLAGS="-O3" \ -DCMAKE_INSTALL_PREFIX=${RAPIDJSON_INSTALL_DIR} \ ..
Perform compilation.
Use all available CPU cores for parallel compilation.
cmake --build . --parallel $(nproc)Alternatively, specify the number of cores (for example, 32 cores).
cmake --build . --parallel 32
Start installation.
cmake --install .Verify the installation directory.
ls -la ${RAPIDJSON_INSTALL_DIR}Command output:
total 16 drwxr-xr-x. 4 user user 4096 May 30 12:19 . drwxr-xr-x. 33 user user 4096 May 30 16:39 .. drwxr-xr-x. 3 user user 4096 May 30 12:19 include drwxr-xr-x. 3 user user 4096 May 30 12:19 libCheck the header files.
ls -la ${RAPIDJSON_INSTALL_DIR}/include/rapidjsonCommand output:
-rw-r--r--. 1 user user ... document.h -rw-r--r--. 1 user user ... reader.h -rw-r--r--. 1 user user ... writer.h -rw-r--r--. 1 user user ... stringbuffer.h
Compilation Option Description
Common CMake Options
| Option | Default Value | Description |
|---|---|---|
-DRAPIDJSON_BUILD_DOC |
OFF | Specifies whether to build documentation. |
-DRAPIDJSON_BUILD_EXAMPLES |
ON | Specifies whether to build examples. |
-DRAPIDJSON_BUILD_TESTS |
ON | Specifies whether to build tests. |
-DCMAKE_BUILD_TYPE |
Release | Specifies the build type (Release or Debug). |
-DCMAKE_CXX_FLAGS |
- | Specifies additional compilation flags (-O3 recommended). |
Performance Optimization Compilation Flag
Recommended compilation flag for the Arm architecture (Kunpeng processors).
cmake -DCMAKE_CXX_FLAGS="-O3 -march=armv8.2-a" ..
# Enables the NEON string scan path (typically available by default on AArch64).
cmake -DCMAKE_CXX_FLAGS="-O3 -march=armv8.2-a+simd -DRAPIDJSON_NEON" ..Running Test
Ensure you are in the
builddirectory.If the directory is not in the
builddirectory, run the following command to go to thebuilddirectory.cd buildIf the directory is already in the
builddirectory, go to the next step.
Select any of the following methods:
- Run all tests.
ctest --verbose- Run a specific test.
ctest -R unittest- Run tests in parallel.
ctest --parallel $(nproc)