From 55f6ed93bc797f0c58d09551b2de96a2615d7906 Mon Sep 17 00:00:00 2001 From: scawful Date: Tue, 14 Oct 2025 00:12:08 -0400 Subject: [PATCH] feat(build): align Windows static builds with vcpkg runtime settings - Updated CMake configuration to align Windows static builds (MSVC, clang-cl) with vcpkg's /MT runtime. - Added conditional linking for libprotobuf when YAZE_WITH_GRPC is enabled, enhancing modularity. - Addressed potential macro conflicts by undefining SendMessage in the conversational agent service files. Benefits: - Improves compatibility and reliability of builds on Windows platforms. - Enhances the flexibility of the build system by conditionally linking libraries based on configuration options. --- CMakeLists.txt | 6 +++++- src/app/app.cmake | 3 +++ src/cli/service/agent/conversational_agent_service.cc | 4 ++++ src/cli/service/agent/conversational_agent_service.h | 4 ++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 508c18b7..34e5c8b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,11 @@ else() LANGUAGES CXX C) endif() +# Align Windows static builds (MSVC, clang-cl) with vcpkg's /MT runtime +if(MSVC OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND WIN32)) + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") +endif() + # Enable ccache for faster rebuilds if available find_program(CCACHE_FOUND ccache) if(CCACHE_FOUND) @@ -163,4 +168,3 @@ add_custom_target(build_cleaner COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_SOURCE_DIR} ${Python3_EXECUTABLE} scripts/build_cleaner.py --dry-run COMMENT "Validate CMake source lists and includes" ) - diff --git a/src/app/app.cmake b/src/app/app.cmake index 2cca28c2..d268aa42 100644 --- a/src/app/app.cmake +++ b/src/app/app.cmake @@ -40,6 +40,9 @@ target_link_libraries(yaze PRIVATE absl::flags absl::flags_parse ) +if(YAZE_WITH_GRPC AND TARGET libprotobuf) + target_link_libraries(yaze PRIVATE libprotobuf) +endif() # Link test support library (yaze_editor needs TestManager) if(TARGET yaze_test_support) diff --git a/src/cli/service/agent/conversational_agent_service.cc b/src/cli/service/agent/conversational_agent_service.cc index 025fe92b..ea925f48 100644 --- a/src/cli/service/agent/conversational_agent_service.cc +++ b/src/cli/service/agent/conversational_agent_service.cc @@ -27,6 +27,10 @@ #include "cli/util/terminal_colors.h" #include "nlohmann/json.hpp" +#ifdef SendMessage +#undef SendMessage +#endif + ABSL_DECLARE_FLAG(std::string, ai_provider); namespace yaze { diff --git a/src/cli/service/agent/conversational_agent_service.h b/src/cli/service/agent/conversational_agent_service.h index 5ff1cf05..e24bbf39 100644 --- a/src/cli/service/agent/conversational_agent_service.h +++ b/src/cli/service/agent/conversational_agent_service.h @@ -20,6 +20,10 @@ #include "cli/service/agent/agent_pretraining.h" #endif +#ifdef SendMessage +#undef SendMessage +#endif + namespace yaze { class Rom;