mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 20:37:34 +00:00
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.
This commit is contained in:
parent
2a218ebb9d
commit
f7f92f104f
2 changed files with 48 additions and 40 deletions
|
@ -171,14 +171,12 @@ install(
|
||||||
)
|
)
|
||||||
|
|
||||||
function(lagom_lib library fs_name)
|
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}")
|
set(target_name "Lib${library}")
|
||||||
if (LAGOM_LIBRARY_STATIC)
|
if (NOT LAGOM_LIBRARY_LIBRARY_TYPE)
|
||||||
add_library(${target_name} STATIC ${LAGOM_LIBRARY_SOURCES})
|
set(LAGOM_LIBRARY_LIBRARY_TYPE "")
|
||||||
else()
|
|
||||||
add_library(${target_name} ${LAGOM_LIBRARY_SOURCES})
|
|
||||||
endif()
|
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
|
# Don't make alias when we're going to import a previous build for Tools
|
||||||
# FIXME: Is there a better way to write this?
|
# FIXME: Is there a better way to write this?
|
||||||
if (NOT ENABLE_FUZZERS AND NOT CMAKE_CROSSCOMPILING)
|
if (NOT ENABLE_FUZZERS AND NOT CMAKE_CROSSCOMPILING)
|
||||||
|
@ -210,6 +208,7 @@ function(lagom_lib library fs_name)
|
||||||
INCLUDES #
|
INCLUDES #
|
||||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
)
|
)
|
||||||
|
# FIXME: Move this to serenity_install_headers
|
||||||
install(
|
install(
|
||||||
DIRECTORY "${SERENITY_PROJECT_ROOT}/Userland/Libraries/Lib${library}"
|
DIRECTORY "${SERENITY_PROJECT_ROOT}/Userland/Libraries/Lib${library}"
|
||||||
COMPONENT Lagom_Development
|
COMPONENT Lagom_Development
|
||||||
|
@ -250,9 +249,25 @@ function(serenity_bin name)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(serenity_lib name fs_name)
|
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()
|
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)
|
add_custom_target(components ALL)
|
||||||
option(BUILD_EVERYTHING "Build all optional components" ON)
|
option(BUILD_EVERYTHING "Build all optional components" ON)
|
||||||
|
|
||||||
|
@ -261,34 +276,25 @@ if (NOT TARGET all_generated)
|
||||||
add_custom_target(all_generated)
|
add_custom_target(all_generated)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# 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(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
|
# AK/LibCore
|
||||||
# Note: AK is included in LibCore for the host build instead of LibC per the target build
|
# 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")
|
add_serenity_subdirectory(AK)
|
||||||
file(GLOB LIBCORE_SOURCES CONFIGURE_DEPENDS "../../Userland/Libraries/LibCore/*.cpp")
|
add_serenity_subdirectory(Userland/Libraries/LibCore)
|
||||||
if (ANDROID)
|
target_link_libraries(LibCore Threads::Threads)
|
||||||
list(REMOVE_ITEM LIBCORE_SOURCES "${CMAKE_CURRENT_LIST_DIR}/../../Userland/Libraries/LibCore/Account.cpp")
|
target_sources(LibCore PRIVATE ${AK_SOURCES})
|
||||||
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
|
|
||||||
)
|
|
||||||
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
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# LibMain
|
# LibMain
|
||||||
file(GLOB LIBMAIN_SOURCES CONFIGURE_DEPENDS "../../Userland/Libraries/LibMain/*.cpp")
|
add_serenity_subdirectory(Userland/Libraries/LibMain)
|
||||||
lagom_lib(Main main
|
|
||||||
SOURCES ${LIBMAIN_SOURCES}
|
|
||||||
STATIC
|
|
||||||
)
|
|
||||||
|
|
||||||
# LibTimeZone
|
# LibTimeZone
|
||||||
# This is needed even if Lagom is not enabled because it is depended upon by code generators.
|
# This is needed even if Lagom is not enabled because it is depended upon by code generators.
|
||||||
|
|
|
@ -1,21 +1,17 @@
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
AnonymousBuffer.cpp
|
AnonymousBuffer.cpp
|
||||||
ArgsParser.cpp
|
ArgsParser.cpp
|
||||||
ConfigFile.cpp
|
|
||||||
Command.cpp
|
Command.cpp
|
||||||
|
ConfigFile.cpp
|
||||||
DateTime.cpp
|
DateTime.cpp
|
||||||
Directory.cpp
|
Directory.cpp
|
||||||
DirIterator.cpp
|
DirIterator.cpp
|
||||||
ElapsedTimer.cpp
|
ElapsedTimer.cpp
|
||||||
Event.cpp
|
Event.cpp
|
||||||
EventLoop.cpp
|
EventLoop.cpp
|
||||||
FileWatcher.cpp
|
|
||||||
File.cpp
|
File.cpp
|
||||||
FilePermissionsMask.cpp
|
FileWatcher.cpp
|
||||||
GetPassword.cpp
|
|
||||||
Group.cpp
|
|
||||||
IODevice.cpp
|
IODevice.cpp
|
||||||
LocalServer.cpp
|
|
||||||
LockFile.cpp
|
LockFile.cpp
|
||||||
MappedFile.cpp
|
MappedFile.cpp
|
||||||
MimeData.cpp
|
MimeData.cpp
|
||||||
|
@ -28,8 +24,8 @@ set(SOURCES
|
||||||
SecretString.cpp
|
SecretString.cpp
|
||||||
SessionManagement.cpp
|
SessionManagement.cpp
|
||||||
SOCKSProxyClient.cpp
|
SOCKSProxyClient.cpp
|
||||||
Stream.cpp
|
|
||||||
StandardPaths.cpp
|
StandardPaths.cpp
|
||||||
|
Stream.cpp
|
||||||
System.cpp
|
System.cpp
|
||||||
SystemServerTakeover.cpp
|
SystemServerTakeover.cpp
|
||||||
TCPServer.cpp
|
TCPServer.cpp
|
||||||
|
@ -38,8 +34,14 @@ set(SOURCES
|
||||||
UDPServer.cpp
|
UDPServer.cpp
|
||||||
Version.cpp
|
Version.cpp
|
||||||
)
|
)
|
||||||
if (NOT ANDROID)
|
if (NOT ANDROID AND NOT WIN32)
|
||||||
list(APPEND SOURCES Account.cpp)
|
list(APPEND SOURCES
|
||||||
|
Account.cpp
|
||||||
|
FilePermissionsMask.cpp
|
||||||
|
GetPassword.cpp
|
||||||
|
Group.cpp
|
||||||
|
LocalServer.cpp
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
serenity_lib(LibCore core)
|
serenity_lib(LibCore core)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue