Files
2026-09-04 22:35:59 +08:00

103 lines
4.7 KiB
CMake

rcl_init(aethera_kernel)
include(${CMAKE_CURRENT_LIST_DIR}/cmake/taskflow.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/cmake/tracy.cmake)
set(Aethera_Kernel_dependencies global::proxy aethera_kernel::taskflow global::magic_enum global::pfr)
set(Aethera_BUILD_TESTS TRUE)
if (Aethera_BUILD_TESTS)
enable_testing()
set(Aethera_Kernel_test_targets)
list(APPEND Aethera_Kernel_dependencies
global::GTest
global::benchmark
)
endif ()
rcl_add_dependency_action_targets(Aethera_Kernel_env ${Aethera_Kernel_dependencies})
library_get_missing_with_rely(Aethera_Kernel_dependencies_installed ${Aethera_Kernel_dependencies})
if (Aethera_Kernel_dependencies_installed)
rcl_log_append(${CMAKE_CURRENT_LIST_LINE} "[FATAL_ERROR] Aethera_Kernel dependencies are not installed. Build Aethera_Kernel_env first")
return()
endif ()
rcl_load_dependency_environment(${Aethera_Kernel_dependencies})
#option(TRACY_ENABLE "" ON)
find_package(Threads REQUIRED)
find_package(Taskflow CONFIG REQUIRED)
find_package(magic_enum CONFIG REQUIRED)
find_package(msft_proxy4 4.1 CONFIG REQUIRED)
find_package(Tracy CONFIG REQUIRED)
if (Aethera_BUILD_TESTS)
find_package(GTest CONFIG REQUIRED)
find_package(benchmark CONFIG REQUIRED)
endif ()
set(Aethera_Kernel_source_dir "${CMAKE_CURRENT_LIST_DIR}/kernel/include")
set(Aethera_Kernel_module_dir "${CMAKE_CURRENT_LIST_DIR}/kernel/module")
set(Aethera_concurrentqueue_dir "${CMAKE_CURRENT_LIST_DIR}/third_party/concurrentqueue-1.0.5")
add_subdirectory("${Aethera_concurrentqueue_dir}"
"${CMAKE_CURRENT_BINARY_DIR}/aethera_concurrentqueue" EXCLUDE_FROM_ALL)
append_glob_source(Aethera_Kernel_Core_sources "${Aethera_Kernel_source_dir}")
add_library(Aethera_Kernel_Core STATIC ${Aethera_Kernel_Core_sources})
target_include_directories(Aethera_Kernel_Core PUBLIC
"$<BUILD_INTERFACE:${Aethera_Kernel_source_dir}>"
"$<BUILD_INTERFACE:${EXTERNAL_DIR}/source/pfr/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/third_party>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/third_party/ratas-master/src>"
)
target_compile_features(Aethera_Kernel_Core PUBLIC cxx_std_20)
target_link_libraries(Aethera_Kernel_Core PUBLIC
magic_enum::magic_enum
msft_proxy4::proxy
Tracy::TracyClient
"$<BUILD_INTERFACE:concurrentqueue>"
)
if (MSVC)
target_compile_options(Aethera_Kernel_Core PUBLIC /utf-8)
endif ()
include("${Aethera_Kernel_module_dir}/main.cmake")
add_library(Aethera_Kernel INTERFACE)
target_link_libraries(Aethera_Kernel INTERFACE
Aethera_Kernel_Core
Aethera_Kernel_Task_Flow
Aethera_Kernel_Time_Thread
Aethera_Kernel_Renderable
Aethera_Kernel_Scene
Aethera_Kernel_Frame_Policy)
if (Aethera_BUILD_TESTS)
set(Aethera_Kernel_test_dir "${CMAKE_CURRENT_LIST_DIR}/kernel/test")
set(Aethera_Kernel_cdb
"D:/ae/ewdk/EWDK_22621_230929-1800/Program Files/Windows Kits/10/Debuggers/x64/cdb.exe")
add_executable(Aethera_Kernel_exe "${Aethera_Kernel_test_dir}/main.cpp")
target_link_libraries(Aethera_Kernel_exe PRIVATE
Aethera_Kernel
GTest::gtest)
append_glob_source(Aethera_Kernel_module_test_sources
"${Aethera_Kernel_test_dir}/error"
"${Aethera_Kernel_test_dir}/model")
foreach (Aethera_Kernel_module_test_source IN LISTS Aethera_Kernel_module_test_sources)
if (NOT Aethera_Kernel_module_test_source MATCHES "\\.(c|cc|cpp|cxx)$")
continue()
endif ()
get_filename_component(Aethera_Kernel_module_test_name
"${Aethera_Kernel_module_test_source}" NAME_WE)
set(Aethera_Kernel_module_test_target
"Aethera_Kernel_${Aethera_Kernel_module_test_name}")
add_executable("${Aethera_Kernel_module_test_target}"
"${Aethera_Kernel_module_test_source}")
target_link_libraries("${Aethera_Kernel_module_test_target}" PRIVATE
Aethera_Kernel
GTest::gtest_main)
add_test(NAME "${Aethera_Kernel_module_test_target}"
COMMAND "${Aethera_Kernel_cdb}" -c "g;q"
"$<TARGET_FILE:${Aethera_Kernel_module_test_target}>")
set_tests_properties("${Aethera_Kernel_module_test_target}" PROPERTIES
LABELS "Aethera_Kernel")
list(APPEND Aethera_Kernel_test_targets
"${Aethera_Kernel_module_test_target}")
endforeach ()
endif ()
if (Aethera_BUILD_TESTS)
add_custom_target(Aethera_Kernel_check
COMMAND "${CMAKE_CTEST_COMMAND}" --test-dir "${CMAKE_BINARY_DIR}"
-C "$<CONFIG>" -L "^Aethera_Kernel$" --output-on-failure
DEPENDS ${Aethera_Kernel_test_targets}
USES_TERMINAL)
endif ()