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.
This commit is contained in:
scawful
2025-10-14 00:12:08 -04:00
parent cafa50b355
commit 55f6ed93bc
4 changed files with 16 additions and 1 deletions

View File

@@ -22,6 +22,11 @@ else()
LANGUAGES CXX C) LANGUAGES CXX C)
endif() 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$<$<CONFIG:Debug>:Debug>")
endif()
# Enable ccache for faster rebuilds if available # Enable ccache for faster rebuilds if available
find_program(CCACHE_FOUND ccache) find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND) 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 COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_SOURCE_DIR} ${Python3_EXECUTABLE} scripts/build_cleaner.py --dry-run
COMMENT "Validate CMake source lists and includes" COMMENT "Validate CMake source lists and includes"
) )

View File

@@ -40,6 +40,9 @@ target_link_libraries(yaze PRIVATE
absl::flags absl::flags
absl::flags_parse 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) # Link test support library (yaze_editor needs TestManager)
if(TARGET yaze_test_support) if(TARGET yaze_test_support)

View File

@@ -27,6 +27,10 @@
#include "cli/util/terminal_colors.h" #include "cli/util/terminal_colors.h"
#include "nlohmann/json.hpp" #include "nlohmann/json.hpp"
#ifdef SendMessage
#undef SendMessage
#endif
ABSL_DECLARE_FLAG(std::string, ai_provider); ABSL_DECLARE_FLAG(std::string, ai_provider);
namespace yaze { namespace yaze {

View File

@@ -20,6 +20,10 @@
#include "cli/service/agent/agent_pretraining.h" #include "cli/service/agent/agent_pretraining.h"
#endif #endif
#ifdef SendMessage
#undef SendMessage
#endif
namespace yaze { namespace yaze {
class Rom; class Rom;