feat: Enhance modular build support and update Abseil integration for macOS

This commit is contained in:
scawful
2025-10-03 19:10:59 -04:00
parent c3eaace72c
commit c9f439207e
6 changed files with 59 additions and 23 deletions

View File

@@ -126,6 +126,17 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "Windows")
endif() endif()
# Abseil provider selection: default to bundled libraries on macOS to avoid
# deployment target mismatches with system packages, but let other platforms
# use their package managers unless overridden.
set(_yaze_default_force_absl OFF)
if(YAZE_PLATFORM_MACOS)
set(_yaze_default_force_absl ON)
endif()
option(YAZE_FORCE_BUNDLED_ABSL
"Force building the bundled Abseil submodule instead of finding a system package"
${_yaze_default_force_absl})
# Create a common interface target for shared settings # Create a common interface target for shared settings
add_library(yaze_common INTERFACE) add_library(yaze_common INTERFACE)
target_compile_features(yaze_common INTERFACE cxx_std_23) target_compile_features(yaze_common INTERFACE cxx_std_23)

View File

@@ -18,7 +18,8 @@
"YAZE_BUILD_APP": "ON", "YAZE_BUILD_APP": "ON",
"YAZE_BUILD_LIB": "ON", "YAZE_BUILD_LIB": "ON",
"YAZE_BUILD_EMU": "OFF", "YAZE_BUILD_EMU": "OFF",
"YAZE_BUILD_Z3ED": "ON" "YAZE_BUILD_Z3ED": "ON",
"YAZE_USE_MODULAR_BUILD": "ON"
} }
}, },
{ {

View File

@@ -1,4 +1,10 @@
if (MINGW OR WIN32) # Normalize Abseil's hardware AES flags when targeting macOS ARM64 only.
if(APPLE AND DEFINED CMAKE_OSX_ARCHITECTURES AND CMAKE_OSX_ARCHITECTURES STREQUAL "arm64")
set(ABSL_RANDOM_HWAES_X64_FLAGS "" CACHE STRING "" FORCE)
set(ABSL_RANDOM_HWAES_ARM64_FLAGS "-march=armv8-a+crypto" CACHE STRING "" FORCE)
endif()
if (MINGW OR WIN32 OR YAZE_FORCE_BUNDLED_ABSL)
add_subdirectory(src/lib/abseil-cpp) add_subdirectory(src/lib/abseil-cpp)
elseif(YAZE_MINIMAL_BUILD) elseif(YAZE_MINIMAL_BUILD)
# For CI builds, always use submodule to avoid dependency issues # For CI builds, always use submodule to avoid dependency issues
@@ -62,3 +68,31 @@ if(NOT WIN32)
else() else()
message(STATUS "Excluding absl::int128 on Windows to avoid C++23 deprecation issues") message(STATUS "Excluding absl::int128 on Windows to avoid C++23 deprecation issues")
endif() endif()
if(APPLE AND DEFINED CMAKE_OSX_ARCHITECTURES AND CMAKE_OSX_ARCHITECTURES STREQUAL "arm64")
foreach(_absl_target IN ITEMS absl_random_internal_randen_hwaes absl_random_internal_randen_hwaes_impl)
if(TARGET ${_absl_target})
get_target_property(_absl_opts ${_absl_target} COMPILE_OPTIONS)
if(NOT _absl_opts STREQUAL "NOTFOUND")
set(_absl_filtered_opts "")
set(_absl_skip_next FALSE)
foreach(_absl_opt IN LISTS _absl_opts)
if(_absl_skip_next)
set(_absl_skip_next FALSE)
continue()
endif()
if(_absl_opt STREQUAL "-Xarch_x86_64")
set(_absl_skip_next TRUE)
continue()
endif()
if(_absl_opt STREQUAL "-maes" OR _absl_opt STREQUAL "-msse4.1")
continue()
endif()
list(APPEND _absl_filtered_opts "${_absl_opt}")
endforeach()
set_target_properties(${_absl_target} PROPERTIES COMPILE_OPTIONS "${_absl_filtered_opts}")
endif()
target_compile_options(${_absl_target} PRIVATE "-Xarch_arm64" "-march=armv8-a+crypto")
endif()
endforeach()
endif()

View File

@@ -99,22 +99,21 @@ else()
endif() endif()
if(YAZE_USE_MODULAR_BUILD) if(YAZE_USE_MODULAR_BUILD)
target_link_libraries(yaze PRIVATE set(_yaze_modular_links yaze_editor)
yaze_util
yaze_gfx
yaze_gui
yaze_zelda3
yaze_core_lib
yaze_editor
)
if(TARGET yaze_agent) if(TARGET yaze_agent)
target_link_libraries(yaze PRIVATE yaze_agent) list(APPEND _yaze_modular_links yaze_agent)
endif() endif()
if(YAZE_BUILD_EMU AND NOT YAZE_WITH_GRPC AND TARGET yaze_emulator) if(YAZE_BUILD_EMU AND NOT YAZE_WITH_GRPC AND TARGET yaze_emulator)
target_link_libraries(yaze PRIVATE yaze_emulator) list(APPEND _yaze_modular_links yaze_emulator)
endif() endif()
# Link once against the editor library and allow its PUBLIC dependencies
# (core, gfx, util, absl, etc.) to propagate transitively. This avoids
# duplicate static archives on the link line while keeping absl symbols
# available for main and other entry points.
target_link_libraries(yaze PRIVATE ${_yaze_modular_links})
else() else()
target_link_libraries(yaze PRIVATE yaze_core) target_link_libraries(yaze PRIVATE yaze_core)
endif() endif()

View File

@@ -35,6 +35,7 @@ target_link_libraries(yaze_core_lib PUBLIC
yaze_util yaze_util
yaze_gfx yaze_gfx
yaze_common yaze_common
ImGui
asar-static asar-static
${ABSL_TARGETS} ${ABSL_TARGETS}
${SDL_TARGETS} ${SDL_TARGETS}

View File

@@ -121,24 +121,14 @@ target_include_directories(
if(YAZE_USE_MODULAR_BUILD) if(YAZE_USE_MODULAR_BUILD)
target_link_libraries( target_link_libraries(
z3ed PRIVATE z3ed PRIVATE
yaze_util yaze_core
yaze_gfx
yaze_zelda3
yaze_core_lib
yaze_agent
ftxui::component ftxui::component
ftxui::screen
ftxui::dom
absl::flags
absl::flags_parse
) )
else() else()
target_link_libraries( target_link_libraries(
z3ed PRIVATE z3ed PRIVATE
yaze_core yaze_core
ftxui::component ftxui::component
ftxui::screen
ftxui::dom
absl::flags absl::flags
absl::flags_parse absl::flags_parse
) )