generated from Game-as-a-Service/Gaas-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
159 lines (133 loc) · 3.73 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
cmake_minimum_required(VERSION 3.16)
project(MachiKoroCPP
VERSION 0.0.1
LANGUAGES CXX
)
# ---------------------------------------------------------------------------------------
# Set project options.
# ---------------------------------------------------------------------------------------
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif ()
message(STATUS "Started CMake for ${PROJECT_NAME} v${PROJECT_VERSION}...")
message(STATUS "Build Type: ${CMAKE_BUILD_TYPE}. \n")
# ---------------------------------------------------------------------------------------
# Package dependency.
# ---------------------------------------------------------------------------------------
find_package(Drogon CONFIG REQUIRED)
find_package(GTest)
if (NOT GTest_FOUND)
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.14.0
)
FetchContent_MakeAvailable(googletest)
endif (NOT GTest_FOUND)
# ---------------------------------------------------------------------------------------
# Headers & Sources.
# ---------------------------------------------------------------------------------------
include(cmake/sources.cmake)
# Model Library
add_library(Model SHARED "")
target_sources(Model
PRIVATE
${MODEL_SOURCES}
${MODEL_HEADERS}
)
target_include_directories(Model
PRIVATE
${CMAKE_SOURCE_DIR}/models
)
# Controller2Usecase Library
add_library(Controller2Usecase SHARED "")
target_sources(Controller2Usecase
PRIVATE
${CONTROLLER_SOURCES}
${CONTROLLER_HEADERS}
${LOGGER_SOURCES}
${LOGGER_HEADERS}
${REPO_SOURCES}
${REPO_HEADERS}
${UTIL_SOURCES}
${UTIL_HEADERS}
${PRESENTER_SOURCES}
${PRESENTER_HEADERS}
${USECASE_SOURCES}
${USECASE_HEADERS}
)
target_include_directories(Controller2Usecase
PRIVATE
${CMAKE_SOURCE_DIR}/controllers
${CMAKE_SOURCE_DIR}/loggers
${CMAKE_SOURCE_DIR}/repos
${CMAKE_SOURCE_DIR}/utils
${CMAKE_SOURCE_DIR}/presenters
${CMAKE_SOURCE_DIR}/usecases
)
target_link_libraries(Controller2Usecase
PRIVATE
Model
PUBLIC
Drogon::Drogon
)
# app
add_executable(${PROJECT_NAME}_app main.cpp)
target_link_libraries(${PROJECT_NAME}_app
PRIVATE
Controller2Usecase
)
# drogon_create_views(${PROJECT_NAME}
# ${CMAKE_CURRENT_SOURCE_DIR}/views
# ${CMAKE_CURRENT_BINARY_DIR}
# )
# ---------------------------------------------------------------------------------------
# Clang-format.
# ---------------------------------------------------------------------------------------
include(cmake/clang-format.cmake)
# ---------------------------------------------------------------------------------------
# E2E Test & Unit Test.
# ---------------------------------------------------------------------------------------
enable_testing()
# E2E Test
add_executable(${PROJECT_NAME}_e2e
${E2E_SOURCES}
)
target_include_directories(${PROJECT_NAME}_e2e
PRIVATE
${CMAKE_SOURCE_DIR}/usecases
${CMAKE_SOURCE_DIR}/models
${CMAKE_SOURCE_DIR}/tests/mock_objects
)
target_link_libraries(${PROJECT_NAME}_e2e
PRIVATE
GTest::gtest
GTest::gtest_main
GTest::gmock
GTest::gmock_main
pthread
Model
Controller2Usecase
)
# Unit Test
add_executable(${PROJECT_NAME}_unit
${UNIT_SOURCES}
)
target_link_libraries(${PROJECT_NAME}_unit
PRIVATE
GTest::gtest
GTest::gtest_main
pthread
Model
Controller2Usecase
)
# Discover
include(GoogleTest)
gtest_discover_tests(${PROJECT_NAME}_e2e)
gtest_discover_tests(${PROJECT_NAME}_unit)