From 58dfe5424f1eee6de55f3ad9700ad169e3ea3b7b Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Mon, 15 Jul 2024 13:24:18 -0400 Subject: [PATCH] AK: Make the AK library's CMake a bit more standard We no longer have multiple locations including AK (e.g. LibC). So let's avoid awkwardly defining the AK library across multiple CMake files. This is to allow more easily adding third-party dependencies to AK in the future. --- AK/CMakeLists.txt | 20 ++++++++++++++++---- Meta/Lagom/CMakeLists.txt | 13 ------------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/AK/CMakeLists.txt b/AK/CMakeLists.txt index 411b2833cd9..f566509651c 100644 --- a/AK/CMakeLists.txt +++ b/AK/CMakeLists.txt @@ -1,4 +1,4 @@ -set(AK_SOURCES +set(SOURCES Assertions.cpp Base64.cpp CircularBuffer.cpp @@ -37,10 +37,22 @@ set(AK_SOURCES Utf8View.cpp kmalloc.cpp ) -# AK sources are included from many different places -list(TRANSFORM AK_SOURCES PREPEND "${CMAKE_CURRENT_SOURCE_DIR}/") -set(AK_SOURCES ${AK_SOURCES} PARENT_SCOPE) +serenity_lib(AK ak) serenity_install_headers(AK) serenity_install_sources(AK) + +find_package(Backtrace) +configure_file(Backtrace.h.in Backtrace.h @ONLY) + +if (Backtrace_FOUND) + if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.30) + target_link_libraries(AK PRIVATE Backtrace::Backtrace) + else() + target_include_directories(AK PRIVATE ${Backtrace_INCLUDE_DIRS}) + target_link_libraries(AK PRIVATE ${Backtrace_LIBRARIES}) + endif() +else() + message(WARNING "Backtrace not found, stack traces will be unavailable") +endif() diff --git a/Meta/Lagom/CMakeLists.txt b/Meta/Lagom/CMakeLists.txt index 22eafef3e7e..77385b6a383 100644 --- a/Meta/Lagom/CMakeLists.txt +++ b/Meta/Lagom/CMakeLists.txt @@ -327,19 +327,6 @@ install(TARGETS LibC LibCrypt NoCoverage EXPORT LagomTargets) # AK add_serenity_subdirectory(AK) -lagom_lib(AK ak SOURCES ${AK_SOURCES}) -find_package(Backtrace) -configure_file(../../AK/Backtrace.h.in AK/Backtrace.h @ONLY) -if (Backtrace_FOUND) - if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.30) - target_link_libraries(AK PRIVATE Backtrace::Backtrace) - else() - target_include_directories(AK PRIVATE ${Backtrace_INCLUDE_DIRS}) - target_link_libraries(AK PRIVATE ${Backtrace_LIBRARIES}) - endif() -else() - message(WARNING "Backtrace not found, stack traces will be unavailable") -endif() # LibCoreMinimal add_serenity_subdirectory(Userland/Libraries/LibCore)