@@ -55,14 +55,32 @@ add_library(graphqlservice
55
55
GraphQLService.cpp
56
56
Introspection.cpp
57
57
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 )
60
61
target_include_directories (graphqlservice PUBLIC
61
62
$< BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /include>
62
63
$< BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR} /include>
63
64
$< INSTALL_INTERFACE:include> )
64
65
cppgraphqlgen_target_set_cxx_standard (graphqlservice )
65
66
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
+
66
84
option (BUILD_TESTS "Build the tests and sample schema library." ON )
67
85
option (UPDATE_SAMPLES "Regenerate the sample schema sources whether or not we're building the tests and the sample library." ON )
68
86
@@ -83,16 +101,12 @@ if(BUILD_TESTS OR UPDATE_SAMPLES)
83
101
)
84
102
85
103
if (BUILD_TESTS )
86
- find_package (RapidJSON CONFIG REQUIRED )
87
-
88
104
add_library (todaygraphql
89
- Today.cpp
90
- TodaySchema.cpp
91
- JSONResponse.cpp )
105
+ Today.cpp
106
+ TodaySchema.cpp )
92
107
target_link_libraries (todaygraphql PUBLIC
93
- graphqlservice )
94
- target_include_directories (todaygraphql SYSTEM PUBLIC
95
- ${RAPIDJSON_INCLUDE_DIRS} )
108
+ graphqlservice
109
+ graphqljson )
96
110
target_include_directories (todaygraphql PUBLIC
97
111
${CMAKE_CURRENT_SOURCE_DIR} /include
98
112
${CMAKE_CURRENT_BINARY_DIR} /include )
@@ -136,7 +150,9 @@ if(BUILD_TESTS OR UPDATE_SAMPLES)
136
150
endif ()
137
151
endif ()
138
152
139
- install (TARGETS graphqlservice
153
+ install (TARGETS
154
+ graphqlservice
155
+ graphqljson
140
156
EXPORT cppgraphqlgen-targets
141
157
RUNTIME DESTINATION bin
142
158
ARCHIVE DESTINATION lib
0 commit comments