summaryrefslogtreecommitdiff
path: root/Meta
diff options
context:
space:
mode:
authorAndrew Kaster <akaster@serenityos.org>2022-10-13 14:07:09 -0600
committerLinus Groh <mail@linusgroh.de>2022-10-16 16:36:39 +0200
commitf7f92f104f7b403533756e3d4387b0e359a7de61 (patch)
tree72c2af4b9fbbfbf119a0f8421445791ceee2bc33 /Meta
parent2a218ebb9dabfc6053f8de6457642fb57570f70c (diff)
downloadserenity-f7f92f104f7b403533756e3d4387b0e359a7de61.zip
Lagom+LibCore: Build LibCore, AK, and LibMain with add_subdirectory
By deferring to the CMakeLists in each of these libraries' directories, we can get rid of a lot of curious GLOB patterns and list removals in the Lagom CMakeLists.
Diffstat (limited to 'Meta')
-rw-r--r--Meta/Lagom/CMakeLists.txt68
1 files changed, 37 insertions, 31 deletions
diff --git a/Meta/Lagom/CMakeLists.txt b/Meta/Lagom/CMakeLists.txt
index 6dd36c9250..1a80c58de4 100644
--- a/Meta/Lagom/CMakeLists.txt
+++ b/Meta/Lagom/CMakeLists.txt
@@ -171,14 +171,12 @@ install(
)
function(lagom_lib library fs_name)
- cmake_parse_arguments(LAGOM_LIBRARY "STATIC" "" "SOURCES;LIBS" ${ARGN})
+ cmake_parse_arguments(LAGOM_LIBRARY "" "LIBRARY_TYPE" "SOURCES;LIBS" ${ARGN})
set(target_name "Lib${library}")
- if (LAGOM_LIBRARY_STATIC)
- add_library(${target_name} STATIC ${LAGOM_LIBRARY_SOURCES})
- else()
- add_library(${target_name} ${LAGOM_LIBRARY_SOURCES})
+ if (NOT LAGOM_LIBRARY_LIBRARY_TYPE)
+ set(LAGOM_LIBRARY_LIBRARY_TYPE "")
endif()
-
+ add_library(${target_name} ${LAGOM_LIBRARY_LIBRARY_TYPE} ${LAGOM_LIBRARY_SOURCES})
# Don't make alias when we're going to import a previous build for Tools
# FIXME: Is there a better way to write this?
if (NOT ENABLE_FUZZERS AND NOT CMAKE_CROSSCOMPILING)
@@ -210,6 +208,7 @@ function(lagom_lib library fs_name)
INCLUDES #
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
+ # FIXME: Move this to serenity_install_headers
install(
DIRECTORY "${SERENITY_PROJECT_ROOT}/Userland/Libraries/Lib${library}"
COMPONENT Lagom_Development
@@ -250,9 +249,25 @@ function(serenity_bin name)
endfunction()
function(serenity_lib name fs_name)
- lagom_lib(name fs_name SOURCES ${SOURCES} ${GENERATED_SOURCES})
+ string(REPLACE "Lib" "" name_without_lib ${name})
+ lagom_lib(${name_without_lib} ${fs_name} SOURCES ${SOURCES} ${GENERATED_SOURCES})
+endfunction()
+
+function(serenity_lib_static name fs_name)
+ string(REPLACE "Lib" "" name_without_lib ${name})
+ lagom_lib(${name_without_lib} ${fs_name} LIBRARY_TYPE STATIC SOURCES ${SOURCES} ${GENERATED_SOURCES})
+endfunction()
+
+function(serenity_install_headers dir)
endfunction()
+function(serenity_install_sources dir)
+endfunction()
+
+macro(add_serenity_subdirectory path)
+ add_subdirectory("${SERENITY_PROJECT_ROOT}/${path}" "${CMAKE_CURRENT_BINARY_DIR}/${path}")
+endmacro()
+
add_custom_target(components ALL)
option(BUILD_EVERYTHING "Build all optional components" ON)
@@ -261,34 +276,25 @@ if (NOT TARGET all_generated)
add_custom_target(all_generated)
endif()
-# AK/LibCore
-# Note: AK is included in LibCore for the host build instead of LibC per the target build
-file(GLOB AK_SOURCES CONFIGURE_DEPENDS "../../AK/*.cpp")
-file(GLOB LIBCORE_SOURCES CONFIGURE_DEPENDS "../../Userland/Libraries/LibCore/*.cpp")
-if (ANDROID)
- list(REMOVE_ITEM LIBCORE_SOURCES "${CMAKE_CURRENT_LIST_DIR}/../../Userland/Libraries/LibCore/Account.cpp")
- list(REMOVE_ITEM LIBCORE_SOURCES "${CMAKE_CURRENT_LIST_DIR}/../../Userland/Libraries/LibCore/LocalServer.cpp")
-endif()
-if (WIN32)
- list(REMOVE_ITEM LIBCORE_SOURCES "${CMAKE_CURRENT_LIST_DIR}/../../Userland/Libraries/LibCore/Account.cpp")
- list(REMOVE_ITEM LIBCORE_SOURCES "${CMAKE_CURRENT_LIST_DIR}/../../Userland/Libraries/LibCore/FilePermissionsMask.cpp")
- list(REMOVE_ITEM LIBCORE_SOURCES "${CMAKE_CURRENT_LIST_DIR}/../../Userland/Libraries/LibCore/Group.cpp")
- list(REMOVE_ITEM LIBCORE_SOURCES "${CMAKE_CURRENT_LIST_DIR}/../../Userland/Libraries/LibCore/GetPassword.cpp")
-endif()
-lagom_lib(Core core
- SOURCES ${AK_SOURCES} ${LIBCORE_SOURCES}
- LIBS Threads::Threads
-)
+# Create mostly empty targets for system libraries we don't need to build for Lagom
+add_library(LibC INTERFACE)
+add_library(LibCrypt INTERFACE)
if (NOT APPLE AND NOT ANDROID AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
- target_link_libraries(LibCore crypt) # LibCore::Account uses crypt() but it's not in libcrypt on macOS
+ target_link_libraries(LibCrypt INTERFACE crypt) # LibCore::Account uses crypt() but it's not in libcrypt on macOS
endif()
+add_library(NoCoverage INTERFACE)
+# "install" these special targets to placate CMake
+install(TARGETS LibC LibCrypt NoCoverage EXPORT LagomTargets)
+
+# AK/LibCore
+# Note: AK is included in LibCore for the host build instead of LibC per the target build
+add_serenity_subdirectory(AK)
+add_serenity_subdirectory(Userland/Libraries/LibCore)
+target_link_libraries(LibCore Threads::Threads)
+target_sources(LibCore PRIVATE ${AK_SOURCES})
# LibMain
-file(GLOB LIBMAIN_SOURCES CONFIGURE_DEPENDS "../../Userland/Libraries/LibMain/*.cpp")
-lagom_lib(Main main
- SOURCES ${LIBMAIN_SOURCES}
- STATIC
-)
+add_serenity_subdirectory(Userland/Libraries/LibMain)
# LibTimeZone
# This is needed even if Lagom is not enabled because it is depended upon by code generators.