refactor(build): enhance CMake configurations for protobuf integration
- Updated CMake files to conditionally link against libprotobuf based on the YAZE_PROTOBUF_TARGET variable across various modules (core, net, agent, z3ed). - Ensured consistent use of the static MSVC runtime to align with vcpkg static triplets. - Improved clarity in build logs by adding status messages for whole-archive linking conditions. Benefits: - Enhances modularity and compatibility of the build system with protobuf. - Streamlines the build process for different platforms by ensuring appropriate linking based on configuration options.
This commit is contained in:
@@ -9,8 +9,8 @@ set(CMAKE_POLICY_VERSION_MINIMUM 3.5 CACHE STRING "Minimum policy version for su
|
||||
# Set policies for compatibility
|
||||
cmake_policy(SET CMP0091 NEW)
|
||||
|
||||
# Ensure we consistently use the dynamic MSVC runtime (/MD, /MDd) even when cached
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL" CACHE STRING "" FORCE)
|
||||
# Ensure we consistently use the static MSVC runtime (/MT, /MTd) to match vcpkg static triplets
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>" CACHE STRING "" FORCE)
|
||||
cmake_policy(SET CMP0048 NEW)
|
||||
cmake_policy(SET CMP0077 NEW)
|
||||
|
||||
|
||||
@@ -85,6 +85,14 @@ if(NOT YAZE_WITH_GRPC)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(TARGET protobuf::libprotobuf)
|
||||
set(YAZE_PROTOBUF_TARGET protobuf::libprotobuf)
|
||||
elseif(TARGET libprotobuf)
|
||||
set(YAZE_PROTOBUF_TARGET libprotobuf)
|
||||
else()
|
||||
set(YAZE_PROTOBUF_TARGET "")
|
||||
endif()
|
||||
|
||||
# SDL2
|
||||
include(cmake/sdl2.cmake)
|
||||
|
||||
@@ -135,4 +143,3 @@ endif()
|
||||
|
||||
# httplib (header only)
|
||||
# No action needed here as it's included directly.
|
||||
|
||||
|
||||
@@ -40,8 +40,8 @@ target_link_libraries(yaze PRIVATE
|
||||
absl::flags
|
||||
absl::flags_parse
|
||||
)
|
||||
if(YAZE_WITH_GRPC AND TARGET libprotobuf)
|
||||
target_link_libraries(yaze PRIVATE libprotobuf)
|
||||
if(YAZE_WITH_GRPC AND YAZE_PROTOBUF_TARGET)
|
||||
target_link_libraries(yaze PRIVATE ${YAZE_PROTOBUF_TARGET})
|
||||
endif()
|
||||
|
||||
# Link test support library (yaze_editor needs TestManager)
|
||||
|
||||
@@ -144,14 +144,19 @@ if(YAZE_WITH_GRPC)
|
||||
target_link_libraries(yaze_core_lib PUBLIC
|
||||
grpc++
|
||||
grpc++_reflection
|
||||
libprotobuf
|
||||
)
|
||||
if(YAZE_PROTOBUF_TARGET)
|
||||
target_link_libraries(yaze_core_lib PUBLIC ${YAZE_PROTOBUF_TARGET})
|
||||
endif()
|
||||
|
||||
# On Windows, force whole-archive linking for protobuf to ensure all symbols are included
|
||||
if(MSVC AND CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
target_link_options(yaze_core_lib PUBLIC /WHOLEARCHIVE:$<TARGET_FILE:libprotobuf>)
|
||||
elseif(MSVC)
|
||||
message(STATUS "○ Skipping /WHOLEARCHIVE for libprotobuf in yaze_core_lib (clang-cl)")
|
||||
if(MSVC AND YAZE_PROTOBUF_TARGET)
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
target_link_options(yaze_core_lib PUBLIC
|
||||
/WHOLEARCHIVE:$<TARGET_FILE:${YAZE_PROTOBUF_TARGET}>)
|
||||
else()
|
||||
message(STATUS "○ Skipping /WHOLEARCHIVE for libprotobuf in yaze_core_lib (clang-cl)")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
message(STATUS " - gRPC test harness + ROM service enabled")
|
||||
|
||||
@@ -142,8 +142,10 @@ if(YAZE_WITH_GRPC)
|
||||
target_link_libraries(yaze_editor PRIVATE
|
||||
grpc++
|
||||
grpc++_reflection
|
||||
libprotobuf
|
||||
)
|
||||
if(YAZE_PROTOBUF_TARGET)
|
||||
target_link_libraries(yaze_editor PRIVATE ${YAZE_PROTOBUF_TARGET})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set_target_properties(yaze_editor PROPERTIES
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,11 @@
|
||||
#include "shortcut_manager.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "app/gui/core/input.h"
|
||||
#include "imgui/imgui.h"
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
|
||||
// Must define before including imgui.h
|
||||
|
||||
@@ -129,6 +129,7 @@ add_library(yaze_gfx_debug STATIC ${GFX_DEBUG_SRC})
|
||||
configure_gfx_library(yaze_gfx_debug)
|
||||
target_link_libraries(yaze_gfx_debug PUBLIC
|
||||
yaze_gfx_types
|
||||
yaze_gfx_resource
|
||||
ImGui
|
||||
)
|
||||
|
||||
|
||||
@@ -83,14 +83,18 @@ if(YAZE_WITH_GRPC)
|
||||
target_link_libraries(yaze_net PUBLIC
|
||||
grpc++
|
||||
grpc++_reflection
|
||||
libprotobuf
|
||||
)
|
||||
if(YAZE_PROTOBUF_TARGET)
|
||||
target_link_libraries(yaze_net PUBLIC ${YAZE_PROTOBUF_TARGET})
|
||||
endif()
|
||||
|
||||
# On Windows, force whole-archive linking for protobuf to ensure all symbols are included
|
||||
if(MSVC AND CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
target_link_options(yaze_net PUBLIC /WHOLEARCHIVE:$<TARGET_FILE:libprotobuf>)
|
||||
elseif(MSVC)
|
||||
message(STATUS "○ Skipping /WHOLEARCHIVE for libprotobuf in yaze_net (clang-cl)")
|
||||
if(MSVC AND YAZE_PROTOBUF_TARGET)
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
target_link_options(yaze_net PUBLIC /WHOLEARCHIVE:$<TARGET_FILE:${YAZE_PROTOBUF_TARGET}>)
|
||||
else()
|
||||
message(STATUS "○ Skipping /WHOLEARCHIVE for libprotobuf in yaze_net (clang-cl)")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
message(STATUS " - gRPC ROM service enabled")
|
||||
|
||||
@@ -9,24 +9,27 @@
|
||||
#include <ctime>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <new>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/status/status.h"
|
||||
#include "absl/status/statusor.h"
|
||||
#include "absl/strings/str_cat.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "app/core/features.h"
|
||||
#include "app/core/window.h"
|
||||
#include "app/gfx/util/compression.h"
|
||||
#include "app/gfx/types/snes_color.h"
|
||||
#include "app/gfx/types/snes_palette.h"
|
||||
#include "app/gfx/types/snes_tile.h"
|
||||
#include "app/snes.h"
|
||||
#include "app/gfx/core/bitmap.h"
|
||||
#include "util/log.h"
|
||||
#include "util/hex.h"
|
||||
#include "util/log.h"
|
||||
#include "util/macro.h"
|
||||
#include "zelda.h"
|
||||
|
||||
namespace yaze {
|
||||
constexpr int Uncompressed3BPPSize = 0x0600;
|
||||
|
||||
@@ -4,11 +4,13 @@
|
||||
#include <SDL.h>
|
||||
#include <zelda.h>
|
||||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include <map>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
@@ -19,6 +21,7 @@
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "app/core/project.h"
|
||||
#include "app/gfx/core/bitmap.h"
|
||||
#include "app/gfx/types/snes_color.h"
|
||||
#include "app/gfx/types/snes_palette.h"
|
||||
#include "app/gfx/types/snes_tile.h"
|
||||
#include "util/macro.h"
|
||||
@@ -74,7 +77,7 @@ class Rom {
|
||||
bool backup = false;
|
||||
bool save_new = false;
|
||||
bool z3_save = true;
|
||||
std::string filename = "";
|
||||
std::string filename;
|
||||
};
|
||||
|
||||
absl::Status LoadFromFile(const std::string& filename, bool z3_load = true);
|
||||
@@ -235,10 +238,10 @@ class Rom {
|
||||
std::string title_ = "ROM not loaded";
|
||||
|
||||
// Filename of the ROM
|
||||
std::string filename_ = "";
|
||||
std::string filename_;
|
||||
|
||||
// Short name of the ROM
|
||||
std::string short_name_ = "";
|
||||
std::string short_name_;
|
||||
|
||||
// Full contiguous rom space
|
||||
std::vector<uint8_t> rom_data_;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
// If any write fails before Commit, subsequent operations are skipped and
|
||||
// Commit() will Rollback() previously applied writes in reverse order.
|
||||
|
||||
#include <cstdint>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
|
||||
@@ -160,14 +160,18 @@ if(YAZE_WITH_GRPC)
|
||||
target_link_libraries(yaze_agent PUBLIC
|
||||
grpc++
|
||||
grpc++_reflection
|
||||
libprotobuf
|
||||
)
|
||||
if(YAZE_PROTOBUF_TARGET)
|
||||
target_link_libraries(yaze_agent PUBLIC ${YAZE_PROTOBUF_TARGET})
|
||||
endif()
|
||||
|
||||
# On Windows, force whole-archive linking for protobuf to ensure all symbols are included
|
||||
if(MSVC AND CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
target_link_options(yaze_agent PUBLIC /WHOLEARCHIVE:$<TARGET_FILE:libprotobuf>)
|
||||
elseif(MSVC)
|
||||
message(STATUS "○ Skipping /WHOLEARCHIVE for libprotobuf (clang-cl)")
|
||||
if(MSVC AND YAZE_PROTOBUF_TARGET)
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
target_link_options(yaze_agent PUBLIC /WHOLEARCHIVE:$<TARGET_FILE:${YAZE_PROTOBUF_TARGET}>)
|
||||
else()
|
||||
message(STATUS "○ Skipping /WHOLEARCHIVE for libprotobuf (clang-cl)")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Note: YAZE_WITH_GRPC is defined globally via add_compile_definitions in root CMakeLists.txt
|
||||
|
||||
@@ -39,12 +39,17 @@ endif()
|
||||
|
||||
if(YAZE_WITH_GRPC)
|
||||
message(STATUS "Adding gRPC support to z3ed CLI")
|
||||
target_link_libraries(z3ed PRIVATE grpc++ grpc++_reflection libprotobuf)
|
||||
target_link_libraries(z3ed PRIVATE grpc++ grpc++_reflection)
|
||||
if(YAZE_PROTOBUF_TARGET)
|
||||
target_link_libraries(z3ed PRIVATE ${YAZE_PROTOBUF_TARGET})
|
||||
endif()
|
||||
|
||||
# On Windows, force whole-archive linking for protobuf to ensure all symbols are included
|
||||
if(MSVC AND CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
target_link_options(z3ed PRIVATE /WHOLEARCHIVE:$<TARGET_FILE:libprotobuf>)
|
||||
elseif(MSVC)
|
||||
message(STATUS "○ Skipping /WHOLEARCHIVE for libprotobuf in z3ed (clang-cl)")
|
||||
if(MSVC AND YAZE_PROTOBUF_TARGET)
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
target_link_options(z3ed PRIVATE /WHOLEARCHIVE:$<TARGET_FILE:${YAZE_PROTOBUF_TARGET}>)
|
||||
else()
|
||||
message(STATUS "○ Skipping /WHOLEARCHIVE for libprotobuf in z3ed (clang-cl)")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include "zelda3/palette_constants.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace yaze {
|
||||
namespace zelda3 {
|
||||
|
||||
@@ -48,9 +48,9 @@ if(YAZE_BUILD_TESTS)
|
||||
if(MSVC)
|
||||
target_link_options(${suite_name} PRIVATE /STACK:16777216)
|
||||
# Force whole-archive linking for protobuf to ensure all symbols are included
|
||||
if(YAZE_WITH_GRPC)
|
||||
if(YAZE_WITH_GRPC AND YAZE_PROTOBUF_TARGET)
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
target_link_options(${suite_name} PRIVATE /WHOLEARCHIVE:$<TARGET_FILE:libprotobuf>)
|
||||
target_link_options(${suite_name} PRIVATE /WHOLEARCHIVE:$<TARGET_FILE:${YAZE_PROTOBUF_TARGET}>)
|
||||
else()
|
||||
message(STATUS "○ Skipping /WHOLEARCHIVE for libprotobuf in ${suite_name} (clang-cl)")
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user