fix(macos): resolve z3ed linker error by ensuring yaze_app_core_lib is always built

Root Cause:
The z3ed CLI tool (via yaze_agent) depends on yaze_app_core_lib, but this
library was only being created when YAZE_BUILD_APP=ON (which doesn't exist -
should be YAZE_BUILD_GUI). When building z3ed standalone with tests
(YAZE_BUILD_Z3ED=ON, YAZE_BUILD_GUI=OFF), the linker failed with:
  ld: library 'yaze_app_core_lib' not found
  clang: error: linker command failed with exit code 1

Changes:
1. Created src/app/app_core.cmake: Contains only yaze_app_core_lib creation
2. Modified src/app/app.cmake: Now includes app_core.cmake, then conditionally
   builds the yaze executable only when YAZE_BUILD_GUI=ON
3. Modified src/CMakeLists.txt: Include app/app.cmake whenever agent features
   are needed (YAZE_BUILD_GUI OR YAZE_BUILD_Z3ED OR YAZE_BUILD_TESTS), ensuring
   yaze_app_core_lib is always available before yaze_agent is built

Impact:
- macOS CI builds will now succeed (z3ed can link properly)
- No impact on existing GUI builds (yaze executable still built correctly)
- No impact on Windows/Linux (same dependency structure applies)
- Cleaner separation: library (always) vs executable (conditional)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
scawful
2025-11-20 01:46:02 -05:00
parent e36d81f357
commit 9c562df277
3 changed files with 157 additions and 141 deletions

View File

@@ -82,7 +82,13 @@ if(YAZE_ENABLE_REMOTE_AUTOMATION)
endif()
# Include agent/CLI components (needed by yaze_editor for agent features)
if(YAZE_BUILD_APP OR YAZE_BUILD_Z3ED OR YAZE_BUILD_TESTS)
# NOTE: yaze_agent depends on yaze_app_core_lib, so we must include app.cmake
# BEFORE cli/agent.cmake when building agent features
if(YAZE_BUILD_GUI OR YAZE_BUILD_Z3ED OR YAZE_BUILD_TESTS)
include(app/app.cmake)
endif()
if(YAZE_BUILD_GUI OR YAZE_BUILD_Z3ED OR YAZE_BUILD_TESTS)
include(cli/agent.cmake)
endif()
@@ -90,11 +96,6 @@ endif()
include(app/editor/editor_library.cmake)
include(app/emu/emu_library.cmake)
# Build main application
if(YAZE_BUILD_APP)
include(app/app.cmake)
endif()
# Build standalone emulator
if(YAZE_BUILD_EMU)
include(app/emu/emu.cmake)

View File

@@ -1,140 +1,19 @@
# ==============================================================================
# Application Core Library (Platform, Controller, ROM, Services)
# Application Core Library and GUI Executable
# ==============================================================================
# This library contains application-level core components:
# - ROM management (app/rom.cc)
# - Application controller (app/controller.cc)
# - Window/platform management (app/platform/)
# - gRPC services for AI automation (app/service/)
#
# Dependencies: yaze_core_lib (foundational), yaze_util, yaze_gfx, SDL2, ImGui
# This file builds:
# 1. yaze_app_core_lib (always, when included)
# 2. yaze executable (GUI application, only when YAZE_BUILD_GUI=ON)
# ==============================================================================
set(
YAZE_APP_CORE_SRC
app/rom.cc
app/controller.cc
app/platform/window.cc
)
# Always create the application core library (needed by yaze_agent)
include(app/app_core.cmake)
# Platform-specific sources
if (WIN32 OR MINGW OR (UNIX AND NOT APPLE))
list(APPEND YAZE_APP_CORE_SRC
app/platform/font_loader.cc
app/platform/asset_loader.cc
app/platform/file_dialog_nfd.cc # NFD file dialog for Windows/Linux
)
# Only build GUI executable when explicitly requested
if(NOT YAZE_BUILD_GUI)
return()
endif()
if(APPLE)
list(APPEND YAZE_APP_CORE_SRC
app/platform/font_loader.cc
app/platform/asset_loader.cc
)
set(YAZE_APPLE_OBJCXX_SRC
app/platform/file_dialog.mm
app/platform/app_delegate.mm
app/platform/font_loader.mm
)
add_library(yaze_app_objcxx OBJECT ${YAZE_APPLE_OBJCXX_SRC})
set_target_properties(yaze_app_objcxx PROPERTIES
OBJCXX_STANDARD 20
OBJCXX_STANDARD_REQUIRED ON
)
target_include_directories(yaze_app_objcxx PUBLIC
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/src/app
${CMAKE_SOURCE_DIR}/ext
${CMAKE_SOURCE_DIR}/ext/imgui
${CMAKE_SOURCE_DIR}/incl
${PROJECT_BINARY_DIR}
)
target_link_libraries(yaze_app_objcxx PUBLIC ${ABSL_TARGETS} yaze_util ${YAZE_SDL2_TARGETS})
target_compile_definitions(yaze_app_objcxx PUBLIC MACOS)
find_library(COCOA_LIBRARY Cocoa)
if(NOT COCOA_LIBRARY)
message(FATAL_ERROR "Cocoa not found")
endif()
set(CMAKE_EXE_LINKER_FLAGS "-framework ServiceManagement -framework Foundation -framework Cocoa")
endif()
# Create the application core library
add_library(yaze_app_core_lib STATIC
${YAZE_APP_CORE_SRC}
$<$<BOOL:${APPLE}>:$<TARGET_OBJECTS:yaze_app_objcxx>>
)
target_precompile_headers(yaze_app_core_lib PRIVATE
"$<$<COMPILE_LANGUAGE:CXX>:${CMAKE_SOURCE_DIR}/src/yaze_pch.h>"
)
target_include_directories(yaze_app_core_lib PUBLIC
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/src/app
${CMAKE_SOURCE_DIR}/ext
${CMAKE_SOURCE_DIR}/ext/imgui
${CMAKE_SOURCE_DIR}/incl
${SDL2_INCLUDE_DIR}
${PROJECT_BINARY_DIR}
)
target_link_libraries(yaze_app_core_lib PUBLIC
yaze_core_lib # Foundational core library with project management
yaze_util
yaze_gfx
yaze_zelda3
yaze_common
ImGui
${ABSL_TARGETS}
${YAZE_SDL2_TARGETS}
${CMAKE_DL_LIBS}
)
# Link nativefiledialog-extended for Windows/Linux file dialogs
if(WIN32 OR (UNIX AND NOT APPLE))
add_subdirectory(${CMAKE_SOURCE_DIR}/ext/nativefiledialog-extended ${CMAKE_BINARY_DIR}/nfd EXCLUDE_FROM_ALL)
target_link_libraries(yaze_app_core_lib PUBLIC nfd)
target_include_directories(yaze_app_core_lib PUBLIC ${CMAKE_SOURCE_DIR}/ext/nativefiledialog-extended/src/include)
endif()
# gRPC Services (Optional)
if(YAZE_WITH_GRPC)
target_include_directories(yaze_app_core_lib PRIVATE
${CMAKE_SOURCE_DIR}/ext/json/include)
target_compile_definitions(yaze_app_core_lib PRIVATE YAZE_WITH_JSON)
# Link to consolidated gRPC support library
target_link_libraries(yaze_app_core_lib PUBLIC yaze_grpc_support)
message(STATUS " - gRPC ROM service + canvas automation enabled")
endif()
# Platform-specific libraries
if(APPLE)
target_link_libraries(yaze_app_core_lib PUBLIC ${COCOA_LIBRARY})
endif()
set_target_properties(yaze_app_core_lib PROPERTIES
POSITION_INDEPENDENT_CODE ON
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
)
# Platform-specific compile definitions
if(UNIX AND NOT APPLE)
target_compile_definitions(yaze_app_core_lib PRIVATE linux stricmp=strcasecmp)
elseif(APPLE)
target_compile_definitions(yaze_app_core_lib PRIVATE MACOS)
elseif(WIN32)
target_compile_definitions(yaze_app_core_lib PRIVATE WINDOWS)
endif()
message(STATUS "✓ yaze_app_core_lib library configured (application layer)")
# ==============================================================================
# Yaze Application Executable
# ==============================================================================

136
src/app/app_core.cmake Normal file
View File

