Skip to content

Commit 7a2d07b

Browse files
committed
Make tests depend on building any graphqljson implementation
1 parent 4a9b80b commit 7a2d07b

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

CMakeLists.txt

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,36 @@ cppgraphqlgen_target_set_cxx_standard(graphqlservice)
6767
# RapidJSON is the only option for JSON serialization used in this project, but if you want
6868
# to use another JSON library you can implement an alternate version of the functions in
6969
# 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.
7073
option(USE_RAPIDJSON "Use RapidJSON for JSON serialization." ON)
7174

7275
if(USE_RAPIDJSON)
7376
find_package(RapidJSON CONFIG REQUIRED)
7477

78+
set(BUILD_GRAPHQLJSON ON)
7579
add_library(graphqljson
7680
JSONResponse.cpp)
77-
target_link_libraries(graphqljson PUBLIC
78-
graphqlservice)
7981
target_include_directories(graphqljson SYSTEM PRIVATE
8082
${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)
8190
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)
8298
endif()
8399

84-
option(BUILD_TESTS "Build the tests and sample schema library." ON)
85100
option(UPDATE_SAMPLES "Regenerate the sample schema sources whether or not we're building the tests and the sample library." ON)
86101

87102
if(BUILD_TESTS OR UPDATE_SAMPLES)
@@ -160,15 +175,6 @@ install(TARGETS
160175
ARCHIVE DESTINATION lib
161176
LIBRARY DESTINATION lib)
162177

163-
if(USE_RAPIDJSON)
164-
install(TARGETS
165-
graphqljson
166-
EXPORT cppgraphqlgen-targets
167-
RUNTIME DESTINATION bin
168-
ARCHIVE DESTINATION lib
169-
LIBRARY DESTINATION lib)
170-
endif()
171-
172178
set(CMAKE_INSTALL_TOOLSDIR ${CMAKE_INSTALL_PREFIX}/bin/${PROJECT_NAME}
173179
CACHE PATH "Install schemagen to this directory.")
174180

0 commit comments

Comments
 (0)