Skip to content

Commit

Permalink
Introduce new ECSTASY_SERIALIZER_JSON option adding RapidJson as depe…
Browse files Browse the repository at this point in the history
…ndency

Linked: #164
  • Loading branch information
AndreasLrx committed Oct 13, 2024
1 parent 90fe105 commit 9394936
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/build-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ jobs:
-DECSTASY_INTEGRATIONS_SFML=TRUE
-DECSTASY_INTEGRATIONS_SFML_BUILD_DEMO=TRUE
-DECSTASY_INTEGRATIONS_USER_ACTION=TRUE
-DECSTASY_SERIALIZER_JSON=TRUE
-DECSTASY_THREAD_SAFE=TRUE

- name: Build
Expand Down
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ if (${ECSTASY_SERIALIZER_TOML})
set(TomlPlusPlus_IncDir ${tomlplusplus_SOURCE_DIR}/include)
endif()

if (${ECSTASY_SERIALIZER_JSON})
find_package(RapidJson)
endif()

project(ecstasy LANGUAGES CXX)
set(VERSION_MAJOR 1)
set(VERSION_MINOR 0)
Expand Down Expand Up @@ -54,4 +58,4 @@ if(BUILD_TEST_SUITE)

set(BUILDING_TESTS 1)
add_subdirectory(tests)
endif()
endif()
4 changes: 4 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
"type": "BOOL",
"value": "TRUE"
},
"ECSTASY_SERIALIZER_JSON": {
"type": "BOOL",
"value": "TRUE"
},
"ECSTASY_THREAD_SAFE": {
"type": "BOOL",
"value": "TRUE"
Expand Down
20 changes: 20 additions & 0 deletions cmake/FindRapidJson.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

CMAKE_MINIMUM_REQUIRED(VERSION 3.15)

if(NOT rapidjson_FOUND)
include(FetchContent)

FetchContent_Declare(rapidjson
GIT_REPOSITORY https://github.com/Tencent/rapidjson
GIT_TAG master
)

FetchContent_GetProperties(rapidjson)

if(NOT rapidjson_POPULATED)
SET(FETCHCONTENT_QUIET NO)
FetchContent_Populate(rapidjson)
SET(RAPIDJSON_INCLUDE_PATH "${rapidjson_SOURCE_DIR}/include")
SET(rapidjson_FOUND TRUE)
endif()
endif()
2 changes: 2 additions & 0 deletions cmake/Options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ CMAKE_DEPENDENT_OPTION(ECSTASY_INTEGRATIONS_USER_ACTION "User Action integration

## Serializer formats
option(ECSTASY_SERIALIZER_TOML "Build Toml serializer." OFF)
option(ECSTASY_SERIALIZER_JSON "Build Json serializer." OFF)

if (${ECSTASY_INTEGRATIONS_USER_ACTION})
set(ECSTASY_SERIALIZER_TOML ON)
Expand Down Expand Up @@ -65,5 +66,6 @@ list(APPEND CMAKE_MESSAGE_INDENT " ")
message(STATUS "Serializes:")
list(APPEND CMAKE_MESSAGE_INDENT " ")
message(STATUS "Toml: ${ECSTASY_SERIALIZER_TOML}")
message(STATUS "Json: ${ECSTASY_SERIALIZER_JSON}")
list(POP_BACK CMAKE_MESSAGE_INDENT)
list(POP_BACK CMAKE_MESSAGE_INDENT)
1 change: 1 addition & 0 deletions doc/Building.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,4 @@ _In case this documentation is not up to date with the [Options.cmake](/cmake/Op
| ECSTASY_INTEGRATIONS_SFML_BUILD_DEMO | Enable the Sfml integration demos. Requires **ECSTASY_INTEGRATIONS_SFML** | OFF |
| ECSTASY_INTEGRATIONS_USER_ACTION | Enable the User Actions integration. Requires **ECSTASY_INTEGRATIONS_EVENT** | OFF |
| ECSTASY_SERIALIZER_TOML | Enable the Toml Serializer. Force set if **ECSTASY_INTEGRATIONS_USER_ACTION** is set | OFF |
| ECSTASY_SERIALIZER_JSON | Enable the Json Serializer. | OFF |
3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ endif()
if (${ECSTASY_SERIALIZER_TOML})
target_link_libraries_system(${LIB_NAME} PRIVATE tomlplusplus::tomlplusplus)
endif()
if (${ECSTASY_SERIALIZER_JSON})
target_include_directories(${LIB_NAME} PUBLIC ${RAPIDJSON_INCLUDE_PATH})
endif()

target_include_directories(${LIB_NAME} PRIVATE ${INCDIRS})
target_include_directories(${LIB_NAME} PUBLIC ${INCROOT})
Expand Down
2 changes: 2 additions & 0 deletions src/ecstasy/config.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,7 @@ namespace ecstasy::thread

// Toml Serializer is available
#cmakedefine ECSTASY_SERIALIZER_TOML
// Json Serializer is available
#cmakedefine ECSTASY_SERIALIZER_JSON

#endif

0 comments on commit 9394936

Please sign in to comment.