@@ -0,0 +1,136 @@
# ==============================================================================
# Application Core Library (Platform, Controller, ROM, Services)
# ==============================================================================
# This library contains application-level core components:
# - ROM management (app/rom.cc)
# - Application controller (app/controller.cc)
# - Window/platform management (app/platform/)
# - gRPC services for AI automation (app/service/)
#
# Dependencies: yaze_core_lib (foundational), yaze_util, yaze_gfx, SDL2, ImGui
# ==============================================================================
set(
YAZE_APP_CORE_SRC
app/rom.cc
app/controller.cc
app/platform/window.cc
)
# Platform-specific sources
if (WIN32 OR MINGW OR (UNIX AND NOT APPLE))
list(APPEND YAZE_APP_CORE_SRC
app/platform/font_loader.cc
app/platform/asset_loader.cc
app/platform/file_dialog_nfd.cc # NFD file dialog for Windows/Linux
)
endif()
if(APPLE)
list(APPEND YAZE_APP_CORE_SRC
app/platform/font_loader.cc
app/platform/asset_loader.cc
)
set(YAZE_APPLE_OBJCXX_SRC
app/platform/file_dialog.mm
app/platform/app_delegate.mm
app/platform/font_loader.mm
)
add_library(yaze_app_objcxx OBJECT ${YAZE_APPLE_OBJCXX_SRC})
set_target_properties(yaze_app_objcxx PROPERTIES
OBJCXX_STANDARD 20
OBJCXX_STANDARD_REQUIRED ON
)
target_include_directories(yaze_app_objcxx PUBLIC
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/src/app
${CMAKE_SOURCE_DIR}/ext
${CMAKE_SOURCE_DIR}/ext/imgui
${CMAKE_SOURCE_DIR}/incl
${PROJECT_BINARY_DIR}
)
target_link_libraries(yaze_app_objcxx PUBLIC ${ABSL_TARGETS} yaze_util ${YAZE_SDL2_TARGETS})
target_compile_definitions(yaze_app_objcxx PUBLIC MACOS)
find_library(COCOA_LIBRARY Cocoa)
if(NOT COCOA_LIBRARY)
message(FATAL_ERROR "Cocoa not found")
endif()
set(CMAKE_EXE_LINKER_FLAGS "-framework ServiceManagement -framework Foundation -framework Cocoa")
endif()
# Create the application core library
add_library(yaze_app_core_lib STATIC
${YAZE_APP_CORE_SRC}
$<$<BOOL:${APPLE}>:$<TARGET_OBJECTS:yaze_app_objcxx>>
)
target_precompile_headers(yaze_app_core_lib PRIVATE
"$<$<COMPILE_LANGUAGE:CXX>:${CMAKE_SOURCE_DIR}/src/yaze_pch.h>"
)
target_include_directories(yaze_app_core_lib PUBLIC
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/src/app
${CMAKE_SOURCE_DIR}/ext
${CMAKE_SOURCE_DIR}/ext/imgui
${CMAKE_SOURCE_DIR}/incl
${SDL2_INCLUDE_DIR}
${PROJECT_BINARY_DIR}
)
target_link_libraries(yaze_app_core_lib PUBLIC
yaze_core_lib # Foundational core library with project management
yaze_util
yaze_gfx
yaze_zelda3
yaze_common
ImGui
${ABSL_TARGETS}
${YAZE_SDL2_TARGETS}
${CMAKE_DL_LIBS}
)
# Link nativefiledialog-extended for Windows/Linux file dialogs
if(WIN32 OR (UNIX AND NOT APPLE))
add_subdirectory(${CMAKE_SOURCE_DIR}/ext/nativefiledialog-extended ${CMAKE_BINARY_DIR}/nfd EXCLUDE_FROM_ALL)
target_link_libraries(yaze_app_core_lib PUBLIC nfd)
target_include_directories(yaze_app_core_lib PUBLIC ${CMAKE_SOURCE_DIR}/ext/nativefiledialog-extended/src/include)
endif()
# gRPC Services (Optional)
if(YAZE_WITH_GRPC)
target_include_directories(yaze_app_core_lib PRIVATE
${CMAKE_SOURCE_DIR}/ext/json/include)
target_compile_definitions(yaze_app_core_lib PRIVATE YAZE_WITH_JSON)
# Link to consolidated gRPC support library
target_link_libraries(yaze_app_core_lib PUBLIC yaze_grpc_support)
message(STATUS " - gRPC ROM service + canvas automation enabled")
endif()
# Platform-specific libraries
if(APPLE)
target_link_libraries(yaze_app_core_lib PUBLIC ${COCOA_LIBRARY})
endif()
set_target_properties(yaze_app_core_lib PROPERTIES
POSITION_INDEPENDENT_CODE ON
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
)
# Platform-specific compile definitions
if(UNIX AND NOT APPLE)
target_compile_definitions(yaze_app_core_lib PRIVATE linux stricmp=strcasecmp)
elseif(APPLE)
target_compile_definitions(yaze_app_core_lib PRIVATE MACOS)
elseif(WIN32)
target_compile_definitions(yaze_app_core_lib PRIVATE WINDOWS)
endif()
message(STATUS "✓ yaze_app_core_lib library configured (application layer)")