2
2
# Licensed under the MIT License.
3
3
4
4
cmake_minimum_required (VERSION 3.5.1 )
5
- project (cppgraphql )
5
+ project (cppgraphqlgen )
6
6
7
7
if (WIN32 )
8
8
# Let CMake figure out the exports for the SHARED library (DLL) on Windows.
@@ -14,16 +14,17 @@ add_executable(schemagen SchemaGenerator.cpp)
14
14
15
15
find_library (GRAPHQLPARSER graphqlparser )
16
16
17
+ find_package (cpprestsdk REQUIRED )
18
+ set (CPPRESTSDK cpprestsdk::cpprest )
19
+
17
20
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} )
22
23
endif ()
23
24
24
- target_include_directories (graphqlservice SYSTEM PUBLIC ${CMAKE_PREFIX_PATH} /include ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} )
25
- target_link_libraries (graphqlservice ${CPPRESTSDK_LIB } ${GRAPHQLPARSER} )
26
- target_link_libraries (schemagen ${CPPRESTSDK_LIB } ${GRAPHQLPARSER} )
25
+ target_include_directories (graphqlservice INTERFACE $< BUILD_INTERFACE: ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} > $< INSTALL_INTERFACE:include > )
26
+ target_link_libraries (graphqlservice ${CPPRESTSDK } ${GRAPHQLPARSER} )
27
+ target_link_libraries (schemagen ${CPPRESTSDK } ${GRAPHQLPARSER} )
27
28
28
29
add_custom_command (
29
30
OUTPUT IntrospectionSchema.cpp IntrospectionSchema.h
@@ -32,73 +33,83 @@ add_custom_command(
32
33
COMMENT "Generating IntrospectionSchema files"
33
34
)
34
35
35
- add_custom_command (
36
- OUTPUT TodaySchema.cpp TodaySchema.h
37
- COMMAND schemagen ${CMAKE_SOURCE_DIR} /schema.today.graphql Today today
38
- DEPENDS schemagen schema.today.graphql
39
- COMMENT "Generating mock TodaySchema files"
40
- )
41
-
42
- add_library (todaygraphql SHARED
43
- TodaySchema.cpp
44
- Today.cpp )
45
-
46
- target_link_libraries (todaygraphql
47
- ${CPPRESTSDK_LIB}
48
- ${GRAPHQLPARSER}
49
- graphqlservice )
50
- target_include_directories (todaygraphql SYSTEM PUBLIC ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} )
51
-
52
- add_executable (test_today test_today.cpp )
53
-
54
- target_link_libraries (test_today
55
- ${CPPRESTSDK_LIB}
56
- ${GRAPHQLPARSER}
57
- graphqlservice
58
- todaygraphql )
59
- target_include_directories (test_today SYSTEM PUBLIC ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} )
60
-
61
- enable_testing ()
62
- add_executable (tests tests.cpp )
63
- find_package (GTest REQUIRED )
64
- target_link_libraries (tests
65
- ${CPPRESTSDK_LIB}
66
- ${GRAPHQLPARSER}
67
- graphqlservice
68
- todaygraphql
69
- GTest::GTest
70
- GTest::Main )
71
- target_include_directories (tests SYSTEM PUBLIC ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} )
72
- add_test (TodayServiceCase tests )
73
- add_test (ArgumentsCase tests )
74
-
75
36
if (UNIX )
76
37
target_compile_options (graphqlservice PRIVATE -std=c++11 )
77
- target_compile_options (todaygraphql PRIVATE -std=c++11 )
78
38
target_compile_options (schemagen PRIVATE -std=c++11 )
79
- target_compile_options (test_today PRIVATE -std=c++11 )
80
- target_compile_options (tests PRIVATE -std=c++11 )
39
+ endif ()
40
+
41
+ option (BUILD_TESTS "Build the tests and sample schema library." ON )
42
+ option (UPDATE_SAMPLES "Regenerate the sample schema sources whether or not we're building the tests and the sample library." ON )
43
+
44
+ if (BUILD_TESTS OR UPDATE_SAMPLES )
45
+ add_custom_command (
46
+ OUTPUT TodaySchema.cpp TodaySchema.h
47
+ COMMAND schemagen ${CMAKE_SOURCE_DIR} /schema.today.graphql Today today
48
+ DEPENDS schemagen schema.today.graphql
49
+ COMMENT "Generating mock TodaySchema files"
50
+ )
51
+
52
+ if (BUILD_TESTS )
53
+ add_library (todaygraphql SHARED
54
+ TodaySchema.cpp
55
+ Today.cpp )
56
+
57
+ target_link_libraries (todaygraphql
58
+ ${CPPRESTSDK}
59
+ ${GRAPHQLPARSER}
60
+ graphqlservice )
61
+ target_include_directories (todaygraphql SYSTEM PUBLIC ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} )
62
+
63
+ add_executable (test_today test_today.cpp )
64
+
65
+ target_link_libraries (test_today
66
+ ${CPPRESTSDK}
67
+ ${GRAPHQLPARSER}
68
+ graphqlservice
69
+ todaygraphql )
70
+ target_include_directories (test_today SYSTEM PUBLIC ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} )
71
+
72
+ enable_testing ()
73
+ add_executable (tests tests.cpp )
74
+ find_package (GTest REQUIRED )
75
+ target_link_libraries (tests
76
+ ${CPPRESTSDK}
77
+ ${GRAPHQLPARSER}
78
+ graphqlservice
79
+ todaygraphql
80
+ GTest::GTest
81
+ GTest::Main )
82
+ target_include_directories (tests SYSTEM PUBLIC ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} )
83
+ add_test (TodayServiceCase tests )
84
+ add_test (ArgumentsCase tests )
85
+
86
+ if (UNIX )
87
+ target_compile_options (todaygraphql PRIVATE -std=c++11 )
88
+ target_compile_options (test_today PRIVATE -std=c++11 )
89
+ target_compile_options (tests PRIVATE -std=c++11 )
90
+ endif ()
91
+ endif ()
92
+
93
+ if (UPDATE_SAMPLES )
94
+ install (FILES IntrospectionSchema.h IntrospectionSchema.cpp TodaySchema.h TodaySchema.cpp
95
+ DESTINATION ${CMAKE_SOURCE_DIR} /samples )
96
+ endif ()
81
97
endif ()
82
98
83
99
install (TARGETS graphqlservice schemagen
100
+ EXPORT cppgraphqlgen-config
84
101
RUNTIME DESTINATION bin
85
102
LIBRARY DESTINATION lib )
86
103
87
104
install (FILES GraphQLService.h Introspection.h IntrospectionSchema.h
88
105
DESTINATION include /graphqlservice )
89
106
90
- install (FILES IntrospectionSchema.h IntrospectionSchema.cpp TodaySchema.h TodaySchema.cpp
91
- DESTINATION ${CMAKE_SOURCE_DIR} /samples )
92
-
93
107
if (WIN32 )
94
108
set (GRAPHQLSERVICE_DIR $< TARGET_FILE_DIR:graphqlservice> )
95
109
install (FILES ${GRAPHQLSERVICE_DIR} /graphqlservice.lib
96
110
DESTINATION lib )
97
-
98
- option (INSTALL_WINDOWS_DLLS "Copy all Windows DLLs as part of the install to get dependencies." OFF )
99
-
100
- if (INSTALL_WINDOWS_DLLS )
101
- install (CODE "include(${CMAKE_SOURCE_DIR} /copy-windows-dlls.cmake)"
102
- CODE "copy_windows_dlls(${CMAKE_BINARY_DIR} )" )
103
- endif ()
104
111
endif ()
112
+
113
+ install (EXPORT cppgraphqlgen-config
114
+ NAMESPACE cppgraphqlgen::
115
+ DESTINATION lib/cppgraphqlgen )
0 commit comments