Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .devcontainer
Submodule .devcontainer added at 97db0d
7 changes: 6 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@ Dockerfile text
# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary
*.json binary
bin/**/*.json binary
library.json binary
package.json binary

# Exceptions for JSON files that should be treated as text
CMakePresets*.json text eol=lf
30 changes: 30 additions & 0 deletions .github/workflows/xpbuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Build
on:
push:
branches: [ "dev" ]
pull_request:
branches: [ "dev" ]
workflow_dispatch:
jobs:
linux:
uses: externpro/externpro/.github/workflows/build-linux.yml@25.05.2
with:
cmake-workflow-preset: LinuxRelease
runon: ubuntu-latest
secrets: inherit
linux-arm64:
uses: externpro/externpro/.github/workflows/build-linux.yml@25.05.2
with:
cmake-workflow-preset: LinuxRelease
runon: ubuntu-24.04-arm
secrets: inherit
macos:
uses: externpro/externpro/.github/workflows/build-macos.yml@25.05.2
with:
cmake-workflow-preset: DarwinRelease
secrets: inherit
windows:
uses: externpro/externpro/.github/workflows/build-windows.yml@25.05.2
with:
cmake-workflow-preset: WindowsRelease
secrets: inherit
20 changes: 20 additions & 0 deletions .github/workflows/xprelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Release
on:
workflow_dispatch:
inputs:
workflow_run_url:
description: 'URL of the workflow run containing artifacts to upload (e.g., https://github.com/owner/repo/actions/runs/123456789)'
required: true
type: string
jobs:
# Upload build artifacts as release assets
release-from-build:
uses: externpro/externpro/.github/workflows/release-from-build.yml@25.05.2
with:
workflow_run_url: ${{ github.event.inputs.workflow_run_url }}
artifact_pattern: "*.tar.xz"
permissions:
contents: write
id-token: write
attestations: write
secrets: inherit
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@ Doxyfile
Doxyfile.zh-cn
DartConfiguration.tcl
*.nupkg

# externpro
.env
_bld*/
docker-compose.override.yml
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "thirdparty/gtest"]
path = thirdparty/gtest
url = https://github.com/google/googletest.git
[submodule ".devcontainer"]
path = .devcontainer
url = https://github.com/externpro/externpro
30 changes: 19 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,13 @@ if(POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)
endif()

set(CMAKE_PROJECT_TOP_LEVEL_INCLUDES .devcontainer/cmake/xproinc.cmake)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules)

PROJECT(RapidJSON CXX)

include(GNUInstallDirs)
include(xpflags)
if(DEFINED XP_NAMESPACE)
set(nameSpace NAMESPACE ${XP_NAMESPACE}::)
set(XP_OPT_INSTALL EXCLUDE_FROM_ALL)
endif()

set(LIB_MAJOR_VERSION "1")
set(LIB_MINOR_VERSION "1")
Expand Down Expand Up @@ -113,9 +110,24 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
string(TOLOWER ${PROJECT_NAME} lib_name)
add_library(${lib_name} INTERFACE)
target_include_directories(${lib_name} INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)

function(callPackageDevel)
set(lib ${lib_name})
string(PREPEND lib "${XP_NAMESPACE}::")
set(CMAKE_PROJECT_NAME ${lib_name})
xpPackageDevel(TARGETS_FILE ${targetsFile} LIBRARIES ${lib})
endfunction()

set(targetsFile ${lib_name}-targets)
install(TARGETS ${lib_name} EXPORT ${targetsFile})
install(EXPORT ${targetsFile} DESTINATION ${CMAKE_INSTALL_DIR} ${nameSpace})
if(DEFINED XP_NAMESPACE)
set(nameSpace NAMESPACE ${XP_NAMESPACE}::)
callPackageDevel()
set(RAPIDJSON_COMPONENT devel)
else()
set(RAPIDJSON_COMPONENT dev)
endif()
install(TARGETS ${lib_name} EXPORT ${targetsFile} COMPONENT devel)
install(EXPORT ${targetsFile} DESTINATION ${CMAKE_INSTALL_DIR} ${nameSpace} COMPONENT devel)

if(RAPIDJSON_BUILD_DOC)
add_subdirectory(doc)
Expand Down Expand Up @@ -144,22 +156,19 @@ IF (UNIX OR CYGWIN)
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc
@ONLY)
INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc
${XP_OPT_INSTALL}
DESTINATION "${LIB_INSTALL_DIR}/pkgconfig"
COMPONENT pkgconfig)
ENDIF()

install(FILES readme.md
${XP_OPT_INSTALL}
DESTINATION "${DOC_INSTALL_DIR}"
COMPONENT doc)

install(DIRECTORY include/rapidjson
DESTINATION "${INCLUDE_INSTALL_DIR}"
COMPONENT dev)
COMPONENT ${RAPIDJSON_COMPONENT})

install(DIRECTORY example/
${XP_OPT_INSTALL}
DESTINATION "${DOC_INSTALL_DIR}/examples"
COMPONENT examples
# Following patterns are for excluding the intermediate/object files
Expand All @@ -183,6 +192,5 @@ CONFIGURE_FILE(${PROJECT_NAME}ConfigVersion.cmake.in
INSTALL(FILES
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
${XP_OPT_INSTALL}
DESTINATION "${CMAKE_INSTALL_DIR}"
COMPONENT dev)
8 changes: 8 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"version": 8,
"include": [
".devcontainer/cmake/presets/xpLinuxNinja.json",
".devcontainer/cmake/presets/xpDarwinNinja.json",
".devcontainer/cmake/presets/xpWindowsVs2022.json"
]
}
19 changes: 19 additions & 0 deletions CMakePresetsBase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"version": 8,
"configurePresets": [
{
"name": "config-base",
"hidden": true,
"binaryDir": "${sourceDir}/_bld-${presetName}",
"cacheVariables": {
"XP_NAMESPACE": "xpro"
}
}
],
"buildPresets": [
{
"name": "build-base",
"hidden": true
}
]
}
1 change: 1 addition & 0 deletions docker-compose.sh
1 change: 1 addition & 0 deletions docker-compose.yml
2 changes: 1 addition & 1 deletion example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8...3.24)
cmake_minimum_required(VERSION 2.8...3.31)

if(POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)
Expand Down
15 changes: 14 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
find_package(GTestSrc)
if(COMMAND xpFindPkg)
xpFindPkg(PKGS googletest)
enable_testing()
get_target_property(GTEST_INCLUDE_DIR xpro::gtest INTERFACE_INCLUDE_DIRECTORIES)
include_directories(SYSTEM ${GTEST_INCLUDE_DIR})
set(TEST_LIBRARIES xpro::gtest xpro::gtest_main)
if(FALSE) # doesn't build with googletest-v1.16.0.1
add_custom_target(tests ALL)
add_subdirectory(perftest)
add_subdirectory(unittest)
endif()
else()
find_package(GTestSrc)
endif()

IF(GTESTSRC_FOUND)
enable_testing()
Expand Down
7 changes: 7 additions & 0 deletions test/perftest/schematest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@

using namespace rapidjson;

RAPIDJSON_DIAG_PUSH
#if defined(__GNUC__) && __GNUC__ >= 7
RAPIDJSON_DIAG_OFF(format-overflow)
#endif

template <typename Allocator>
static char* ReadFile(const char* filename, Allocator& allocator) {
const char *paths[] = {
Expand Down Expand Up @@ -42,6 +47,8 @@ static char* ReadFile(const char* filename, Allocator& allocator) {
return json;
}

RAPIDJSON_DIAG_POP

class Schema : public PerfTest {
public:
Schema() {}
Expand Down
Loading