Update: Translations from eints
[openttd-github.git] / src / script / api / CMakeLists.txt
blobf41efd068cb6453f6a80306ca65d5fdfd37f92b6
1 add_library(script_api
2         INTERFACE
5 # Get script_window.hpp dependencies
6 file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/script_window.hpp.in ENUM_LINES REGEX "@enum")
7 foreach(ENUM IN LISTS ENUM_LINES)
8     string(REGEX REPLACE ".* ([^ @]+)@.*" "\\1" FILE_PATTERN "${ENUM}")
9     file(GLOB FILENAMES "${FILE_PATTERN}")
10     list(APPEND DEPENDENCIES ${FILENAMES})
11 endforeach()
12 list(REMOVE_DUPLICATES DEPENDENCIES)
14 # Add a command to generate script_window.hpp
15 add_custom_command_timestamp(OUTPUT ${CMAKE_BINARY_DIR}/generated/script/api/script_window.hpp
16         COMMAND ${CMAKE_COMMAND}
17                 -DGENERATE_SOURCE_FILE=${CMAKE_CURRENT_SOURCE_DIR}/script_window.hpp.in
18                 -DGENERATE_BINARY_FILE=${CMAKE_BINARY_DIR}/generated/script/api/script_window.hpp
19                 -P ${CMAKE_SOURCE_DIR}/cmake/scripts/GenerateWidget.cmake
20         MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/script_window.hpp.in
21         DEPENDS ${CMAKE_SOURCE_DIR}/cmake/scripts/GenerateWidget.cmake ${DEPENDENCIES}
22         WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
23         COMMENT "Generating script_window.hpp"
25 add_custom_target_timestamp(script_window
26         DEPENDS
27         ${CMAKE_BINARY_DIR}/generated/script/api/script_window.hpp
29 target_include_directories(script_api
30         INTERFACE
31         ${CMAKE_BINARY_DIR}/generated/script/api/
32         ${CMAKE_CURRENT_SOURCE_DIR}
35 file(GLOB SCRIPT_API_FILES "script_*.hpp")
36 list(APPEND SCRIPT_API_FILES ${CMAKE_BINARY_DIR}/generated/script/api/script_window.hpp)
38 foreach(API "ai;AI" "game;GS" "template;Template")
39     list(GET API 0 APILC)
40     list(GET API 1 APIUC)
42     foreach(SCRIPT_API_FILE IN LISTS SCRIPT_API_FILES)
43         if("${SCRIPT_API_FILE}" MATCHES ".*script_controller.*")
44             continue()
45         endif()
46         get_filename_component(SCRIPT_API_FILE_NAME "${SCRIPT_API_FILE}" NAME)
47         string(REPLACE "script_" "${APILC}_" SCRIPT_API_FILE_NAME "${SCRIPT_API_FILE_NAME}")
48         set(SCRIPT_API_BINARY_FILE "${CMAKE_BINARY_DIR}/generated/script/api/${APILC}/${SCRIPT_API_FILE_NAME}.sq")
50         add_custom_command_timestamp(OUTPUT ${SCRIPT_API_BINARY_FILE}
51                 COMMAND ${CMAKE_COMMAND}
52                         -DSCRIPT_API_SOURCE_FILE=${CMAKE_CURRENT_SOURCE_DIR}/squirrel_export.hpp.sq.in
53                         -DSCRIPT_API_BINARY_FILE=${SCRIPT_API_BINARY_FILE}
54                         -DSCRIPT_API_FILE=${SCRIPT_API_FILE}
55                         -DAPIUC=${APIUC}
56                         -DAPILC=${APILC}
57                         -P ${CMAKE_SOURCE_DIR}/cmake/scripts/SquirrelExport.cmake
58                 MAIN_DEPENDENCY ${SCRIPT_API_FILE}
59                 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/squirrel_export.hpp.sq.in
60                         ${CMAKE_SOURCE_DIR}/cmake/scripts/SquirrelExport.cmake
61                 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
62                 COMMENT "Generating ${APILC}/${SCRIPT_API_FILE_NAME}.sq"
63         )
64         list(APPEND SCRIPT_${APIUC}_BINARY_FILES ${SCRIPT_API_BINARY_FILE})
65     endforeach()
67     add_custom_target_timestamp(script_${APILC}
68             DEPENDS
69             ${SCRIPT_${APIUC}_BINARY_FILES}
70     )
71     add_dependencies(script_${APILC}
72             script_window
73     )
75     if(NOT "${APILC}" STREQUAL "template")
76         list(APPEND SCRIPT_${APIUC}_BINARY_FILES "${CMAKE_CURRENT_SOURCE_DIR}/${APILC}/${APILC}_controller.hpp.sq")
77         set(INCLUDES_BINARY_FILE "${CMAKE_BINARY_DIR}/generated/script/api/${APILC}/${APILC}_includes.hpp")
78         set(API_FILES "${CMAKE_CURRENT_BINARY_DIR}/${APILC}.files")
79         file(GENERATE OUTPUT ${API_FILES} CONTENT "${SCRIPT_${APIUC}_BINARY_FILES}")
80         add_custom_command_timestamp(OUTPUT ${INCLUDES_BINARY_FILE}
81                 COMMAND ${CMAKE_COMMAND}
82                         -DINCLUDES_SOURCE_FILE=${CMAKE_CURRENT_SOURCE_DIR}/script_includes.hpp.in
83                         -DINCLUDES_BINARY_FILE=${INCLUDES_BINARY_FILE}
84                         -DAPIUC=${APIUC}
85                         -DAPILC=${APILC}
86                         -DAPI_FILES=${API_FILES}
87                         -P ${CMAKE_SOURCE_DIR}/cmake/scripts/SquirrelIncludes.cmake
88                 MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/script_includes.hpp.in
89                 DEPENDS ${SCRIPT_${APIUC}_BINARY_FILES}
90                         ${API_FILES}
91                         ${CMAKE_SOURCE_DIR}/cmake/scripts/SquirrelIncludes.cmake
92                 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
93                 COMMENT "Generating ${APILC}/${APILC}_includes.hpp"
94         )
95         add_custom_target_timestamp(script_${APILC}_includes
96                 DEPENDS
97                 ${INCLUDES_BINARY_FILE}
98         )
99         add_dependencies(script_${APILC}_includes
100             script_${APILC}
101         )
102         add_dependencies(script_api
103                 script_${APILC}_includes
104         )
106         # Documentation
107         if(DOXYGEN_EXECUTABLE)
108             add_custom_target(docs_${APILC}
109                 ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/docs
110                 COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile_${APIUC}
111                 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
112                 COMMENT "Generating documentation for ${APILC} API"
113             )
114             add_dependencies(docs_${APILC}
115                 find_version
116                 script_window
117             )
118             add_dependencies(docs
119                 docs_${APILC}
120             )
121         endif()
122     else()
123         add_dependencies(script_api
124                 script_${APILC}
125         )
126     endif()
128     target_include_directories(script_api
129             INTERFACE
130             ${CMAKE_BINARY_DIR}/generated/script
131             ${CMAKE_BINARY_DIR}/generated/script/api/${APILC}
132             ${CMAKE_CURRENT_SOURCE_DIR}/${APILC}
133     )
134 endforeach()
136 if(OPTION_TOOLS_ONLY)
137     return()
138 endif()
140 add_library(openttd::script_api ALIAS script_api)
143 add_files(
144     ai_changelog.hpp
145     game_changelog.hpp
146     script_accounting.hpp
147     script_admin.hpp
148     script_airport.hpp
149     script_asyncmode.hpp
150     script_base.hpp
151     script_basestation.hpp
152     script_bridge.hpp
153     script_bridgelist.hpp
154     script_cargo.hpp
155     script_cargolist.hpp
156     script_cargomonitor.hpp
157     script_client.hpp
158     script_clientlist.hpp
159     script_company.hpp
160     script_companymode.hpp
161     script_controller.hpp
162     script_date.hpp
163     script_depotlist.hpp
164     script_engine.hpp
165     script_enginelist.hpp
166     script_error.hpp
167     script_event.hpp
168     script_event_types.hpp
169     script_execmode.hpp
170     script_game.hpp
171     script_gamesettings.hpp
172     script_goal.hpp
173     script_group.hpp
174     script_grouplist.hpp
175     script_industry.hpp
176     script_industrylist.hpp
177     script_industrytype.hpp
178     script_industrytypelist.hpp
179     script_info_docs.hpp
180     script_infrastructure.hpp
181     script_league.hpp
182     script_list.hpp
183     script_log.hpp
184     script_log_types.hpp
185     script_map.hpp
186     script_marine.hpp
187     script_newgrf.hpp
188     script_news.hpp
189     script_object.hpp
190     script_objecttype.hpp
191     script_objecttypelist.hpp
192     script_order.hpp
193     script_priorityqueue.hpp
194     script_rail.hpp
195     script_railtypelist.hpp
196     script_road.hpp
197     script_roadtypelist.hpp
198     script_sign.hpp
199     script_signlist.hpp
200     script_station.hpp
201     script_stationlist.hpp
202     script_story_page.hpp
203     script_storypagelist.hpp
204     script_storypageelementlist.hpp
205     script_subsidy.hpp
206     script_subsidylist.hpp
207     script_testmode.hpp
208     script_text.hpp
209     script_tile.hpp
210     script_tilelist.hpp
211     script_town.hpp
212     script_townlist.hpp
213     script_tunnel.hpp
214     script_types.hpp
215     script_vehicle.hpp
216     script_vehiclelist.hpp
217     script_viewport.hpp
218     script_waypoint.hpp
219     script_waypointlist.hpp
220     script_accounting.cpp
221     script_admin.cpp
222     script_airport.cpp
223     script_asyncmode.cpp
224     script_base.cpp
225     script_basestation.cpp
226     script_bridge.cpp
227     script_bridgelist.cpp
228     script_cargo.cpp
229     script_cargolist.cpp
230     script_cargomonitor.cpp
231     script_client.cpp
232     script_clientlist.cpp
233     script_company.cpp
234     script_companymode.cpp
235     script_controller.cpp
236     script_date.cpp
237     script_depotlist.cpp
238     script_engine.cpp
239     script_enginelist.cpp
240     script_error.cpp
241     script_event.cpp
242     script_event_types.cpp
243     script_execmode.cpp
244     script_game.cpp
245     script_gamesettings.cpp
246     script_goal.cpp
247     script_group.cpp
248     script_grouplist.cpp
249     script_industry.cpp
250     script_industrylist.cpp
251     script_industrytype.cpp
252     script_industrytypelist.cpp
253     script_infrastructure.cpp
254     script_league.cpp
255     script_list.cpp
256     script_log.cpp
257     script_map.cpp
258     script_marine.cpp
259     script_newgrf.cpp
260     script_news.cpp
261     script_object.cpp
262     script_objecttype.cpp
263     script_objecttypelist.cpp
264     script_order.cpp
265     script_priorityqueue.cpp
266     script_rail.cpp
267     script_railtypelist.cpp
268     script_road.cpp
269     script_roadtypelist.cpp
270     script_sign.cpp
271     script_signlist.cpp
272     script_station.cpp
273     script_stationlist.cpp
274     script_story_page.cpp
275     script_storypagelist.cpp
276     script_storypageelementlist.cpp
277     script_subsidy.cpp
278     script_subsidylist.cpp
279     script_testmode.cpp
280     script_text.cpp
281     script_tile.cpp
282     script_tilelist.cpp
283     script_town.cpp
284     script_townlist.cpp
285     script_tunnel.cpp
286     script_vehicle.cpp
287     script_vehiclelist.cpp
288     script_viewport.cpp
289     script_waypoint.cpp
290     script_waypointlist.cpp
291     script_window.cpp