Skip to content

Commit 4286260

Browse files
committed
Merge changes from master to pegtl
2 parents 75bc67d + e4dbc06 commit 4286260

11 files changed

+390
-394
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ CTestCostData.txt
1919
CTestTestfile.cmake
2020
install_manifest.txt
2121
LastTest.log
22+
lib*.a
2223
lib*.so
2324
Makefile
2425
schemagen

CMakeLists.txt

Lines changed: 74 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,33 @@
22
# Licensed under the MIT License.
33

44
cmake_minimum_required(VERSION 3.5.1)
5-
project(cppgraphql)
5+
project(cppgraphqlgen)
66

77
if(WIN32)
88
# Let CMake figure out the exports for the SHARED library (DLL) on Windows.
99
SET(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
1010
endif()
1111

12-
add_library(graphqlservice SHARED GraphQLService.cpp Introspection.cpp IntrospectionSchema.cpp)
12+
add_library(graphqlservice GraphQLService.cpp Introspection.cpp IntrospectionSchema.cpp)
1313
add_executable(schemagen SchemaGenerator.cpp)
1414

1515
find_library(GRAPHQLPARSER graphqlparser)
1616

17+
find_package(cpprestsdk REQUIRED)
18+
set(CPPRESTSDK cpprestsdk::cpprest)
19+
1720
if(UNIX)
18-
find_library(CPPRESTSDK_LIB cpprest)
19-
elseif(WIN32)
20-
find_package(cpprestsdk REQUIRED)
21-
set(CPPRESTSDK_LIB cpprestsdk::cpprest)
21+
find_library(BOOST_SYSTEM boost_system)
22+
list(APPEND CPPRESTSDK ${BOOST_SYSTEM})
2223
endif()
2324

2425
find_package(pegtl CONFIG REQUIRED)
2526

2627
add_library(graphqlpeg SHARED GraphQLGrammar.cpp)
27-
target_include_directories(graphqlpeg SYSTEM PUBLIC ${CMAKE_PREFIX_PATH}/include ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR})
28+
target_include_directories(graphqlpeg INTERFACE $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}> $<INSTALL_INTERFACE:include>)
2829
target_link_libraries(graphqlpeg taocpp::pegtl ${GRAPHQLPARSER})
2930

30-
target_include_directories(graphqlservice SYSTEM PUBLIC ${CMAKE_PREFIX_PATH}/include ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR})
31+
target_include_directories(graphqlservice INTERFACE $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}> $<INSTALL_INTERFACE:include>)
3132
target_link_libraries(graphqlservice ${CPPRESTSDK_LIB} ${GRAPHQLPARSER} graphqlpeg)
3233
target_link_libraries(schemagen ${CPPRESTSDK_LIB} ${GRAPHQLPARSER} graphqlpeg)
3334

@@ -38,74 +39,85 @@ add_custom_command(
3839
COMMENT "Generating IntrospectionSchema files"
3940
)
4041

