CMake: Make sure to install generated sources and header files

We weren't installing a lot of generated sources for the top level Lagom
build or for LibWeb, making it impossible to use LibWeb from a
find_package. ...And also Kernel/API/KeyCode.h, which is included by
no less than 8 different files in Userland/Libraries. We also weren't
installing any Ladybird header files.
This commit is contained in:
Andrew Kaster 2023-08-07 22:14:22 -06:00 committed by Andrew Kaster
parent 79108f615d
commit 92214b59ab
Notes: sideshowbarker 2024-07-17 06:51:48 +09:00
4 changed files with 62 additions and 9 deletions

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.16...3.22)
cmake_minimum_required(VERSION 3.23)
project(ladybird
VERSION 0.0.1
@ -92,6 +92,16 @@ set(SOURCES
HelperProcess.cpp
Utilities.cpp
)
set(BROWSER_HEADERS
${BROWSER_SOURCE_DIR}/CookieJar.h
${BROWSER_SOURCE_DIR}/Database.h
${BROWSER_SOURCE_DIR}/History.h
)
set(LADYBIRD_HEADERS
HelperProcess.h
Types.h
Utilities.h
)
if (ENABLE_QT)
qt_add_executable(ladybird ${SOURCES})
@ -129,6 +139,14 @@ else()
# For now, we can export a static library of common files for chromes to link to
add_library(ladybird STATIC ${SOURCES})
endif()
target_sources(ladybird PUBLIC FILE_SET browser TYPE HEADERS
BASE_DIRS ${SERENITY_SOURCE_DIR}/Userland/Applications
FILES ${BROWSER_HEADERS}
)
target_sources(ladybird PUBLIC FILE_SET ladybird TYPE HEADERS
BASE_DIRS ${SERENITY_SOURCE_DIR}
FILES ${LADYBIRD_HEADERS}
)
target_link_libraries(ladybird PRIVATE LibCore LibFileSystem LibGfx LibGUI LibIPC LibJS LibMain LibWeb LibWebView LibSQL LibProtocol)
target_include_directories(ladybird PRIVATE ${CMAKE_CURRENT_BINARY_DIR})

View File

@ -24,6 +24,10 @@ install(TARGETS ${app_install_targets}
COMPONENT ladybird_Runtime
NAMELINK_COMPONENT ladybird_Development
DESTINATION ${CMAKE_INSTALL_LIBDIR}
FILE_SET browser
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILE_SET ladybird
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
include("${SERENITY_SOURCE_DIR}/Meta/Lagom/get_linked_lagom_libraries.cmake")

View File

@ -1,12 +1,12 @@
function (generate_css_implementation)
set(LIBWEB_INPUT_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}")
invoke_generator(
"EasingFunctions.cpp"
Lagom::GenerateCSSEasingFunctions
"${LIBWEB_INPUT_FOLDER}/CSS/EasingFunctions.json"
"CSS/EasingFunctions.h"
"CSS/EasingFunctions.cpp"
arguments -j "${LIBWEB_INPUT_FOLDER}/CSS/EasingFunctions.json"
"EasingFunctions.cpp"
Lagom::GenerateCSSEasingFunctions
"${LIBWEB_INPUT_FOLDER}/CSS/EasingFunctions.json"
"CSS/EasingFunctions.h"
"CSS/EasingFunctions.cpp"
arguments -j "${LIBWEB_INPUT_FOLDER}/CSS/EasingFunctions.json"
)
invoke_generator(
@ -89,6 +89,18 @@ function (generate_css_implementation)
add_custom_target(generate_QuirksModeStyleSheetSource.cpp DEPENDS CSS/QuirksModeStyleSheetSource.cpp)
add_dependencies(all_generated generate_QuirksModeStyleSheetSource.cpp)
set(CSS_GENERATED_TO_INSTALL
"CSS/EasingFunctions.h"
"CSS/Enums.h"
"CSS/MathFunctions.h"
"CSS/MediaFeatureID.h"
"CSS/PropertyID.h"
"CSS/TransformFunctions.h"
"CSS/ValueID.h"
)
list(TRANSFORM CSS_GENERATED_TO_INSTALL PREPEND "${CMAKE_CURRENT_BINARY_DIR}/")
install(FILES ${CSS_GENERATED_TO_INSTALL} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/LibWeb/CSS")
endfunction()
function (generate_js_bindings target)
@ -154,6 +166,10 @@ function (generate_js_bindings target)
add_dependencies(all_generated generate_${basename})
add_dependencies(${target} generate_${basename})
# install generated sources
list(FILTER BINDINGS_SOURCES INCLUDE REGEX "\.h$")
install(FILES ${BINDINGS_SOURCES} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/LibWeb/Bindings")
list(APPEND LIBWEB_ALL_IDL_FILES "${LIBWEB_INPUT_FOLDER}/${class}.idl")
set(LIBWEB_ALL_IDL_FILES ${LIBWEB_ALL_IDL_FILES} PARENT_SCOPE)
endfunction()
@ -185,6 +201,10 @@ function (generate_js_bindings target)
add_custom_target(generate_exposed_interfaces DEPENDS ${exposed_interface_sources})
add_dependencies(all_generated generate_exposed_interfaces)
add_dependencies(${target} generate_exposed_interfaces)
list(FILTER exposed_interface_sources INCLUDE REGEX "\.h$")
list(TRANSFORM exposed_interface_sources PREPEND "${CMAKE_CURRENT_BINARY_DIR}/")
install(FILES ${exposed_interface_sources} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/LibWeb/Bindings")
endfunction()
include("idl_files.cmake")

View File

@ -377,6 +377,11 @@ install(
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*.h"
)
install(FILES
${Lagom_BINARY_DIR}/AK/Debug.h
COMPONENT Lagom_Development
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/AK"
)
# Code Generators and other host tools
if (BUILD_LAGOM_TOOLS)
@ -452,11 +457,14 @@ if (BUILD_LAGOM)
list(APPEND LIBWEBVIEW_GENERATED_SOURCES WebSocket/WebSocketClientEndpoint.h)
list(APPEND LIBWEBVIEW_GENERATED_SOURCES WebSocket/WebSocketServerEndpoint.h)
set(GENERATED_SOURCES ${LIBWEBVIEW_GENERATED_SOURCES})
lagom_lib(LibWebView webview
SOURCES ${LIBWEBVIEW_SOURCES} ${LIBWEBVIEW_GENERATED_SOURCES}
LIBS LibGfx LibGUI LibIPC LibWeb LibProtocol)
unset(GENERATED_SOURCES)
foreach(header ${LIBWEBVIEW_GENERATED_SOURCES})
get_filename_component(subdirectory ${header} DIRECTORY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${header}" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${subdirectory}")
endforeach()
install(FILES "${SERENITY_PROJECT_ROOT}/Userland/Services/RequestServer/ConnectionCache.h" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/RequestServer")
endif()
if (NOT EMSCRIPTEN)
@ -488,6 +496,9 @@ if (BUILD_LAGOM)
SOURCES ${LIBGUI_SOURCES}
LIBS LibGfx LibSyntax)
# FIXME: How about we don't include Kernel/API from random high-level libraries?
install(FILES ${SERENITY_PROJECT_ROOT}/Kernel/API/KeyCode.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/Kernel/API")
# FIXME: LibLocaleData is an object lib in Lagom, because the weak symbol trick we use on serenity
# straight up isn't supposed to work per ELF rules
target_link_libraries(LibLocale PRIVATE LibTimeZone)