@@ -67,21 +67,38 @@ cppgraphqlgen_target_set_cxx_standard(graphqlservice)
67
67
# RapidJSON is the only option for JSON serialization used in this project, but if you want
68
68
# to use another JSON library you can implement an alternate version of the functions in
69
69
# JSONResponse.cpp to serialize to and from GraphQLResponse and build graphqljson from that.
70
+ # You will also need to define how to build the graphqljson library target with your
71
+ # implementation, and you should set BUILD_GRAPHQLJSON so that the test dependencies know
72
+ # about your version of graphqljson.
70
73
option (USE_RAPIDJSON "Use RapidJSON for JSON serialization." ON )
71
74
72
75
if (USE_RAPIDJSON )
73
76
find_package (RapidJSON CONFIG REQUIRED )
74
77
78
+ set (BUILD_GRAPHQLJSON ON )
75
79
add_library (graphqljson
76
80
JSONResponse.cpp )
77
- target_link_libraries (graphqljson PUBLIC
78
- graphqlservice )
79
81
target_include_directories (graphqljson SYSTEM PRIVATE
80
82
${RAPIDJSON_INCLUDE_DIRS} )
83
+ endif ()
84
+
85
+ if (BUILD_GRAPHQLJSON )
86
+ option (BUILD_TESTS "Build the tests and sample schema library." ON )
87
+
88
+ target_link_libraries (graphqljson PUBLIC
89
+ graphqlservice )
81
90
cppgraphqlgen_target_set_cxx_standard (graphqljson )
91
+
92
+ install (TARGETS
93
+ graphqljson
94
+ EXPORT cppgraphqlgen-targets
95
+ RUNTIME DESTINATION bin
96
+ ARCHIVE DESTINATION lib
97
+ LIBRARY DESTINATION lib )
98
+ else ()
99
+ set (BUILD_TESTS OFF )
82
100
endif ()
83
101
84
- option (BUILD_TESTS "Build the tests and sample schema library." ON )
85
102
option (UPDATE_SAMPLES "Regenerate the sample schema sources whether or not we're building the tests and the sample library." ON )
86
103
87
104
if (BUILD_TESTS OR UPDATE_SAMPLES )
@@ -100,22 +117,22 @@ if(BUILD_TESTS OR UPDATE_SAMPLES)
100
117
DEPENDS TodaySchema.cpp
101
118
)
102
119
103
- if (BUILD_TESTS )
104
- add_library (todaygraphql
105
- Today.cpp
106
- TodaySchema.cpp )
107
- target_link_libraries (todaygraphql PUBLIC
108
- graphqlservice
109
- graphqljson )
110
- target_include_directories (todaygraphql PUBLIC
111
- ${CMAKE_CURRENT_SOURCE_DIR} /include
112
- ${CMAKE_CURRENT_BINARY_DIR} /include )
113
- cppgraphqlgen_target_set_cxx_standard (todaygraphql )
120
+ add_library (todaygraphql
121
+ Today.cpp
122
+ TodaySchema.cpp )
123
+ target_link_libraries (todaygraphql PUBLIC
124
+ graphqlservice )
125
+ target_include_directories (todaygraphql PUBLIC
126
+ ${CMAKE_CURRENT_SOURCE_DIR} /include
127
+ ${CMAKE_CURRENT_BINARY_DIR} /include )
128
+ cppgraphqlgen_target_set_cxx_standard (todaygraphql )
114
129
130
+ if (BUILD_TESTS )
115
131
add_executable (test_today
116
132
test_today.cpp )
117
133
target_link_libraries (test_today PRIVATE
118
- todaygraphql )
134
+ todaygraphql
135
+ graphqljson )
119
136
cppgraphqlgen_target_set_cxx_standard (test_today )
120
137
121
138
enable_testing ()
@@ -125,6 +142,7 @@ if(BUILD_TESTS OR UPDATE_SAMPLES)
125
142
tests.cpp )
126
143
target_link_libraries (tests PRIVATE
127
144
todaygraphql
145
+ graphqljson
128
146
GTest::GTest
129
147
GTest::Main )
130
148
cppgraphqlgen_target_set_cxx_standard (tests )
@@ -155,7 +173,6 @@ endif()
155
173
156
174
install (TARGETS
157
175
graphqlservice
158
- graphqljson
159
176
EXPORT cppgraphqlgen-targets
160
177
RUNTIME DESTINATION bin
161
178
ARCHIVE DESTINATION lib
0 commit comments