Files
Aethera/kernel/main.cmake
T
2026-08-31 18:03:39 +08:00

95 lines
4.3 KiB
CMake

include(${CMAKE_CURRENT_LIST_DIR}/cmake/rely.cmake)
set(Aethera_Kernel_dependencies global::proxy aethera_kernel::taskflow global::magic_enum)
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})
find_package(Threads REQUIRED)
find_package(Taskflow CONFIG REQUIRED)
find_package(magic_enum CONFIG REQUIRED)
find_package(msft_proxy4 4.1 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_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_sources "${Aethera_Kernel_source_dir}")
add_library(Aethera_Kernel STATIC ${Aethera_Kernel_sources})
target_include_directories(Aethera_Kernel PUBLIC
"$<BUILD_INTERFACE:${Aethera_Kernel_source_dir}>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/third_party>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/third_party/ratas-master/src>"
)
target_compile_features(Aethera_Kernel PUBLIC cxx_std_20)
target_link_libraries(Aethera_Kernel PUBLIC
Taskflow::Taskflow
magic_enum::magic_enum
msft_proxy4::proxy
"$<BUILD_INTERFACE:concurrentqueue>"
)
target_link_libraries(Aethera_Kernel PRIVATE Threads::Threads)
if (MSVC)
target_compile_options(Aethera_Kernel PUBLIC /utf-8)
endif ()
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
GTest::gmock)
append_glob_source(Aethera_Kernel_module_test_sources
"${Aethera_Kernel_test_dir}/concurrent"
"${Aethera_Kernel_test_dir}/model"
"${Aethera_Kernel_test_dir}/task_flow"
"${Aethera_Kernel_test_dir}/time_thread"
"${Aethera_Kernel_test_dir}/function/frame_policy")
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
GTest::gmock)
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 ()