aboutsummaryrefslogtreecommitdiff
path: root/libs/kstd/CMakeLists.txt
diff options
context:
space:
mode:
authorLukas Oesch <lukas.oesch@ost.ch>2026-06-10 10:40:46 +0200
committerLukas Oesch <lukas.oesch@ost.ch>2026-06-10 10:40:46 +0200
commit33abd5cf264cb9e34121082105b0bc17b3cf7a36 (patch)
tree36b15d53fea04f4f9d9af817100f7ad013bd9b5c /libs/kstd/CMakeLists.txt
parentd01caf1c4aef3c89c68b9d1cc9fe56445f0860b5 (diff)
parent7e27130c342b7299a1d2188a7192a7f17b5ac2ad (diff)
downloadkernel-33abd5cf264cb9e34121082105b0bc17b3cf7a36.tar.xz
kernel-33abd5cf264cb9e34121082105b0bc17b3cf7a36.zip
Merge branch 'develop-BA-FS26' into 'develop'HEADdevelop
Merge of BA-FS26 branch into develop See merge request teachos/kernel!49
Diffstat (limited to 'libs/kstd/CMakeLists.txt')
-rw-r--r--libs/kstd/CMakeLists.txt117
1 files changed, 84 insertions, 33 deletions
diff --git a/libs/kstd/CMakeLists.txt b/libs/kstd/CMakeLists.txt
index 1f140f6..0f64761 100644
--- a/libs/kstd/CMakeLists.txt
+++ b/libs/kstd/CMakeLists.txt
@@ -1,49 +1,100 @@
-add_library("kstd" STATIC)
-add_library("libs::kstd" ALIAS "kstd")
+cmake_minimum_required(VERSION "3.27.0")
-set(KSTD_LIBC_SYMBOLS
- "abort"
- "strlen"
- "memcmp"
+project("kstd"
+ DESCRIPTION "A kernel STL implementation"
+ VERSION "0.0.1"
+ LANGUAGES CXX
)
-target_sources("kstd" PRIVATE
- "src/libc/stdlib.cpp"
- "src/libc/string.cpp"
+include("CTest")
+
+#[============================================================================[
+# Library
+#]============================================================================]
+
+add_library("kstd" STATIC)
+add_library("kstd::lib" ALIAS "kstd")
- "src/os/error.cpp"
+target_sources("kstd" PRIVATE
+ "kstd/os/error.cpp"
+ "kstd/mutex.cpp"
+ "kstd/vformat.cpp"
+)
- "src/mutex.cpp"
+file(GLOB_RECURSE KSTD_HEADERS
+ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
+ CONFIGURE_DEPENDS
+ "kstd/*"
)
+list(FILTER KSTD_HEADERS EXCLUDE REGEX ".*\.cpp")
+
target_sources("kstd" PUBLIC
FILE_SET HEADERS
- BASE_DIRS "include"
+ BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}"
FILES
- "include/kstd/bits/format_context.hpp"
- "include/kstd/bits/format_specs.hpp"
- "include/kstd/bits/format_string.hpp"
- "include/kstd/bits/formatter.hpp"
- "include/kstd/bits/shared_ptr.hpp"
- "include/kstd/bits/unique_ptr.hpp"
-
- "include/kstd/ext/bitfield_enum"
-
- "include/kstd/os/error.hpp"
- "include/kstd/os/print.hpp"
-
- "include/kstd/asm_ptr"
- "include/kstd/format"
- "include/kstd/memory"
- "include/kstd/mutex"
- "include/kstd/stack"
- "include/kstd/vector"
+ ${KSTD_HEADERS}
)
target_include_directories("kstd" PUBLIC
- "include"
+ "${CMAKE_CURRENT_SOURCE_DIR}"
+)
+
+set_target_properties("kstd" PROPERTIES
+ VERIFY_INTERFACE_HEADER_SETS YES
)
-list(TRANSFORM KSTD_LIBC_SYMBOLS PREPEND "-Wl,--undefined=")
+if(NOT BUILD_TESTING)
+ target_sources("kstd" PRIVATE
+ "kstd/libc/stdlib.cpp"
+ "kstd/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})
+endif()
+
+#[============================================================================[
+# Tests
+#]============================================================================]
+
+if(BUILD_TESTING)
+ find_package("Catch2")
+ include("Catch")
+
+ add_executable("kstd_tests")
+ add_executable("kstd::tests" ALIAS "kstd_tests")
+
+ target_sources("kstd_tests" PRIVATE
+ "kstd/flat_map.test.cpp"
+ "kstd/format.test.cpp"
+ "kstd/vector.test.cpp"
+ "kstd/bits/observer_ptr.test.cpp"
+ "kstd/test_support/os_panic.test.cpp"
+ "kstd/string.test.cpp"
+ )
+
+ target_link_libraries("kstd_tests" PRIVATE
+ "Catch2::Catch2WithMain"
+ "kstd::lib"
+ )
+
+ set_target_properties("kstd_tests" PROPERTIES
+ EXCLUDE_FROM_ALL NO
+ )
+
+ if(COMMAND "enable_coverage")
+ enable_coverage("kstd")
+ enable_coverage("kstd_tests")
+ endif()
-target_link_options("kstd" INTERFACE ${KSTD_LIBC_SYMBOLS}) \ No newline at end of file
+ catch_discover_tests("kstd::tests" ${CATCH_TEST_ARGS})
+endif() \ No newline at end of file