diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bf4f1597..3c64183f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -67,7 +67,7 @@ add_subdirectory(core) include(app/gfx/gfx_library.cmake) include(app/net/net_library.cmake) include(app/gui/gui_library.cmake) -include(app/core/core_library.cmake) +# NOTE: app/core/core_library.cmake merged into app/app.cmake # Include test support library BEFORE yaze_editor so it can link against it # (yaze_editor needs TestManager for editor features) diff --git a/src/app/app.cmake b/src/app/app.cmake index ecf76291..98a4947d 100644 --- a/src/app/app.cmake +++ b/src/app/app.cmake @@ -1,4 +1,167 @@ -# This file defines the main `yaze` application executable. +# ============================================================================== +# 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}/src/lib + ${CMAKE_SOURCE_DIR}/src/lib/imgui + ${CMAKE_SOURCE_DIR}/incl + ${SDL2_INCLUDE_DIR} + ${PROJECT_BINARY_DIR} + ) + target_link_libraries(yaze_app_objcxx PUBLIC ${ABSL_TARGETS} yaze_util) + 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} + $<$:$> +) + +target_precompile_headers(yaze_app_core_lib PRIVATE + "$<$:${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}/src/lib + ${CMAKE_SOURCE_DIR}/src/lib/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} + ${SDL_TARGETS} + ${CMAKE_DL_LIBS} +) + +# Link nativefiledialog-extended for Windows/Linux file dialogs +if(WIN32 OR (UNIX AND NOT APPLE)) + add_subdirectory(${CMAKE_SOURCE_DIR}/src/lib/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}/src/lib/nativefiledialog-extended/src/include) +endif() + +# gRPC Services (Optional) +if(YAZE_WITH_GRPC) + target_include_directories(yaze_app_core_lib PRIVATE + ${CMAKE_SOURCE_DIR}/third_party/json/include) + target_compile_definitions(yaze_app_core_lib PRIVATE YAZE_WITH_JSON) + + # Add proto definitions for ROM service and canvas automation + # NOTE: Test harness proto is in test.cmake with yaze_test_support + target_add_protobuf(yaze_app_core_lib + ${PROJECT_SOURCE_DIR}/src/protos/rom_service.proto) + target_add_protobuf(yaze_app_core_lib + ${PROJECT_SOURCE_DIR}/src/protos/canvas_automation.proto) + + # Add unified gRPC server (non-test services only) + target_sources(yaze_app_core_lib PRIVATE + ${CMAKE_SOURCE_DIR}/src/app/service/unified_grpc_server.cc + ${CMAKE_SOURCE_DIR}/src/app/service/unified_grpc_server.h + ) + + target_link_libraries(yaze_app_core_lib PUBLIC + grpc++ + grpc++_reflection + ) + if(YAZE_PROTOBUF_TARGETS) + target_link_libraries(yaze_app_core_lib PUBLIC ${YAZE_PROTOBUF_TARGETS}) + if(MSVC AND YAZE_PROTOBUF_WHOLEARCHIVE_TARGETS) + foreach(_yaze_proto_target IN LISTS YAZE_PROTOBUF_WHOLEARCHIVE_TARGETS) + target_link_options(yaze_app_core_lib PUBLIC /WHOLEARCHIVE:$) + endforeach() + endif() + endif() + + 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 +# ============================================================================== if (APPLE) add_executable(yaze MACOSX_BUNDLE app/main.cc ${YAZE_RESOURCE_FILES}) diff --git a/src/app/core/core_library.cmake b/src/app/core/core_library.cmake deleted file mode 100644 index 47209e48..00000000 --- a/src/app/core/core_library.cmake +++ /dev/null @@ -1,175 +0,0 @@ -# ============================================================================== -# Application Core Library (Platform, Controller, Services) -# ============================================================================== -# This file defines the application-level core components that were moved -# from the monolithic app/core structure. This is distinct from the foundational -# yaze_core_lib in src/core/ which handles project management and asar. -# -# Components: -# - ROM management (app/rom.cc) -# - Application controller (app/controller.cc) -# - Window/platform management (app/platform/) -# - gRPC services for AI automation (app/service/) -# - Test harness (app/test/) -# -# Dependencies: yaze_core_lib (foundational), yaze_util, yaze_gfx, SDL2, ImGui -# ============================================================================== - -set( - YAZE_APP_CORE_SRC - 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}/src/lib - ${CMAKE_SOURCE_DIR}/src/lib/imgui - ${CMAKE_SOURCE_DIR}/incl - ${SDL2_INCLUDE_DIR} - ${PROJECT_BINARY_DIR} - ) - target_link_libraries(yaze_app_objcxx PUBLIC ${ABSL_TARGETS} yaze_util) - 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() - -# ============================================================================== -# Application Core Library -# ============================================================================== -# Renamed from old yaze_core_lib to yaze_app_core_lib to distinguish from -# the foundational yaze_core_lib in src/core/ -# ============================================================================== - -add_library(yaze_app_core_lib STATIC - app/rom.cc - ${YAZE_APP_CORE_SRC} - $<$:$> -) - -target_precompile_headers(yaze_app_core_lib PRIVATE - "$<$:${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}/src/lib - ${CMAKE_SOURCE_DIR}/src/lib/imgui - ${CMAKE_SOURCE_DIR}/incl - ${SDL2_INCLUDE_DIR} - ${PROJECT_BINARY_DIR} -) - -target_link_libraries(yaze_app_core_lib PUBLIC - yaze_core_lib # NEW foundational core library with project management - yaze_util - yaze_gfx - yaze_zelda3 - yaze_common - ImGui - ${ABSL_TARGETS} - ${SDL_TARGETS} - ${CMAKE_DL_LIBS} -) - -# Link nativefiledialog-extended for Windows/Linux file dialogs -if(WIN32 OR (UNIX AND NOT APPLE)) - add_subdirectory(${CMAKE_SOURCE_DIR}/src/lib/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}/src/lib/nativefiledialog-extended/src/include) -endif() - -# ============================================================================== -# gRPC Services and Test Harness (Optional) -# ============================================================================== - -if(YAZE_WITH_GRPC) - target_include_directories(yaze_app_core_lib PRIVATE - ${CMAKE_SOURCE_DIR}/third_party/json/include) - target_compile_definitions(yaze_app_core_lib PRIVATE YAZE_WITH_JSON) - - # Add proto definitions for ROM service and canvas automation - # NOTE: Test harness proto moved to test.cmake with yaze_test_support - target_add_protobuf(yaze_app_core_lib - ${PROJECT_SOURCE_DIR}/src/protos/rom_service.proto) - target_add_protobuf(yaze_app_core_lib - ${PROJECT_SOURCE_DIR}/src/protos/canvas_automation.proto) - - # Add unified gRPC server (non-test services only) - target_sources(yaze_app_core_lib PRIVATE - ${CMAKE_SOURCE_DIR}/src/app/service/unified_grpc_server.cc - ${CMAKE_SOURCE_DIR}/src/app/service/unified_grpc_server.h - ) - - target_link_libraries(yaze_app_core_lib PUBLIC - grpc++ - grpc++_reflection - ) - if(YAZE_PROTOBUF_TARGETS) - target_link_libraries(yaze_app_core_lib PUBLIC ${YAZE_PROTOBUF_TARGETS}) - if(MSVC AND YAZE_PROTOBUF_WHOLEARCHIVE_TARGETS) - foreach(_yaze_proto_target IN LISTS YAZE_PROTOBUF_WHOLEARCHIVE_TARGETS) - target_link_options(yaze_app_core_lib PUBLIC /WHOLEARCHIVE:$) - endforeach() - endif() - endif() - - message(STATUS " - gRPC ROM service + canvas automation enabled") - message(STATUS " - gRPC test harness moved to yaze_test_support (avoid circular deps)") -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)")