编译过

This commit is contained in:
2026-08-20 14:45:12 +08:00
parent f379907f1b
commit 44af33bee6
14 changed files with 991 additions and 293 deletions
+13 -43
View File
@@ -1,5 +1,6 @@
include(${CMAKE_CURRENT_LIST_DIR}/cmake/rely.cmake)
set(Aethera_Kernel_dependencies aethera_kernel::taskflow global::magic_enum global::expected)
set(Aethera_BUILD_TESTS TRUE)
if (Aethera_BUILD_TESTS)
set(Aethera_Kernel_test_targets)
list(APPEND Aethera_Kernel_dependencies global::GTest)
@@ -22,7 +23,6 @@ endif ()
set(Aethera_Kernel_source_dir "${CMAKE_CURRENT_LIST_DIR}/src/kernel")
append_glob_source(Aethera_Kernel_sources "${Aethera_Kernel_source_dir}")
add_library(Aethera_Kernel STATIC ${Aethera_Kernel_sources})
add_library(Renderive::Kernel ALIAS Aethera_Kernel)
set_target_properties(Aethera_Kernel PROPERTIES EXPORT_NAME Kernel)
target_include_directories(Aethera_Kernel PUBLIC
"$<BUILD_INTERFACE:${Aethera_Kernel_source_dir}>"
@@ -35,21 +35,20 @@ target_link_libraries(Aethera_Kernel PUBLIC
tl::expected
)
target_link_libraries(Aethera_Kernel PRIVATE Threads::Threads)
function(Aethera_stage_kernel_runtime target)
if (WIN32)
add_custom_command(TARGET "${target}" POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"$<TARGET_FILE:TBB::tbb>"
"$<TARGET_FILE_DIR:${target}>"
COMMENT "Staging oneTBB runtime for ${target}"
VERBATIM)
endif ()
endfunction()
if (MSVC)
target_compile_options(Aethera_Kernel PRIVATE /utf-8)
target_compile_options(Aethera_Kernel PUBLIC /utf-8)
endif ()
if (Aethera_BUILD_TESTS)
set(Aethera_Kernel_test_dir "${CMAKE_CURRENT_LIST_DIR}/src/test")
append_glob_source(Aethera_Kernel_test_sources "${Aethera_Kernel_test_dir}")
add_executable(Aethera_Kernel_exe ${Aethera_Kernel_test_sources})
target_link_libraries(Aethera_Kernel_exe PRIVATE Aethera_Kernel GTest::gtest)
add_test(NAME Aethera_Kernel_exe COMMAND Aethera_Kernel_exe)
set_tests_properties(Aethera_Kernel_exe PROPERTIES
LABELS "Aethera_Kernel"
ENVIRONMENT "Aethera_ERROR_MODE=exception")
list(APPEND Aethera_Kernel_test_targets Aethera_Kernel_exe)
endif ()
add_executable(Aethera_Kernel_exe "${CMAKE_CURRENT_LIST_DIR}/src/test/main.cpp")
target_link_libraries(Aethera_Kernel_exe PRIVATE Aethera_Kernel)
install(TARGETS Aethera_Kernel
EXPORT RenderiveTargets
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
@@ -59,35 +58,6 @@ install(DIRECTORY "${Aethera_Kernel_source_dir}/renderive"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" PATTERN "*.inl")
if (Aethera_BUILD_TESTS)
set(Aethera_Kernel_test_dir "${CMAKE_CURRENT_LIST_DIR}/tests")
append_glob_source(Aethera_Kernel_test_sources "${Aethera_Kernel_test_dir}")
# Concrete 2D/3D scene tests belong to their owning modules. The former
# header-only Scene_Context fixtures were removed with the Builder-based
# scene API, so Kernel's suite must remain independently linkable.
list(FILTER Aethera_Kernel_test_sources EXCLUDE REGEX
"(Real_Time_Data_Test|Renderable_Base_Test|Color_Cache_Test|Renderable_Test|Scene_Base_Test|Scene_Test|Dynamic_Renderable_Lifecycle_Test|Render_Plan_Execution_Test|Scene_Inheritance_Test|Scene_Memory_Resource_Test|Scene_State_Observer_Test|Scene2D_Context_Test|Scene2D_Render_Order_Test|Scene3D_Context_Test|Threading_Contract_Test)\\.cpp$")
foreach (Aethera_Kernel_test_source IN LISTS Aethera_Kernel_test_sources)
if (NOT Aethera_Kernel_test_source MATCHES "\\.(c|cc|cpp|cxx)$")
continue()
endif ()
file(RELATIVE_PATH Aethera_Kernel_test_name "${Aethera_Kernel_test_dir}" "${Aethera_Kernel_test_source}")
string(REGEX REPLACE "\\.[^.]+$" "" Aethera_Kernel_test_name "${Aethera_Kernel_test_name}")
string(MAKE_C_IDENTIFIER "${Aethera_Kernel_test_name}" Aethera_Kernel_test_name)
set(Aethera_Kernel_test_target "Aethera_Kernel_${Aethera_Kernel_test_name}")
add_executable("${Aethera_Kernel_test_target}" "${Aethera_Kernel_test_source}")
target_include_directories("${Aethera_Kernel_test_target}" PRIVATE
"${Aethera_Kernel_test_dir}"
"${CMAKE_CURRENT_LIST_DIR}/../render_2D"
"${CMAKE_CURRENT_LIST_DIR}/../render_3D"
)
target_link_libraries("${Aethera_Kernel_test_target}" PRIVATE Aethera_Kernel GTest::gtest_main)
Aethera_stage_kernel_runtime("${Aethera_Kernel_test_target}")
add_test(NAME "${Aethera_Kernel_test_target}" COMMAND "${Aethera_Kernel_test_target}")
set_tests_properties("${Aethera_Kernel_test_target}" PROPERTIES
LABELS "Aethera_Kernel"
ENVIRONMENT "Aethera_ERROR_MODE=exception")
list(APPEND Aethera_Kernel_test_targets "${Aethera_Kernel_test_target}")
endforeach ()
add_custom_target(Aethera_Kernel_check
COMMAND "${CMAKE_CTEST_COMMAND}" --test-dir "${CMAKE_BINARY_DIR}"
-C "$<CONFIG>" -L "^Aethera_Kernel$" --output-on-failure