-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
223 lines (210 loc) · 7.13 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# successful cmake file
cmake_minimum_required(VERSION 3.27)
set(CMAKE_CXX_COMPILER "cl.exe")
project(snakeRebuild)
# Set the C++ standard
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_CXX_SCAN_FOR_MODULES NO)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D module_bug /std:c++latest")
# Enable module compilation
add_compile_definitions(CMAKE_CXX_COMPILE_FEATURES="cxx_std_23")
# add modules as library
add_library(std)
target_sources(std
PUBLIC
FILE_SET cxx_modules TYPE CXX_MODULES FILES
module/std.ixx
)
set_property(TARGET std PROPERTY CXX_MODULES TRUE)
add_library(std.compat
module/std.ixx module/std.compat.ixx)
add_library(ancillarycat.api.ansi
src/ancillarycat.api.ansi.ixx)
add_library(ancillarycat.api.windows
src/ancillarycat.api.windows.ixx)
add_library(ancillarycat.api.generator
src/ancillarycat.api.generator.ixx)
add_library(ancillarycat.api
module/ancillarycat.api.ixx)
target_link_libraries(ancillarycat.api
PUBLIC
ancillarycat.api.ansi
ancillarycat.api.generator
ancillarycat.api.windows
)
# order matters!
add_library(ancillarycat.console.console
src/ancillarycat.console.console.cpp
module/ancillarycat.console.console.ixx)
add_library(ancillarycat.console.point
src/ancillarycat.console.point.ixx)
add_library(ancillarycat.console
module/ancillarycat.console.ixx)
target_link_libraries(ancillarycat.console
PUBLIC
ancillarycat.console.point
ancillarycat.console.console
)
add_library(ancillarycat.entities.entity
src/ancillarycat.entities.entity.cpp
module/ancillarycat.entities.entity.ixx)
add_library(ancillarycat.entities.snake
module/ancillarycat.entities.snake.ixx)
add_library(ancillarycat.entities.food
module/ancillarycat.entities.food.ixx)
add_library(ancillarycat.entities
module/ancillarycat.entities.ixx)
target_link_libraries(ancillarycat.entities
PUBLIC
ancillarycat.entities.entity
ancillarycat.entities.snake
ancillarycat.entities.food
)
add_library(ancillarycat.utils
src/ancillarycat.utils.cpp
module/ancillarycat.utils.ixx)
add_library(ancillarycat.game.game
src/ancillarycat.game.game.ixx)
add_library(ancillarycat.game.leaderboard
src/ancillarycat.game.leaderboard.ixx)
add_library(ancillarycat.game.config
src/ancillarycat.game.config.ixx)
add_library(ancillarycat.game
module/ancillarycat.game.ixx)
target_link_libraries(ancillarycat.game
PUBLIC
ancillarycat.game.game
ancillarycat.game.leaderboard
ancillarycat.game.config
)
add_library(ancillarycat.handler
src/ancillarycat.handler.cpp
module/ancillarycat.handler.ixx)
add_library(ancillarycat.blocks.block
module/ancillarycat.blocks.block.ixx)
add_library(ancillarycat.blocks.obstacle
module/ancillarycat.blocks.obstacle.ixx)
add_library(ancillarycat.blocks
module/ancillarycat.blocks.ixx)
target_link_libraries(ancillarycat.blocks
PUBLIC
ancillarycat.blocks.block
ancillarycat.blocks.obstacle
)
add_executable(snakeRebuild
src/realMain.cpp
snakeRebuild.cpp)
# appear earlier, linked later
target_link_libraries(
snakeRebuild
PRIVATE
ancillarycat.handler
ancillarycat.game
ancillarycat.utils
ancillarycat.blocks
ancillarycat.entities
ancillarycat.console
ancillarycat.api
std.compat
std
)
# another method
# not working!
#function(build_all_modules)
# foreach (module ${ARGN})
# if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/module/${module}.ixx)
# if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/${module}.cpp)
# add_library(${module}
# src/${module}.cpp
# module/${module}.ixx
# )
# else ()
# add_library(${module} module/${module}.ixx)
# endif ()
# elseif (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/${module}.ixx)
# if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/${module}.cpp)
# add_library(${module}
# src/${module}.cpp
# src/${module}.ixx
# )
# else ()
# add_library(${module} src/${module}.ixx)
# endif ()
# else ()
# message(FATAL_ERROR "No source file found for module ${module}")
# endif ()
# endforeach ()
#endfunction()
#
#build_all_modules(
# std
# std.compat
#
# ancillarycat.api.ansi
# ancillarycat.api.windows
# ancillarycat.api.generator
# ancillarycat.api
#
# ancillarycat.console
#
# ancillarycat.entities.entity
# ancillarycat.entities.snake
# ancillarycat.entities.food
# ancillarycat.entities
#
# ancillarycat.utils
#
# ancillarycat.game.game
# ancillarycat.game.leaderboard
# ancillarycat.game.config
# ancillarycat.game
#
# ancillarycat.handler
#
# ancillarycat.blocks.obstacle
# ancillarycat.blocks
#)
#function(build_all_modules)
# foreach (interface_module ${ARGN})
# # Find submodule partitions in module directory
# file(GLOB_RECURSE submodule_partitions_module "${CMAKE_CURRENT_SOURCE_DIR}/module/${interface_module}.*.*.cpp")
#
# # Find submodule partitions in src directory
# file(GLOB_RECURSE submodule_partitions_src "${CMAKE_CURRENT_SOURCE_DIR}/src/${interface_module}.*.*.cpp")
#
# # Combine results from both directories
# set(submodule_partitions ${submodule_partitions_module} ${submodule_partitions_src})
#
# message(STATUS "Submodule partitions for ${interface_module}: ${submodule_partitions}")
#
# foreach(submodule_partition ${submodule_partitions})
# message(STATUS "Processing submodule partition: ${submodule_partition}")
# get_filename_component(submodule_name ${submodule_partition} NAME_WE)
# # Extract interface module name
# string(REGEX REPLACE "\\..*$" "" interface_module_name ${interface_module})
# # Add submodule partition
# add_library(${submodule_partition} ${submodule_partition} module/${interface_module_name}.ixx)
# target_link_libraries(${interface_module} PUBLIC ${submodule_partition})
# endforeach()
#
# # Check if the interface module exists
# if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/module/${interface_module}.ixx")
# add_library(${interface_module} module/${interface_module}.ixx)
# elseif (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/${interface_module}.ixx")
# add_library(${interface_module} src/${interface_module}.ixx)
# else ()
# message(FATAL_ERROR "No source file found for interface module ${interface_module}")
# endif ()
# endforeach()
#endfunction()
#
#build_all_modules(
# ancillarycat.api
# ancillarycat.console
# ancillarycat.entities
# ancillarycat.utils
# ancillarycat.game
# ancillarycat.handler
# ancillarycat.blocks
#)