mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03:00
Ladybird: Support building Ladybird as a non-top-level project
The implementation assumes that Lagom is either the top level project, or included before Ladybird is.
This commit is contained in:
parent
03294b0177
commit
b4d80f92ec
Notes:
sideshowbarker
2024-07-17 03:18:29 +09:00
Author: https://github.com/ADKaster Commit: https://github.com/SerenityOS/serenity/commit/b4d80f92ec Pull-request: https://github.com/SerenityOS/serenity/pull/16583 Reviewed-by: https://github.com/awesomekling ✅ Reviewed-by: https://github.com/linusg
@ -45,16 +45,27 @@ if (ENABLE_UNDEFINED_SANITIZER)
|
||||
endif()
|
||||
|
||||
# Lagom
|
||||
include(FetchContent)
|
||||
include(cmake/FetchLagom.cmake)
|
||||
# FIXME: PROJECT_IS_TOP_LEVEL with CMake 3.21+
|
||||
set(LADYBIRD_IS_TOP_LEVEL FALSE)
|
||||
set(LADYBIRD_CUSTOM_TARGET_SUFFIX "-ladybird")
|
||||
if ("${CMAKE_BINARY_DIR}" STREQUAL "${PROJECT_BINARY_DIR}")
|
||||
set(LADYBIRD_IS_TOP_LEVEL TRUE)
|
||||
set(LADYBIRD_CUSTOM_TARGET_SUFFIX "")
|
||||
endif()
|
||||
|
||||
get_filename_component(
|
||||
SERENITY_SOURCE_DIR "${Lagom_SOURCE_DIR}/../.."
|
||||
ABSOLUTE
|
||||
)
|
||||
if (LADYBIRD_IS_TOP_LEVEL)
|
||||
get_filename_component(
|
||||
SERENITY_SOURCE_DIR "${ladybird_SOURCE_DIR}/.."
|
||||
ABSOLUTE
|
||||
)
|
||||
list(APPEND CMAKE_MODULE_PATH "${SERENITY_SOURCE_DIR}/Meta/CMake")
|
||||
include(cmake/EnableLagom.cmake)
|
||||
include(lagom_compile_options NO_POLICY_SCOPE)
|
||||
else()
|
||||
# FIXME: Use SERENITY_SOURCE_DIR in Lagom/CMakeLists.txt
|
||||
set(SERENITY_SOURCE_DIR "${SERENITY_PROJECT_ROOT}")
|
||||
endif()
|
||||
|
||||
# Lagom warnings
|
||||
include(${Lagom_SOURCE_DIR}/../CMake/lagom_compile_options.cmake)
|
||||
add_compile_options(-Wno-expansion-to-defined)
|
||||
add_compile_options(-Wno-user-defined-literals)
|
||||
|
||||
@ -102,12 +113,12 @@ if (ANDROID)
|
||||
include(cmake/AndroidExtras.cmake)
|
||||
endif()
|
||||
|
||||
add_custom_target(run
|
||||
add_custom_target(run${LADYBIRD_CUSTOM_TARGET_SUFFIX}
|
||||
COMMAND "${CMAKE_COMMAND}" -E env "SERENITY_SOURCE_DIR=${SERENITY_SOURCE_DIR}" "$<TARGET_FILE:ladybird>"
|
||||
USES_TERMINAL
|
||||
)
|
||||
|
||||
add_custom_target(debug
|
||||
add_custom_target(debug${LADYBIRD_CUSTOM_TARGET_SUFFIX}
|
||||
COMMAND "${CMAKE_COMMAND}" -E env "SERENITY_SOURCE_DIR=${SERENITY_SOURCE_DIR}" gdb -ex "set follow-fork-mode child" "$<TARGET_FILE:ladybird>"
|
||||
USES_TERMINAL
|
||||
)
|
||||
|
18
Ladybird/cmake/EnableLagom.cmake
Normal file
18
Ladybird/cmake/EnableLagom.cmake
Normal file
@ -0,0 +1,18 @@
|
||||
# Copyright (c) 2021, Andrew Kaster <akaster@serenityos.org>
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
set(BUILD_LAGOM ON CACHE INTERNAL "Build all Lagom targets")
|
||||
|
||||
set(LAGOM_SOURCE_DIR "${SERENITY_SOURCE_DIR}/Meta/Lagom")
|
||||
set(LAGOM_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/Lagom")
|
||||
|
||||
# FIXME: Setting target_include_directories on Lagom libraries might make this unecessary?
|
||||
include_directories(${SERENITY_SOURCE_DIR})
|
||||
include_directories(${SERENITY_SOURCE_DIR}/Userland/Libraries)
|
||||
include_directories(${LAGOM_BINARY_DIR})
|
||||
include_directories(${LAGOM_BINARY_DIR}/Userland/Services)
|
||||
include_directories(${LAGOM_BINARY_DIR}/Userland/Libraries)
|
||||
|
||||
# We set EXCLUDE_FROM_ALL to make sure that only required Lagom libraries are built
|
||||
add_subdirectory("${LAGOM_SOURCE_DIR}" "${LAGOM_BINARY_DIR}" EXCLUDE_FROM_ALL)
|
@ -1,35 +0,0 @@
|
||||
# Copyright (c) 2021, Andrew Kaster <akaster@serenityos.org>
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
# Fetch serenity, so that we can build Lagom from it
|
||||
FetchContent_Declare(lagom
|
||||
GIT_REPOSITORY https://github.com/SerenityOS/serenity.git
|
||||
GIT_TAG origin/master
|
||||
GIT_SHALLOW TRUE
|
||||
SOURCE_DIR serenity
|
||||
)
|
||||
|
||||
# Allow developers to skip download/update steps with local checkout
|
||||
if (SERENITY_SOURCE_DIR)
|
||||
set(FETCHCONTENT_SOURCE_DIR_LAGOM ${SERENITY_SOURCE_DIR} CACHE PATH "Developer's pre-existing serenity source directory" FORCE)
|
||||
message(STATUS "Using pre-existing SERENITY_SOURCE_DIR: ${SERENITY_SOURCE_DIR}")
|
||||
endif()
|
||||
|
||||
# Can't use FetchContent_MakeAvailable b/c we want to use the Lagom build, not the main build
|
||||
# Populate source directory for lagom
|
||||
FetchContent_GetProperties(lagom)
|
||||
if (NOT lagom_POPULATED)
|
||||
FetchContent_Populate(lagom)
|
||||
set(BUILD_LAGOM ON CACHE INTERNAL "Build all Lagom targets")
|
||||
|
||||
# FIXME: Setting target_include_directories on Lagom libraries might make this unecessary?
|
||||
include_directories(${lagom_SOURCE_DIR})
|
||||
include_directories(${lagom_SOURCE_DIR}/Userland/Libraries)
|
||||
include_directories(${lagom_BINARY_DIR})
|
||||
include_directories(${lagom_BINARY_DIR}/Userland/Services)
|
||||
include_directories(${lagom_BINARY_DIR}/Userland/Libraries)
|
||||
|
||||
# We set EXCLUDE_FROM_ALL to make sure that only required Lagom libraries are built
|
||||
add_subdirectory(${lagom_SOURCE_DIR}/Meta/Lagom ${lagom_BINARY_DIR} EXCLUDE_FROM_ALL)
|
||||
endif()
|
@ -28,7 +28,7 @@ install(TARGETS WebContent
|
||||
DESTINATION bundle
|
||||
)
|
||||
|
||||
include("${Lagom_SOURCE_DIR}/get_linked_lagom_libraries.cmake")
|
||||
include("${SERENITY_SOURCE_DIR}/Meta/Lagom/get_linked_lagom_libraries.cmake")
|
||||
get_linked_lagom_libraries(ladybird ladybird_lagom_libraries)
|
||||
get_linked_lagom_libraries(WebContent webcontent_lagom_libraries)
|
||||
list(APPEND all_required_lagom_libraries ${ladybird_lagom_libraries} ${webcontent_lagom_libraries})
|
||||
|
Loading…
Reference in New Issue
Block a user