@@ -35,7 +35,8 @@ add_executable(schemagen
35
35
GraphQLResponse.cpp
36
36
SchemaGenerator.cpp )
37
37
target_link_libraries (schemagen PRIVATE taocpp::pegtl )
38
- target_include_directories (schemagen PRIVATE ${CMAKE_SOURCE_DIR} /include ${CMAKE_BINARY_DIR} )
38
+ target_include_directories (schemagen PRIVATE
39
+ ${CMAKE_CURRENT_SOURCE_DIR} /include )
39
40
cppgraphqlgen_target_set_cxx_standard (schemagen )
40
41
41
42
add_custom_command (
@@ -56,15 +57,10 @@ add_library(graphqlservice
56
57
IntrospectionSchema.cpp )
57
58
target_link_libraries (graphqlservice PRIVATE taocpp::pegtl )
58
59
target_link_libraries (graphqlservice PUBLIC Threads::Threads )
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>
60
+ target_include_directories (graphqlservice PUBLIC
61
+ $< BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /include>
62
+ $< BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR} /include>
63
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 )
68
64
cppgraphqlgen_target_set_cxx_standard (graphqlservice )
69
65
70
66
option (BUILD_TESTS "Build the tests and sample schema library." ON )
@@ -75,15 +71,15 @@ if(BUILD_TESTS OR UPDATE_SAMPLES)
75
71
OUTPUT
76
72
TodaySchema.cpp
77
73
include /TodaySchema.h
78
- COMMAND schemagen ${CMAKE_SOURCE_DIR} /schema.today.graphql Today today
74
+ COMMAND schemagen ${CMAKE_CURRENT_SOURCE_DIR} /samples /schema.today.graphql Today today
79
75
COMMAND ${CMAKE_COMMAND} -E rename TodaySchema.h include /TodaySchema.h
80
- DEPENDS schemagen schema.today.graphql
76
+ DEPENDS schemagen ${CMAKE_CURRENT_SOURCE_DIR} /samples/ schema.today.graphql
81
77
COMMENT "Generating mock TodaySchema files"
82
78
)
83
79
84
80
# force the generation of samples on the default build target
85
81
add_custom_target (update_samples ALL
86
- DEPENDS ${CMAKE_BINARY_DIR} / TodaySchema.cpp
82
+ DEPENDS TodaySchema.cpp
87
83
)
88
84
89
85
if (BUILD_TESTS )
@@ -95,11 +91,11 @@ if(BUILD_TESTS OR UPDATE_SAMPLES)
95
91
JSONResponse.cpp )
96
92
target_link_libraries (todaygraphql PUBLIC
97
93
graphqlservice )
98
- target_include_directories (todaygraphql SYSTEM PUBLIC ${RAPIDJSON_INCLUDE_DIRS} )
99
- target_include_directories ( todaygraphql
100
- PUBLIC
101
- ${CMAKE_SOURCE_DIR }/include
102
- ${CMAKE_BINARY_DIR }/include )
94
+ target_include_directories (todaygraphql SYSTEM PUBLIC
95
+ ${RAPIDJSON_INCLUDE_DIRS} )
96
+ target_include_directories ( todaygraphql PUBLIC
97
+ ${CMAKE_CURRENT_SOURCE_DIR }/include
98
+ ${CMAKE_CURRENT_BINARY_DIR }/include )
103
99
cppgraphqlgen_target_set_cxx_standard (todaygraphql )
104
100
105
101
add_executable (test_today
@@ -132,11 +128,11 @@ if(BUILD_TESTS OR UPDATE_SAMPLES)
132
128
133
129
if (UPDATE_SAMPLES )
134
130
install (FILES
135
- ${CMAKE_BINARY_DIR } /include/graphqlservice/IntrospectionSchema.h
136
- ${CMAKE_BINARY_DIR } /IntrospectionSchema.cpp
137
- ${CMAKE_BINARY_DIR } /include/TodaySchema.h
138
- ${CMAKE_BINARY_DIR } /TodaySchema.cpp
139
- DESTINATION ${CMAKE_SOURCE_DIR } /samples )
131
+ ${CMAKE_CURRENT_BINARY_DIR } /include/graphqlservice/IntrospectionSchema.h
132
+ ${CMAKE_CURRENT_BINARY_DIR } /IntrospectionSchema.cpp
133
+ ${CMAKE_CURRENT_BINARY_DIR } /include/TodaySchema.h
134
+ ${CMAKE_CURRENT_BINARY_DIR } /TodaySchema.cpp
135
+ DESTINATION ${CMAKE_CURRENT_SOURCE_DIR } /samples )
140
136
endif ()
141
137
endif ()
142
138
@@ -146,9 +142,12 @@ install(TARGETS graphqlservice
146
142
ARCHIVE DESTINATION lib
147
143
LIBRARY DESTINATION lib )
148
144
145
+ set (CMAKE_INSTALL_TOOLSDIR tools/${PROJECT_NAME}
146
+ CACHE PATH "Install schemagen to this directory." )
147
+
149
148
install (TARGETS schemagen
150
149
EXPORT cppgraphqlgen-targets
151
- RUNTIME DESTINATION tools/cppgraphqlgen
150
+ RUNTIME DESTINATION ${CMAKE_INSTALL_TOOLSDIR}
152
151
CONFIGURATIONS Release )
153
152
154
153
install (FILES
@@ -157,11 +156,13 @@ install(FILES
157
156
include /graphqlservice/GraphQLService.h
158
157
include /graphqlservice/JSONResponse.h
159
158
include /graphqlservice/Introspection.h
160
- ${CMAKE_BINARY_DIR } /include/graphqlservice/IntrospectionSchema.h
159
+ ${CMAKE_CURRENT_BINARY_DIR } /include/graphqlservice/IntrospectionSchema.h
161
160
DESTINATION include /graphqlservice
162
161
CONFIGURATIONS Release )
163
162
164
- set (CMAKE_INSTALL_CONFIGDIR lib/cmake/${PROJECT_NAME} )
163
+ set (CMAKE_INSTALL_CONFIGDIR lib/cmake/${PROJECT_NAME}
164
+ CACHE PATH "Install the CMake config files to this directory." )
165
+
165
166
install (FILES cmake/${PROJECT_NAME}-config.cmake
166
167
DESTINATION ${CMAKE_INSTALL_CONFIGDIR}
167
168
)
0 commit comments