aboutsummaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2026-04-21 13:06:35 +0200
committerFelix Morgner <felix.morgner@ost.ch>2026-04-21 13:06:35 +0200
commit9b4cbc6ba3f8059278a20a4893780717851ce8e4 (patch)
treebb089d306639e1c3ef27c9b8f3fc90e8742f4117 /libs
parent3441e7e164d8e5e8413a1eb47e3e9f3c824ed2d0 (diff)
downloadteachos-9b4cbc6ba3f8059278a20a4893780717851ce8e4.tar.xz
teachos-9b4cbc6ba3f8059278a20a4893780717851ce8e4.zip
build: clean up configuration
Diffstat (limited to 'libs')
-rw-r--r--libs/acpi/CMakeLists.txt64
-rw-r--r--libs/elf/CMakeLists.txt43
-rw-r--r--libs/kstd/CMakeLists.txt97
-rw-r--r--libs/multiboot2/CMakeLists.txt49
4 files changed, 209 insertions, 44 deletions
diff --git a/libs/acpi/CMakeLists.txt b/libs/acpi/CMakeLists.txt
index 55d5b54..b0fc48f 100644
--- a/libs/acpi/CMakeLists.txt
+++ b/libs/acpi/CMakeLists.txt
@@ -6,17 +6,35 @@ project("acpi"
LANGUAGES ASM CXX
)
-add_library("acpi" STATIC)
-add_library("libs::acpi" ALIAS "acpi")
+include("CTest")
-target_include_directories("acpi" PUBLIC
- "${CMAKE_CURRENT_SOURCE_DIR}"
-)
+#[============================================================================[
+# External Dependencies
+#]============================================================================]
-file(GLOB_RECURSE ACPI_HEADERS
- RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
- "acpi/*.hpp"
-)
+include("FetchContent")
+
+if (BUILD_TESTING)
+ FetchContent_Declare(
+ "Catch2"
+ URL "https://github.com/catchorg/Catch2/archive/refs/tags/v3.7.1.tar.gz"
+ URL_HASH "SHA256=c991b247a1a0d7bb9c39aa35faf0fe9e19764213f28ffba3109388e62ee0269c"
+ EXCLUDE_FROM_ALL
+ FIND_PACKAGE_ARGS
+ )
+
+ FetchContent_MakeAvailable("Catch2")
+
+ find_package("Catch2")
+ include("Catch")
+endif()
+
+#[============================================================================[
+# Library
+#]============================================================================]
+
+add_library("acpi" STATIC)
+add_library("acpi::lib" ALIAS "acpi")
target_sources("acpi" PRIVATE
"acpi/common/checksum.cpp"
@@ -27,6 +45,11 @@ target_sources("acpi" PRIVATE
"acpi/pointers.cpp"
)
+file(GLOB_RECURSE ACPI_HEADERS
+ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
+ "acpi/*.hpp"
+)
+
target_sources("acpi" PUBLIC
FILE_SET HEADERS
BASE_DIRS "acpi"
@@ -34,11 +57,23 @@ target_sources("acpi" PUBLIC
${ACPI_HEADERS}
)
+target_include_directories("acpi" PUBLIC
+ "${CMAKE_CURRENT_SOURCE_DIR}"
+)
+
target_link_libraries("acpi" PUBLIC
- "libs::kstd"
+ "kstd::lib"
)
-if(NOT CMAKE_CROSSCOMPILING)
+set_target_properties("acpi" PROPERTIES
+ VERIFY_INTERFACE_HEADER_SETS YES
+)
+
+#[============================================================================[
+# Tests
+#]============================================================================]
+
+if(BUILD_TESTING)
find_program(IASL_EXE NAMES "iasl" REQUIRED)
set(TEST_TABLES
@@ -61,7 +96,10 @@ if(NOT CMAKE_CROSSCOMPILING)
set_source_files_properties("test_data/tables.S" PROPERTIES OBJECT_DEPENDS "${GENERATED_TABLE_BLOBS}")
- add_executable("acpi_tests"
+ add_executable("acpi_tests")
+ add_executable("acpi::tests" ALIAS "acpi_tests")
+
+ target_sources("acpi_tests" PRIVATE
"acpi/common/table_header.test.cpp"
"acpi/data/madt.test.cpp"
"acpi/data/rsdt.test.cpp"
@@ -77,7 +115,7 @@ if(NOT CMAKE_CROSSCOMPILING)
target_link_libraries("acpi_tests" PRIVATE
"Catch2::Catch2WithMain"
- "libs::acpi"
+ "acpi::lib"
)
set_target_properties("acpi_tests" PROPERTIES
diff --git a/libs/elf/CMakeLists.txt b/libs/elf/CMakeLists.txt
index f254094..f1f5275 100644
--- a/libs/elf/CMakeLists.txt
+++ b/libs/elf/CMakeLists.txt
@@ -1,7 +1,46 @@
+cmake_minimum_required(VERSION "3.27.0")
+
+project("elf"
+ DESCRIPTION "ELF file format library"
+ VERSION "0.0.1"
+ LANGUAGES CXX
+)
+
+include("CTest")
+
+#[============================================================================[
+# External Dependencies
+#]============================================================================]
+
+include("FetchContent")
+
+if (BUILD_TESTING)
+ FetchContent_Declare(
+ "Catch2"
+ URL "https://github.com/catchorg/Catch2/archive/refs/tags/v3.7.1.tar.gz"
+ URL_HASH "SHA256=c991b247a1a0d7bb9c39aa35faf0fe9e19764213f28ffba3109388e62ee0269c"
+ EXCLUDE_FROM_ALL
+ FIND_PACKAGE_ARGS
+ )
+
+ FetchContent_MakeAvailable("Catch2")
+
+ find_package("Catch2")
+ include("Catch")
+endif()
+
+#[============================================================================[
+# Library
+#]============================================================================]
+
add_library("elf" INTERFACE)
-add_library("libs::elf" ALIAS "elf")
+add_library("elf::lib" ALIAS "elf")
-file(GLOB_RECURSE ELF_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "include/**.hpp")
+file(GLOB_RECURSE ELF_HEADERS
+ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
+ CONFIGURE_DEPENDS
+ "include/**.hpp"
+)
target_sources("elf" INTERFACE
FILE_SET HEADERS
diff --git a/libs/kstd/CMakeLists.txt b/libs/kstd/CMakeLists.txt
index ced3138..ee84ff1 100644
--- a/libs/kstd/CMakeLists.txt
+++ b/libs/kstd/CMakeLists.txt
@@ -1,30 +1,52 @@
-add_library("kstd" STATIC)
-add_library("libs::kstd" ALIAS "kstd")
+cmake_minimum_required(VERSION "3.27.0")
-if(CMAKE_CROSSCOMPILING)
- set(KSTD_LIBC_SYMBOLS
- "abort"
- "strlen"
- "memcmp"
- "memcpy"
- )
+project("kstd"
+ DESCRIPTION "A kernel STL implementation"
+ VERSION "0.0.1"
+ LANGUAGES CXX
+)
- set(KSTD_LIBC_SOURCES
- "src/libc/stdlib.cpp"
- "src/libc/string.cpp"
- )
+include("CTest")
+
+#[============================================================================[
+# External Dependencies
+#]============================================================================]
+
+include("FetchContent")
+
+if (BUILD_TESTING)
+ FetchContent_Declare(
+ "Catch2"
+ URL "https://github.com/catchorg/Catch2/archive/refs/tags/v3.7.1.tar.gz"
+ URL_HASH "SHA256=c991b247a1a0d7bb9c39aa35faf0fe9e19764213f28ffba3109388e62ee0269c"
+ EXCLUDE_FROM_ALL
+ FIND_PACKAGE_ARGS
+ )
+
+ FetchContent_MakeAvailable("Catch2")
+
+ find_package("Catch2")
+ include("Catch")
endif()
-target_sources("kstd" PRIVATE
- ${KSTD_LIBC_SOURCES}
+#[============================================================================[
+# Library
+#]============================================================================]
- "src/os/error.cpp"
+add_library("kstd" STATIC)
+add_library("kstd::lib" ALIAS "kstd")
+target_sources("kstd" PRIVATE
+ "src/os/error.cpp"
"src/mutex.cpp"
"src/vformat.cpp"
)
-file(GLOB_RECURSE KSTD_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "include/kstd/*")
+file(GLOB_RECURSE KSTD_HEADERS
+ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
+ CONFIGURE_DEPENDS
+ "include/kstd/*"
+)
target_sources("kstd" PUBLIC
FILE_SET HEADERS
@@ -37,12 +59,37 @@ target_include_directories("kstd" PUBLIC
"include"
)
-if(CMAKE_CROSSCOMPILING)
+set_target_properties("kstd" PROPERTIES
+ VERIFY_INTERFACE_HEADER_SETS YES
+)
+
+if(NOT BUILD_TESTING)
+ target_sources("kstd" PRIVATE
+ "src/libc/stdlib.cpp"
+ "src/libc/string.cpp"
+ )
+
+ set(KSTD_LIBC_SYMBOLS
+ "abort"
+ "strlen"
+ "memcmp"
+ "memcpy"
+ )
+
list(TRANSFORM KSTD_LIBC_SYMBOLS PREPEND "-Wl,--undefined=")
target_link_options("kstd" INTERFACE ${KSTD_LIBC_SYMBOLS})
-else()
- add_executable("kstd_tests"
+endif()
+
+#[============================================================================[
+# Tests
+#]============================================================================]
+
+if(BUILD_TESTING)
+ add_executable("kstd_tests")
+ add_executable("kstd::tests" ALIAS "kstd_tests")
+
+ target_sources("kstd_tests" PRIVATE
"tests/src/flat_map.cpp"
"tests/src/format.cpp"
"tests/src/vector.cpp"
@@ -57,7 +104,7 @@ else()
target_link_libraries("kstd_tests" PRIVATE
"Catch2::Catch2WithMain"
- "libs::kstd"
+ "kstd::lib"
)
set_target_properties("kstd_tests" PROPERTIES
@@ -66,8 +113,10 @@ else()
EXCLUDE_FROM_ALL NO
)
- enable_coverage("kstd")
- enable_coverage("kstd_tests")
+ if(COMMAND "enable_coverage")
+ enable_coverage("kstd")
+ enable_coverage("kstd_tests")
+ endif()
- catch_discover_tests("kstd_tests")
+ catch_discover_tests("kstd::tests")
endif() \ No newline at end of file
diff --git a/libs/multiboot2/CMakeLists.txt b/libs/multiboot2/CMakeLists.txt
index 7384a3d..b56b0ba 100644
--- a/libs/multiboot2/CMakeLists.txt
+++ b/libs/multiboot2/CMakeLists.txt
@@ -1,7 +1,46 @@
+cmake_minimum_required(VERSION "3.27.0")
+
+project("multiboot2"
+ DESCRIPTION "Multiboot2 bootloader specification library"
+ VERSION "0.0.1"
+ LANGUAGES CXX
+)
+
+include("CTest")
+
+#[============================================================================[
+# External Dependencies
+#]============================================================================]
+
+include("FetchContent")
+
+if (BUILD_TESTING)
+ FetchContent_Declare(
+ "Catch2"
+ URL "https://github.com/catchorg/Catch2/archive/refs/tags/v3.7.1.tar.gz"
+ URL_HASH "SHA256=c991b247a1a0d7bb9c39aa35faf0fe9e19764213f28ffba3109388e62ee0269c"
+ EXCLUDE_FROM_ALL
+ FIND_PACKAGE_ARGS
+ )
+
+ FetchContent_MakeAvailable("Catch2")
+
+ find_package("Catch2")
+ include("Catch")
+endif()
+
+#[============================================================================[
+# Library
+#]============================================================================]
+
add_library("multiboot2" INTERFACE)
-add_library("libs::multiboot2" ALIAS "multiboot2")
+add_library("multiboot2::lib" ALIAS "multiboot2")
-file(GLOB_RECURSE MULTIBOOT2_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "include/**.hpp")
+file(GLOB_RECURSE MULTIBOOT2_HEADERS
+ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
+ CONFIGURE_DEPENDS
+ "include/**.hpp"
+)
target_sources("multiboot2" INTERFACE
FILE_SET HEADERS
@@ -15,10 +54,10 @@ target_include_directories("multiboot2" INTERFACE
)
target_link_libraries("multiboot2" INTERFACE
- "libs::elf"
- "libs::kstd"
+ "elf::lib"
+ "kstd::lib"
)
set_target_properties("multiboot2" PROPERTIES
VERIFY_INTERFACE_HEADER_SETS YES
-) \ No newline at end of file
+)