aboutsummaryrefslogtreecommitdiff
path: root/libs/acpi/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'libs/acpi/CMakeLists.txt')
-rw-r--r--libs/acpi/CMakeLists.txt67
1 files changed, 64 insertions, 3 deletions
diff --git a/libs/acpi/CMakeLists.txt b/libs/acpi/CMakeLists.txt
index c6e63b9..55d5b54 100644
--- a/libs/acpi/CMakeLists.txt
+++ b/libs/acpi/CMakeLists.txt
@@ -1,3 +1,11 @@
+cmake_minimum_required(VERSION "3.27.0")
+
+project("acpi"
+ DESCRIPTION "An ACPI parsing library"
+ VERSION "0.0.1"
+ LANGUAGES ASM CXX
+)
+
add_library("acpi" STATIC)
add_library("libs::acpi" ALIAS "acpi")
@@ -11,10 +19,12 @@ file(GLOB_RECURSE ACPI_HEADERS
)
target_sources("acpi" PRIVATE
- "acpi/checksum.cpp"
- "acpi/madt.cpp"
+ "acpi/common/checksum.cpp"
+ "acpi/common/table_header.cpp"
+ "acpi/data/madt.cpp"
+ "acpi/data/rsdt.cpp"
+ "acpi/data/xsdt.cpp"
"acpi/pointers.cpp"
- "acpi/sdt.cpp"
)
target_sources("acpi" PUBLIC
@@ -27,3 +37,54 @@ target_sources("acpi" PUBLIC
target_link_libraries("acpi" PUBLIC
"libs::kstd"
)
+
+if(NOT CMAKE_CROSSCOMPILING)
+ find_program(IASL_EXE NAMES "iasl" REQUIRED)
+
+ set(TEST_TABLES
+ "basic_madt"
+ "basic_rsdt"
+ "basic_rsdp"
+ "basic_xsdt"
+ "table_header"
+ )
+
+ foreach(TABLE IN LISTS TEST_TABLES)
+ add_custom_command(OUTPUT "test_data/${TABLE}.aml"
+ COMMAND "${IASL_EXE}" -p "test_data/${TABLE}.aml" "${CMAKE_CURRENT_SOURCE_DIR}/test_data/${TABLE}.asl"
+ DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/test_data/${TABLE}.asl"
+ COMMENT "Compiling test_data/${TABLE}.asl"
+ VERBATIM
+ )
+ list(APPEND GENERATED_TABLE_BLOBS "${CMAKE_CURRENT_BINARY_DIR}/test_data/${TABLE}.aml")
+ endforeach()
+
+ set_source_files_properties("test_data/tables.S" PROPERTIES OBJECT_DEPENDS "${GENERATED_TABLE_BLOBS}")
+
+ add_executable("acpi_tests"
+ "acpi/common/table_header.test.cpp"
+ "acpi/data/madt.test.cpp"
+ "acpi/data/rsdt.test.cpp"
+ "acpi/data/xsdt.test.cpp"
+ "acpi/pointers.test.cpp"
+
+ "test_data/tables.S"
+ )
+
+ target_include_directories("acpi_tests" PRIVATE
+ "${CMAKE_CURRENT_BINARY_DIR}/test_data"
+ )
+
+ target_link_libraries("acpi_tests" PRIVATE
+ "Catch2::Catch2WithMain"
+ "libs::acpi"
+ )
+
+ set_target_properties("acpi_tests" PROPERTIES
+ C_CLANG_TIDY ""
+ CXX_CLANG_TIDY ""
+ EXCLUDE_FROM_ALL NO
+ )
+
+ catch_discover_tests("acpi_tests")
+endif()