Skip to content

Commit 05a4c63

Browse files
committed
move public headers to graphqlservice/ directory
This is where the file are installed. This means the files generated by schemagen should also specify this directory.
1 parent faddbd0 commit 05a4c63

20 files changed

+80
-44
lines changed

CMakeLists.txt

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,25 @@ endif()
1111

1212
find_package(Threads MODULE REQUIRED)
1313

14+
include(CMakePackageConfigHelpers)
15+
1416
find_package(pegtl CONFIG REQUIRED)
1517

1618
add_executable(schemagen
1719
GraphQLTree.cpp
1820
GraphQLResponse.cpp
1921
SchemaGenerator.cpp)
2022
target_link_libraries(schemagen PRIVATE taocpp::pegtl)
21-
target_include_directories(schemagen PRIVATE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
23+
target_include_directories(schemagen PRIVATE ${CMAKE_SOURCE_DIR}/include ${CMAKE_BINARY_DIR})
2224
set_property(TARGET schemagen PROPERTY CXX_STANDARD 11)
2325

2426
add_custom_command(
25-
OUTPUT IntrospectionSchema.cpp IntrospectionSchema.h
27+
OUTPUT
28+
graphqlservice/IntrospectionSchema.cpp
29+
graphqlservice/IntrospectionSchema.h
2630
COMMAND schemagen
31+
COMMAND ${CMAKE_COMMAND} -E rename IntrospectionSchema.cpp graphqlservice/IntrospectionSchema.cpp
32+
COMMAND ${CMAKE_COMMAND} -E rename IntrospectionSchema.h graphqlservice/IntrospectionSchema.h
2733
DEPENDS schemagen
2834
COMMENT "Generating IntrospectionSchema files"
2935
)
@@ -33,11 +39,15 @@ add_library(graphqlservice
3339
GraphQLResponse.cpp
3440
GraphQLService.cpp
3541
Introspection.cpp
36-
IntrospectionSchema.cpp)
42+
${CMAKE_BINARY_DIR}/graphqlservice/IntrospectionSchema.cpp)
3743
target_link_libraries(graphqlservice PRIVATE taocpp::pegtl)
3844
target_link_libraries(graphqlservice PUBLIC ${CMAKE_THREAD_LIBS_INIT})
39-
target_include_directories(graphqlservice SYSTEM INTERFACE $<INSTALL_INTERFACE:include>)
40-
target_include_directories(graphqlservice PRIVATE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
45+
target_include_directories(graphqlservice
46+
PUBLIC
47+
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
48+
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}>
49+
$<INSTALL_INTERFACE:include>
50+
)
4151
set_property(TARGET graphqlservice PROPERTY CXX_STANDARD 11)
4252

4353
option(BUILD_TESTS "Build the tests and sample schema library." ON)
@@ -61,8 +71,8 @@ if(BUILD_TESTS OR UPDATE_SAMPLES)
6171

6272
add_library(todaygraphql
6373
${CMAKE_BINARY_DIR}/TodaySchema.cpp
64-
Today.cpp
65-
JSONResponse.cpp)
74+
Today.cpp
75+
JSONResponse.cpp)
6676
target_link_libraries(todaygraphql PUBLIC
6777
graphqlservice)
6878
target_include_directories(todaygraphql SYSTEM PUBLIC ${RAPIDJSON_INCLUDE_DIRS})
@@ -101,34 +111,41 @@ if(BUILD_TESTS OR UPDATE_SAMPLES)
101111

102112
if(UPDATE_SAMPLES)
103113
install(FILES
104-
${CMAKE_BINARY_DIR}/IntrospectionSchema.h
105-
${CMAKE_BINARY_DIR}/IntrospectionSchema.cpp
114+
${CMAKE_BINARY_DIR}/graphqlservice/IntrospectionSchema.h
115+
${CMAKE_BINARY_DIR}/graphqlservice/IntrospectionSchema.cpp
106116
${CMAKE_BINARY_DIR}/TodaySchema.h
107117
${CMAKE_BINARY_DIR}/TodaySchema.cpp
108118
DESTINATION ${CMAKE_SOURCE_DIR}/samples)
109119
endif()
110120
endif()
111121

112122
install(TARGETS graphqlservice
113-
EXPORT cppgraphqlgen-config
123+
EXPORT cppgraphqlgen-targets
114124
RUNTIME DESTINATION bin
115125
ARCHIVE DESTINATION lib
116126
LIBRARY DESTINATION lib)
117127

118128
install(TARGETS schemagen
129+
EXPORT cppgraphqlgen-targets
119130
RUNTIME DESTINATION tools/cppgraphqlgen
120131
CONFIGURATIONS Release)
121132

