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})
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
27 ${CMAKE_BINARY_DIR}/generated/script/api/script_window.hpp
29 target_include_directories(script_api
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")
42 foreach(SCRIPT_API_FILE IN LISTS SCRIPT_API_FILES)
43 if("${SCRIPT_API_FILE}" MATCHES ".*script_controller.*")
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}
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"
64 list(APPEND SCRIPT_${APIUC}_BINARY_FILES ${SCRIPT_API_BINARY_FILE})
67 add_custom_target_timestamp(script_${APILC}
69 ${SCRIPT_${APIUC}_BINARY_FILES}
71 add_dependencies(script_${APILC}
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}
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}
91 ${CMAKE_SOURCE_DIR}/cmake/scripts/SquirrelIncludes.cmake
92 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
93 COMMENT "Generating ${APILC}/${APILC}_includes.hpp"
95 add_custom_target_timestamp(script_${APILC}_includes
97 ${INCLUDES_BINARY_FILE}
99 add_dependencies(script_${APILC}_includes
102 add_dependencies(script_api
103 script_${APILC}_includes
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"
114 add_dependencies(docs_${APILC}
118 add_dependencies(docs
123 add_dependencies(script_api
128 target_include_directories(script_api
130 ${CMAKE_BINARY_DIR}/generated/script
131 ${CMAKE_BINARY_DIR}/generated/script/api/${APILC}
132 ${CMAKE_CURRENT_SOURCE_DIR}/${APILC}
136 if(OPTION_TOOLS_ONLY)
140 add_library(openttd::script_api ALIAS script_api)
146 script_accounting.hpp
151 script_basestation.hpp
153 script_bridgelist.hpp
156 script_cargomonitor.hpp
158 script_clientlist.hpp
160 script_companymode.hpp
161 script_controller.hpp
165 script_enginelist.hpp
168 script_event_types.hpp
171 script_gamesettings.hpp
176 script_industrylist.hpp
177 script_industrytype.hpp
178 script_industrytypelist.hpp
180 script_infrastructure.hpp
190 script_objecttype.hpp
191 script_objecttypelist.hpp
193 script_priorityqueue.hpp
195 script_railtypelist.hpp
197 script_roadtypelist.hpp
201 script_stationlist.hpp
202 script_story_page.hpp
203 script_storypagelist.hpp
204 script_storypageelementlist.hpp
206 script_subsidylist.hpp
216 script_vehiclelist.hpp
219 script_waypointlist.hpp
220 script_accounting.cpp
225 script_basestation.cpp
227 script_bridgelist.cpp
230 script_cargomonitor.cpp
232 script_clientlist.cpp
234 script_companymode.cpp
235 script_controller.cpp
239 script_enginelist.cpp
242 script_event_types.cpp
245 script_gamesettings.cpp
250 script_industrylist.cpp
251 script_industrytype.cpp
252 script_industrytypelist.cpp
253 script_infrastructure.cpp
262 script_objecttype.cpp
263 script_objecttypelist.cpp
265 script_priorityqueue.cpp
267 script_railtypelist.cpp
269 script_roadtypelist.cpp
273 script_stationlist.cpp
274 script_story_page.cpp
275 script_storypagelist.cpp
276 script_storypageelementlist.cpp
278 script_subsidylist.cpp
287 script_vehiclelist.cpp
290 script_waypointlist.cpp