@@ -40,11 +40,10 @@ cppgraphqlgen_target_set_cxx_standard(schemagen)
4040
4141add_custom_command (
4242 OUTPUT
43- graphqlservice/ IntrospectionSchema.cpp
44- graphqlservice/IntrospectionSchema.h
43+ IntrospectionSchema.cpp
44+ include / graphqlservice/IntrospectionSchema.h
4545 COMMAND schemagen
46- COMMAND ${CMAKE_COMMAND} -E rename IntrospectionSchema.cpp graphqlservice/IntrospectionSchema.cpp
47- COMMAND ${CMAKE_COMMAND} -E rename IntrospectionSchema.h graphqlservice/IntrospectionSchema.h
46+ COMMAND ${CMAKE_COMMAND} -E rename IntrospectionSchema.h include /graphqlservice/IntrospectionSchema.h
4847 DEPENDS schemagen
4948 COMMENT "Generating IntrospectionSchema files"
5049)
@@ -54,24 +53,30 @@ add_library(graphqlservice
5453 GraphQLResponse.cpp
5554 GraphQLService.cpp
5655 Introspection.cpp
57- ${CMAKE_BINARY_DIR} /graphqlservice/ IntrospectionSchema.cpp)
56+ IntrospectionSchema.cpp)
5857target_link_libraries (graphqlservice PRIVATE taocpp::pegtl)
5958target_link_libraries (graphqlservice PUBLIC Threads::Threads)
60- target_include_directories (graphqlservice
61- PUBLIC
62- $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR} /include >
63- $<BUILD_INTERFACE:${CMAKE_BINARY_DIR} >
64- $<INSTALL_INTERFACE:include >
65- )
59+ # Make system includes (e.g. <graphqlservice/public.h>) work relative to the build/install generator expressions
60+ target_include_directories (graphqlservice SYSTEM PUBLIC
61+ $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR} /include >
62+ $<BUILD_INTERFACE:${CMAKE_BINARY_DIR} /include >
63+ $<INSTALL_INTERFACE:include >)
64+ # Make local includes (e.g. "private.h") work while building graphqlservice, but don't export them
65+ target_include_directories (graphqlservice PRIVATE
66+ ${CMAKE_SOURCE_DIR} /include
67+ ${CMAKE_BINARY_DIR} /include )
6668cppgraphqlgen_target_set_cxx_standard(graphqlservice)
6769
6870option (BUILD_TESTS "Build the tests and sample schema library." ON )
6971option (UPDATE_SAMPLES "Regenerate the sample schema sources whether or not we're building the tests and the sample library." ON )
7072
7173if (BUILD_TESTS OR UPDATE_SAMPLES)
7274 add_custom_command (
73- OUTPUT TodaySchema.cpp TodaySchema.h
75+ OUTPUT
76+ TodaySchema.cpp
77+ include /TodaySchema.h
7478 COMMAND schemagen ${CMAKE_SOURCE_DIR} /schema.today.graphql Today today
79+ COMMAND ${CMAKE_COMMAND} -E rename TodaySchema.h include /TodaySchema.h
7580 DEPENDS schemagen schema.today.graphql
7681 COMMENT "Generating mock TodaySchema files"
7782 )
@@ -85,20 +90,22 @@ if(BUILD_TESTS OR UPDATE_SAMPLES)
8590 find_package (RapidJSON CONFIG REQUIRED)
8691
8792 add_library (todaygraphql
88- ${CMAKE_BINARY_DIR} /TodaySchema.cpp
8993 Today.cpp
94+ TodaySchema.cpp
9095 JSONResponse.cpp)
9196 target_link_libraries (todaygraphql PUBLIC
9297 graphqlservice)
9398 target_include_directories (todaygraphql SYSTEM PUBLIC ${RAPIDJSON_INCLUDE_DIRS} )
94- target_include_directories (todaygraphql PRIVATE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} )
99+ target_include_directories (todaygraphql
100+ PUBLIC
101+ ${CMAKE_SOURCE_DIR} /include
102+ ${CMAKE_BINARY_DIR} /include )
95103 cppgraphqlgen_target_set_cxx_standard(todaygraphql)
96104
97105 add_executable (test_today
98106 test_today.cpp)
99107 target_link_libraries (test_today PRIVATE
100108 todaygraphql)
101- target_include_directories (test_today PRIVATE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} )
102109 cppgraphqlgen_target_set_cxx_standard(test_today)
103110
104111 enable_testing ()
@@ -110,7 +117,6 @@ if(BUILD_TESTS OR UPDATE_SAMPLES)
110117 todaygraphql
111118 GTest::GTest
112119 GTest::Main)
113- target_include_directories (tests PRIVATE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} )
114120 cppgraphqlgen_target_set_cxx_standard(tests)
115121
116122 add_test (NAME TodayServiceCase
@@ -126,9 +132,9 @@ if(BUILD_TESTS OR UPDATE_SAMPLES)
126132
127133 if (UPDATE_SAMPLES)
128134 install (FILES
129- ${CMAKE_BINARY_DIR} /graphqlservice/IntrospectionSchema.h
130- ${CMAKE_BINARY_DIR} /graphqlservice/ IntrospectionSchema.cpp
131- ${CMAKE_BINARY_DIR} /TodaySchema.h
135+ ${CMAKE_BINARY_DIR} /include / graphqlservice/IntrospectionSchema.h
136+ ${CMAKE_BINARY_DIR} /IntrospectionSchema.cpp
137+ ${CMAKE_BINARY_DIR} /include / TodaySchema.h
132138 ${CMAKE_BINARY_DIR} /TodaySchema.cpp
133139 DESTINATION ${CMAKE_SOURCE_DIR} /samples)
134140 endif ()
@@ -149,9 +155,9 @@ install(FILES
149155 include /graphqlservice/GraphQLTree.h
150156 include /graphqlservice/GraphQLResponse.h
151157 include /graphqlservice/GraphQLService.h
152- include /graphqlservice/Introspection.h
153- ${CMAKE_BINARY_DIR} /graphqlservice/IntrospectionSchema.h
154158 include /graphqlservice/JSONResponse.h
159+ include /graphqlservice/Introspection.h
160+ ${CMAKE_BINARY_DIR} /include /graphqlservice/IntrospectionSchema.h
155161 DESTINATION include /graphqlservice
156162 CONFIGURATIONS Release)
157163
0 commit comments