122133
install(FILES
123-
GraphQLTree.h
124-
GraphQLResponse.h
125-
GraphQLService.h
126-
Introspection.h
127-
${CMAKE_BINARY_DIR}/IntrospectionSchema.h
128-
JSONResponse.h
134+
include/graphqlservice/GraphQLTree.h
135+
include/graphqlservice/GraphQLResponse.h
136+
include/graphqlservice/GraphQLService.h
137+
include/graphqlservice/Introspection.h
138+
${CMAKE_BINARY_DIR}/graphqlservice/IntrospectionSchema.h
139+
include/graphqlservice/JSONResponse.h
129140
DESTINATION include/graphqlservice
130141
CONFIGURATIONS Release)
131142

132-
install(EXPORT cppgraphqlgen-config
143+
set(CMAKE_INSTALL_CONFIGDIR lib/cmake/${PROJECT_NAME})
144+
install(FILES cmake/${PROJECT_NAME}-config.cmake
145+
DESTINATION ${CMAKE_INSTALL_CONFIGDIR}
146+
)
147+
148+
install(EXPORT cppgraphqlgen-targets
133149
NAMESPACE cppgraphqlgen::
134-
DESTINATION share/cppgraphqlgen)
150+
DESTINATION ${CMAKE_INSTALL_CONFIGDIR}
151+
)

GraphQLResponse.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
#include "GraphQLResponse.h"
4+
#include "graphqlservice/GraphQLResponse.h"
55

66
#include <stdexcept>
77

@@ -466,4 +466,4 @@ ScalarType Value::release<ScalarType>()
466466

467467
} /* namespace response */
468468
} /* namespace graphql */
469-
} /* namespace facebook */
469+
} /* namespace facebook */

GraphQLService.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
#include "GraphQLService.h"
4+
#include "graphqlservice/GraphQLService.h"
55
#include "GraphQLGrammar.h"
66

77
#include <iostream>
@@ -1066,4 +1066,4 @@ void OperationDefinitionVisitor::visit(const peg::ast_node& operationDefinition)
10661066

10671067
} /* namespace service */
10681068
} /* namespace graphql */
1069-
} /* namespace facebook */
1069+
} /* namespace facebook */

GraphQLTree.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
#include "GraphQLTree.h"
4+
#include "graphqlservice/GraphQLTree.h"
55
#include "GraphQLGrammar.h"
66

77
#include <tao/pegtl/contrib/unescape.hpp>
@@ -597,4 +597,4 @@ std::unique_ptr<peg::ast<const char*>> operator "" _graphql(const char* text, si
597597
}
598598

599599
} /* namespace graphql */
600-
} /* namespace facebook */
600+
} /* namespace facebook */

Introspection.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
#include "Introspection.h"
4+
#include "graphqlservice/Introspection.h"
55

66
namespace facebook {
77
namespace graphql {
@@ -652,4 +652,4 @@ std::future<std::unique_ptr<std::string>> EnumValue::getDeprecationReason(servic
652652

653653
} /* namespace facebook */
654654
} /* namespace graphql */
655-
} /* namespace introspection */
655+
} /* namespace introspection */

JSONResponse.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
#include "JSONResponse.h"
4+
#include "graphqlservice/JSONResponse.h"
55

66
namespace facebook {
77
namespace graphql {

SchemaGenerator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,7 @@ bool Generator::outputHeader() const noexcept
11681168
#include <string>
11691169
#include <vector>
11701170
1171-
#include "GraphQLService.h"
1171+
#include <graphqlservice/GraphQLService.h>
11721172
11731173
namespace facebook {
11741174
namespace graphql {
@@ -1497,7 +1497,7 @@ bool Generator::outputSource() const noexcept
14971497
// Licensed under the MIT License.
14981498
14991499
#include ")cpp" << _filenamePrefix << R"cpp(Schema.h"
1500-
#include "Introspection.h"
1500+
#include <graphqlservice/Introspection.h>
15011501
15021502
#include <algorithm>
15031503
#include <functional>

SchemaGenerator.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <array>
77
#include <cstdio>
88

9-
#include "GraphQLService.h"
9+
#include "graphqlservice/GraphQLService.h"
1010

1111
namespace facebook {
1212
namespace graphql {
@@ -301,4 +301,4 @@ class Generator
301301

302302
} /* namespace schema */
303303
} /* namespace graphql */
304-
} /* namespace facebook */
304+
} /* namespace facebook */

cmake/cppgraphqlgen-config.cmake

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
4+
#[=======================================================================[.rst:
5+
cppgraphqlgen
6+
-------------
7+
8+
The following import targets are created
9+
10+
::
11+
12+
cppgraphqlgen::graphqlservice
13+
cppgraphqlgen::schemagen
14+
#]=======================================================================]
15+
16+
include(CMakeFindDependencyMacro)
17+
find_package(pegtl REQUIRED)
18+
include("${CMAKE_CURRENT_LIST_DIR}/cppgraphqlgen-targets.cmake")
File renamed without changes.

0 commit comments

Comments
 (0)