summaryrefslogtreecommitdiff
path: root/Ladybird/cmake
diff options
context:
space:
mode:
authorAndrew Kaster <akaster@serenityos.org>2022-07-04 05:45:18 -0600
committerAndrew Kaster <andrewdkaster@gmail.com>2022-12-25 07:58:58 -0700
commit74fda4aff511f3d81544873270d06cb938490597 (patch)
tree4b60ab5ac02424aeb817b09357ef86a9991f8128 /Ladybird/cmake
parentda19b78dea08c659acb51cb018e7a9f8fc8b49ff (diff)
downloadserenity-74fda4aff511f3d81544873270d06cb938490597.zip
Ladybird/Meta: Convert to CMake build
Diffstat (limited to 'Ladybird/cmake')
-rw-r--r--Ladybird/cmake/EnableLLD.cmake14
-rw-r--r--Ladybird/cmake/FetchLagom.cmake33
2 files changed, 47 insertions, 0 deletions
diff --git a/Ladybird/cmake/EnableLLD.cmake b/Ladybird/cmake/EnableLLD.cmake
new file mode 100644
index 0000000000..52416a404d
--- /dev/null
+++ b/Ladybird/cmake/EnableLLD.cmake
@@ -0,0 +1,14 @@
+
+option(LADYBIRD_USE_LLD "Use llvm lld to link application" ON)
+if (LADYBIRD_USE_LLD AND NOT APPLE)
+ find_program(LLD_LINKER NAMES "ld.lld")
+ if (NOT LLD_LINKER)
+ message(INFO "LLD not found, cannot use to link. Disabling option...")
+ set(LADYBIRD_USE_LLD OFF CACHE BOOL "" FORCE)
+ endif()
+endif()
+if (LADYBIRD_USE_LLD AND NOT APPLE)
+ add_link_options(-fuse-ld=lld)
+ add_compile_options(-ggnu-pubnames)
+ add_link_options(LINKER:--gdb-index)
+endif()
diff --git a/Ladybird/cmake/FetchLagom.cmake b/Ladybird/cmake/FetchLagom.cmake
new file mode 100644
index 0000000000..ef5abeb46d
--- /dev/null
+++ b/Ladybird/cmake/FetchLagom.cmake
@@ -0,0 +1,33 @@
+# 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}/Userland/Libraries)
+ include_directories(${lagom_SOURCE_DIR})
+ include_directories(${lagom_BINARY_DIR})
+
+ # 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()