@@ -35,7 +35,8 @@ add_executable(schemagen
3535 GraphQLResponse.cpp
3636 SchemaGenerator.cpp)
3737target_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 )
3940cppgraphqlgen_target_set_cxx_standard(schemagen)
4041
4142add_custom_command (
@@ -56,15 +57,10 @@ add_library(graphqlservice
5657 IntrospectionSchema.cpp)
5758target_link_libraries (graphqlservice PRIVATE taocpp::pegtl)
5859target_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 >
6363 $<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 )
6864cppgraphqlgen_target_set_cxx_standard(graphqlservice)
6965
7066option (BUILD_TESTS "Build the tests and sample schema library." ON )
@@ -75,15 +71,15 @@ if(BUILD_TESTS OR UPDATE_SAMPLES)
7571 OUTPUT
7672 TodaySchema.cpp
7773 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
7975 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
8177 COMMENT "Generating mock TodaySchema files"
8278 )
8379
8480 # force the generation of samples on the default build target
8581 add_custom_target (update_samples ALL
86- DEPENDS ${CMAKE_BINARY_DIR} / TodaySchema.cpp
82+ DEPENDS TodaySchema.cpp
8783 )
8884
8985 if (BUILD_TESTS)
@@ -95,11 +91,11 @@ if(BUILD_TESTS OR UPDATE_SAMPLES)
9591 JSONResponse.cpp)
9692 target_link_libraries (todaygraphql PUBLIC
9793 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 )
10399 cppgraphqlgen_target_set_cxx_standard(todaygraphql)
104100
105101 add_executable (test_today
@@ -132,11 +128,11 @@ if(BUILD_TESTS OR UPDATE_SAMPLES)
132128
133129 if (UPDATE_SAMPLES)
134130 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)
140136 endif ()
141137endif ()
142138
@@ -146,9 +142,12 @@ install(TARGETS graphqlservice
146142 ARCHIVE DESTINATION lib
147143 LIBRARY DESTINATION lib)
148144
145+ set (CMAKE_INSTALL_TOOLSDIR tools/${PROJECT_NAME}
146+ CACHE PATH "Install schemagen to this directory." )
147+
149148install (TARGETS schemagen
150149 EXPORT cppgraphqlgen-targets
151- RUNTIME DESTINATION tools/cppgraphqlgen
150+ RUNTIME DESTINATION ${CMAKE_INSTALL_TOOLSDIR}
152151 CONFIGURATIONS Release)
153152
154153install (FILES
@@ -157,11 +156,13 @@ install(FILES
157156 include /graphqlservice/GraphQLService.h
158157 include /graphqlservice/JSONResponse.h
159158 include /graphqlservice/Introspection.h
160- ${CMAKE_BINARY_DIR } /include /graphqlservice/IntrospectionSchema.h
159+ ${CMAKE_CURRENT_BINARY_DIR } /include /graphqlservice/IntrospectionSchema.h
161160 DESTINATION include /graphqlservice
162161 CONFIGURATIONS Release)
163162
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+
165166install (FILES cmake/${PROJECT_NAME} -config.cmake
166167 DESTINATION ${CMAKE_INSTALL_CONFIGDIR}
167168)
0 commit comments