@@ -55,14 +55,32 @@ add_library(graphqlservice
5555 GraphQLService.cpp
5656 Introspection.cpp
5757 IntrospectionSchema.cpp)
58- target_link_libraries (graphqlservice PRIVATE taocpp::pegtl)
59- target_link_libraries (graphqlservice PUBLIC Threads::Threads)
58+ target_link_libraries (graphqlservice PUBLIC
59+ taocpp::pegtl
60+ Threads::Threads)
6061target_include_directories (graphqlservice PUBLIC
6162 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /include >
6263 $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR} /include >
6364 $<INSTALL_INTERFACE:include >)
6465cppgraphqlgen_target_set_cxx_standard(graphqlservice)
6566
67+ # RapidJSON is the only option for JSON serialization used in this project, but if you want
68+ # to use another JSON library you can implement an alternate version of the functions in
69+ # JSONResponse.cpp to serialize to and from GraphQLResponse and build graphqljson from that.
70+ option (USE_RAPIDJSON "Use RapidJSON for JSON serialization." ON )
71+
72+ if (USE_RAPIDJSON)
73+ find_package (RapidJSON CONFIG REQUIRED)
74+
75+ add_library (graphqljson
76+ JSONResponse.cpp)
77+ target_link_libraries (graphqljson PUBLIC
78+ graphqlservice)
79+ target_include_directories (graphqljson SYSTEM PRIVATE
80+ ${RAPIDJSON_INCLUDE_DIRS} )
81+ cppgraphqlgen_target_set_cxx_standard(graphqljson)
82+ endif ()
83+
6684option (BUILD_TESTS "Build the tests and sample schema library." ON )
6785option (UPDATE_SAMPLES "Regenerate the sample schema sources whether or not we're building the tests and the sample library." ON )
6886
@@ -83,16 +101,12 @@ if(BUILD_TESTS OR UPDATE_SAMPLES)
83101 )
84102
85103 if (BUILD_TESTS)
86- find_package (RapidJSON CONFIG REQUIRED)
87-
88104 add_library (todaygraphql
89- Today.cpp
90- TodaySchema.cpp
91- JSONResponse.cpp)
105+ Today.cpp
106+ TodaySchema.cpp)
92107 target_link_libraries (todaygraphql PUBLIC
93- graphqlservice)
94- target_include_directories (todaygraphql SYSTEM PUBLIC
95- ${RAPIDJSON_INCLUDE_DIRS} )
108+ graphqlservice
109+ graphqljson)
96110 target_include_directories (todaygraphql PUBLIC
97111 ${CMAKE_CURRENT_SOURCE_DIR} /include
98112 ${CMAKE_CURRENT_BINARY_DIR} /include )
@@ -136,7 +150,9 @@ if(BUILD_TESTS OR UPDATE_SAMPLES)
136150 endif ()
137151endif ()
138152
139- install (TARGETS graphqlservice
153+ install (TARGETS
154+ graphqlservice
155+ graphqljson
140156 EXPORT cppgraphqlgen-targets
141157 RUNTIME DESTINATION bin
142158 ARCHIVE DESTINATION lib
0 commit comments