41-
add_custom_command(
42-
OUTPUT TodaySchema.cpp TodaySchema.h
43-
COMMAND schemagen ${CMAKE_SOURCE_DIR}/schema.today.graphql Today today
44-
DEPENDS schemagen schema.today.graphql
45-
COMMENT "Generating mock TodaySchema files"
46-
)
47-
48-
add_library(todaygraphql SHARED
49-
TodaySchema.cpp
50-
Today.cpp)
51-
52-
target_link_libraries(todaygraphql
53-
${CPPRESTSDK_LIB}
54-
${GRAPHQLPARSER}
55-
graphqlservice)
56-
target_include_directories(todaygraphql SYSTEM PUBLIC ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR})
57-
58-
add_executable(test_today test_today.cpp)
59-
60-
target_link_libraries(test_today
61-
${CPPRESTSDK_LIB}
62-
${GRAPHQLPARSER}
63-
graphqlservice
64-
todaygraphql)
65-
target_include_directories(test_today SYSTEM PUBLIC ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR})
66-
67-
enable_testing()
68-
add_executable(tests tests.cpp)
69-
find_package(GTest REQUIRED)
70-
target_link_libraries(tests
71-
${CPPRESTSDK_LIB}
72-
${GRAPHQLPARSER}
73-
graphqlservice
74-
graphqlpeg
75-
todaygraphql
76-
GTest::GTest
77-
GTest::Main)
78-
target_include_directories(tests SYSTEM PUBLIC ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR})
79-
add_test(TodayServiceCase tests)
80-
add_test(ArgumentsCase tests)
81-
8242
if(UNIX)
8343
target_compile_options(graphqlservice PRIVATE -std=c++11)
84-
target_compile_options(todaygraphql PRIVATE -std=c++11)
8544
target_compile_options(schemagen PRIVATE -std=c++11)
86-
target_compile_options(test_today PRIVATE -std=c++11)
87-
target_compile_options(tests PRIVATE -std=c++11)
45+
endif()
46+
47+
option(BUILD_TESTS "Build the tests and sample schema library." ON)
48+
option(UPDATE_SAMPLES "Regenerate the sample schema sources whether or not we're building the tests and the sample library." ON)
49+
50+
if(BUILD_TESTS OR UPDATE_SAMPLES)
51+
add_custom_command(
52+
OUTPUT TodaySchema.cpp TodaySchema.h
53+
COMMAND schemagen ${CMAKE_SOURCE_DIR}/schema.today.graphql Today today
54+
DEPENDS schemagen schema.today.graphql
55+
COMMENT "Generating mock TodaySchema files"
56+
)
57+
58+
if(BUILD_TESTS)
59+
add_library(todaygraphql
60+
TodaySchema.cpp
61+
Today.cpp)
62+
63+
target_link_libraries(todaygraphql
64+
${CPPRESTSDK}
65+
${GRAPHQLPARSER}
66+
graphqlservice)
67+
target_include_directories(todaygraphql SYSTEM PUBLIC ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR})
68+
69+
add_executable(test_today test_today.cpp)
70+
71+
target_link_libraries(test_today
72+
${CPPRESTSDK}
73+
${GRAPHQLPARSER}
74+
graphqlservice
75+
todaygraphql)
76+
target_include_directories(test_today SYSTEM PUBLIC ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR})
77+
78+
enable_testing()
79+
add_executable(tests tests.cpp)
80+
find_package(GTest REQUIRED)
81+
target_link_libraries(tests
82+
${CPPRESTSDK}
83+
${GRAPHQLPARSER}
84+
graphqlpeg
85+
graphqlservice
86+
todaygraphql
87+
GTest::GTest
88+
GTest::Main)
89+
target_include_directories(tests SYSTEM PUBLIC ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR})
90+
add_test(TodayServiceCase tests)
91+
add_test(ArgumentsCase tests)
92+
93+
if(UNIX)
94+
target_compile_options(todaygraphql PRIVATE -std=c++11)
95+
target_compile_options(test_today PRIVATE -std=c++11)
96+
target_compile_options(tests PRIVATE -std=c++11)
97+
endif()
98+
endif()
99+
100+
if(UPDATE_SAMPLES)
101+
install(FILES IntrospectionSchema.h IntrospectionSchema.cpp TodaySchema.h TodaySchema.cpp
102+
DESTINATION ${CMAKE_SOURCE_DIR}/samples)
103+
endif()
88104
endif()
89105

90106
install(TARGETS graphqlservice schemagen
107+
EXPORT cppgraphqlgen-config
91108
RUNTIME DESTINATION bin
109+
ARCHIVE DESTINATION lib
92110
LIBRARY DESTINATION lib)
93111

94112
install(FILES GraphQLService.h Introspection.h IntrospectionSchema.h
95113
DESTINATION include/graphqlservice)
96114

97-
install(FILES IntrospectionSchema.h IntrospectionSchema.cpp TodaySchema.h TodaySchema.cpp
98-
DESTINATION ${CMAKE_SOURCE_DIR}/samples)
99-
100115
if(WIN32)
101116
set(GRAPHQLSERVICE_DIR $<TARGET_FILE_DIR:graphqlservice>)
102117
install(FILES ${GRAPHQLSERVICE_DIR}/graphqlservice.lib
103118
DESTINATION lib)
104-
105-
option(INSTALL_WINDOWS_DLLS "Copy all Windows DLLs as part of the install to get dependencies." OFF)
106-
107-
if(INSTALL_WINDOWS_DLLS)
108-
install(CODE "include(${CMAKE_SOURCE_DIR}/copy-windows-dlls.cmake)"
109-
CODE "copy_windows_dlls(${CMAKE_BINARY_DIR})")
110-
endif()
111119
endif()
120+
121+
install(EXPORT cppgraphqlgen-config
122+
NAMESPACE cppgraphqlgen::
123+
DESTINATION lib/cppgraphqlgen)

0 commit comments

Comments
 (0)