1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 18:18:12 +00:00

Lagom+CMake: Propagate dependencies for generated custom targets

We have logic for serenity_generated_sources which works well for source
files that are specified in GENERATED_SOURCES prior to calling
serenity_lib or serenity_bin. However, code generated with
invoke_generator, and the LibWeb generators do not always follow the
pattern of the IDL and GML files.

For the LibWeb generators, we can just add_dependencies to LibWeb at the
time we declare the generate_Foo custom target. However for LibLocale,
LibTimeZone, and LibUnicode, we don't have the name of the target
available, so export the name in a variable to set into
GENERATED_SOURCES.

To make this work for Lagom, we need to make sure that lagom_lib and
serenity_bin in Lagom/CMakeLists.txt call serenity_generated_sources on
the target.

This enables the Xcode generator on macOS hosts, at least for Lagom.
This commit is contained in:
Andrew Kaster 2022-10-16 23:49:52 -06:00 committed by Linus Groh
parent 8160b53228
commit b8e51425e9
6 changed files with 22 additions and 10 deletions

View file

@ -121,14 +121,13 @@ function (generate_js_bindings target)
MAIN_DEPENDENCY ${class}.idl
)
endforeach()
add_custom_target(generate_${basename}Constructor.h DEPENDS Bindings/${basename}Constructor.h)
add_dependencies(all_generated generate_${basename}Constructor.h)
add_custom_target(generate_${basename}Constructor.cpp DEPENDS Bindings/${basename}Constructor.cpp)
add_dependencies(all_generated generate_${basename}Constructor.cpp)
add_custom_target(generate_${basename}Prototype.h DEPENDS Bindings/${basename}Prototype.h)
add_dependencies(all_generated generate_${basename}Prototype.h)
add_custom_target(generate_${basename}Prototype.cpp DEPENDS Bindings/${basename}Prototype.cpp)
add_dependencies(all_generated generate_${basename}Prototype.cpp)
foreach(generated_file IN LISTS BINDINGS_SOURCES)
get_filename_component(generated_name ${generated_file} NAME)
add_custom_target(generate_${generated_name} DEPENDS ${generated_file})
add_dependencies(all_generated generate_${generated_name})
add_dependencies(${target} generate_${generated_name})
endforeach()
list(APPEND LIBWEB_ALL_IDL_FILES "${LIBWEB_INPUT_FOLDER}/${class}.idl")
set(LIBWEB_ALL_IDL_FILES ${LIBWEB_ALL_IDL_FILES} PARENT_SCOPE)
@ -154,8 +153,9 @@ function (generate_js_bindings target)
DEPENDS Lagom::GenerateWindowOrWorkerInterfaces ${LIBWEB_ALL_IDL_FILES}
)
target_sources(${target} PRIVATE ${exposed_interface_sources})
add_custom_target("generate_exposed_interfaces" DEPENDS ${exposed_interface_sources})
add_dependencies(all_generated "generate_exposed_interfaces")
add_custom_target(generate_exposed_interfaces DEPENDS ${exposed_interface_sources})
add_dependencies(all_generated generate_exposed_interfaces)
add_dependencies(${target} generate_exposed_interfaces)
endfunction()
include("idl_files.cmake")