Files

148 lines
10 KiB
CMake

# Included only by the top-level WIN32 branch. No Linux/Wine bootstrap, server,
# MariaDB, relay, ptrace or frontend target is used by this native backend.
if(NOT WIN32)
message(FATAL_ERROR "WindowsBackend requires an actual Windows target toolchain")
endif()
find_package(OpenSSL 3.0 REQUIRED COMPONENTS Crypto)
find_package(ZLIB REQUIRED)
set(GW_WINDOWS_PROTOCOL_SOURCES
src/protocol.cpp src/auras.cpp src/srp.cpp src/forever.cpp src/legacy_client.cpp
src/realms.cpp src/roster_translation.cpp src/world.cpp src/object_updates.cpp
src/chat.cpp src/contact_names.cpp src/who.cpp src/pvp_statistics.cpp src/auction_browse.cpp src/auction_aux.cpp src/pet_stable.cpp src/social.cpp src/queries.cpp src/splines.cpp src/gameplay.cpp src/npc_text.cpp src/reputation.cpp
src/talents.cpp src/loot.cpp src/group.cpp src/guild_bank.cpp src/guild_notifications.cpp src/quest_packets.cpp src/quest_log.cpp
src/warrior_cooldown_modifiers.cpp src/spell_modifier_operations.cpp src/spell_modifier_group_values.cpp src/spell_modifiers.cpp src/aura_state.cpp src/remote_speeds.cpp
src/character_creation.cpp src/character_creation_lifecycle.cpp
src/character_initialization.cpp src/legacy_stream.cpp src/world_authentication.cpp)
add_library(gateway_protocol STATIC ${GW_WINDOWS_PROTOCOL_SOURCES})
target_include_directories(gateway_protocol PUBLIC include)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ItemBuildBase.cmake)
gw_admit_item_build_base(gateway_protocol)
target_compile_definitions(gateway_protocol PUBLIC NOMINMAX WIN32_LEAN_AND_MEAN _WIN32_WINNT=0x0A00)
target_link_libraries(gateway_protocol PUBLIC OpenSSL::Crypto ZLIB::ZLIB ws2_32)
add_library(GWNativeBackend SHARED
native/windows_backend.cpp native/wine_wire_registry.cpp native/session.cpp
native/aura_translation.cpp native/world_translation.cpp native/entity_translation.cpp
native/peer_player_translation.cpp native/inventory_translation.cpp native/loot_translation.cpp
native/guild_bank_translation.cpp native/emote_translation.cpp
native/party_translation.cpp native/far_transfer.cpp native/quest_translation.cpp
native/contact_name_translation.cpp native/social_translation.cpp src/gameobject_queries.cpp
native/radio_player.cpp native/client_update.cpp)
target_compile_definitions(GWNativeBackend PRIVATE GW_IN_CLIENT_FEATURE_DEFAULTS=1)
target_include_directories(GWNativeBackend PRIVATE native)
foreach(_gw_quest_header GW_QUEST_POI_DATASET_HEADER GW_QUEST_POI_60141_GEOMETRY_HEADER)
set(${_gw_quest_header} "" CACHE FILEPATH "Reviewed immutable native quest POI header")
if(${_gw_quest_header})
get_filename_component(_gw_quest_input "${${_gw_quest_header}}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
if(NOT EXISTS "${_gw_quest_input}")
message(FATAL_ERROR "Reviewed Windows quest POI input is missing: ${_gw_quest_header}")
endif()
target_compile_definitions(GWNativeBackend PRIVATE ${_gw_quest_header}="${_gw_quest_input}")
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${_gw_quest_input}")
endif()
endforeach()
set(GW_GAMEOBJECT_AUTHORITY_PROFILE_HEADER "" CACHE FILEPATH "Reviewed immutable local Source game-object authority header")
set(GW_GAMEOBJECT_AUTHORITY_PACKAGE_INCLUDE "" CACHE PATH "Combined codec compatibility-include directory used by the game-object authority")
if(GW_GAMEOBJECT_AUTHORITY_PROFILE_HEADER OR GW_GAMEOBJECT_AUTHORITY_PACKAGE_INCLUDE)
if(NOT GW_GAMEOBJECT_AUTHORITY_PROFILE_HEADER OR NOT GW_GAMEOBJECT_AUTHORITY_PACKAGE_INCLUDE)
message(FATAL_ERROR "Game-object authority requires its header and the combined codec package include")
endif()
if(NOT EXISTS "${GW_GAMEOBJECT_AUTHORITY_PROFILE_HEADER}" OR NOT EXISTS "${GW_GAMEOBJECT_AUTHORITY_PACKAGE_INCLUDE}/gateway/item_sparse_compat.hpp")
message(FATAL_ERROR "Reviewed Windows game-object authority inputs are missing")
endif()
target_compile_definitions(GWNativeBackend PRIVATE GW_GAMEOBJECT_AUTHORITY_PROFILE_HEADER="${GW_GAMEOBJECT_AUTHORITY_PROFILE_HEADER}")
target_include_directories(GWNativeBackend BEFORE PRIVATE "${GW_GAMEOBJECT_AUTHORITY_PACKAGE_INCLUDE}")
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${GW_GAMEOBJECT_AUTHORITY_PROFILE_HEADER}" "${GW_GAMEOBJECT_AUTHORITY_PACKAGE_INCLUDE}/gateway/item_sparse_compat.hpp")
endif()
target_link_libraries(GWNativeBackend PRIVATE gateway_protocol winhttp msacm32 ole32)
set_target_properties(GWNativeBackend PROPERTIES PREFIX "" OUTPUT_NAME "GWNativeBackend")
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
target_compile_options(gateway_protocol PRIVATE -Wall -Wextra -Wpedantic -Werror)
target_compile_options(GWNativeBackend PRIVATE -Wall -Wextra -Wpedantic -Werror)
target_link_options(GWNativeBackend PRIVATE -Wl,--no-undefined)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# The reviewed compact registry uses this finite Clang budget in the
# serializer builder too; GCC's existing metadata build already accepts it.
target_compile_options(GWNativeBackend PRIVATE -fconstexpr-steps=33554432)
# Generated metadata intentionally exceeds the standard minimum string limit.
set_property(SOURCE native/world_translation.cpp APPEND PROPERTY
COMPILE_OPTIONS -Wno-overlength-strings)
endif()
add_executable(windows-backend-smoke tests/windows_backend_smoke.cpp)
target_include_directories(windows-backend-smoke PRIVATE native)
target_link_libraries(windows-backend-smoke PRIVATE gateway_protocol)
target_compile_definitions(windows-backend-smoke PRIVATE NOMINMAX WIN32_LEAN_AND_MEAN _WIN32_WINNT=0x0A00)
enable_testing()
add_test(NAME windows-native-backend-load COMMAND windows-backend-smoke $<TARGET_FILE:GWNativeBackend>)
add_executable(windows-talent-addon-control-tests tests/talent_addon_control_test.cpp)
target_link_libraries(windows-talent-addon-control-tests PRIVATE gateway_protocol)
add_test(NAME windows-talent-addon-control COMMAND windows-talent-addon-control-tests)
# Match the already reviewed creation profile used by the sibling codec.
set(GW_WINDOWS_LOGIN_PROFILE_HEADER "" CACHE FILEPATH "Reviewed source/native creation profile")
if(GW_WINDOWS_LOGIN_PROFILE_HEADER)
file(SHA256 "${GW_WINDOWS_LOGIN_PROFILE_HEADER}" _gw_login_digest)
if(NOT _gw_login_digest STREQUAL "cc6710f18d5058a30d38307237312f3492319a1d33a9467cb0238af7066fc9bf"
AND NOT _gw_login_digest STREQUAL "b3d2e7e432a46ff6405ee8a6a9b297be68e22b65d56ecb40e683ac1cc63c7522")
message(FATAL_ERROR "Windows creation profile differs from the pinned reviewed 59-pair profile")
endif()
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/reviewed-login/gateway")
configure_file("${GW_WINDOWS_LOGIN_PROFILE_HEADER}" "${CMAKE_CURRENT_BINARY_DIR}/reviewed-login/gateway/turtle_login_profile.hpp" COPYONLY)
target_include_directories(gateway_protocol BEFORE PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/reviewed-login")
target_include_directories(GWNativeBackend BEFORE PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/reviewed-login")
endif()
set(GW_WINDOWS_CODEC_IMPORT_LIBRARY "" CACHE FILEPATH "Native source codec import library")
if(GW_WINDOWS_CODEC_IMPORT_LIBRARY)
if(NOT EXISTS "${GW_WINDOWS_CODEC_IMPORT_LIBRARY}")
message(FATAL_ERROR "Native codec import library missing")
endif()
target_compile_definitions(GWNativeBackend PRIVATE GW_WINDOWS_LINKED_CODEC=1)
target_link_libraries(GWNativeBackend PRIVATE "${GW_WINDOWS_CODEC_IMPORT_LIBRARY}")
endif()
# Standalone owned worker only: no game injection or in-client loader changes.
add_executable(windows-backend-host native/windows_backend_host.cpp)
add_executable(windows-backend-ipc-test tests/windows_backend_ipc_test.cpp)
foreach(_gw_ipc_target windows-backend-host windows-backend-ipc-test)
target_include_directories(${_gw_ipc_target} PRIVATE native)
target_link_libraries(${_gw_ipc_target} PRIVATE gateway_protocol)
target_compile_definitions(${_gw_ipc_target} PRIVATE NOMINMAX WIN32_LEAN_AND_MEAN _WIN32_WINNT=0x0A00)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
target_compile_options(${_gw_ipc_target} PRIVATE -Wall -Wextra -Wpedantic -Werror)
endif()
endforeach()
# Optional same-name Wire frontend with an owned out-of-process backend.
# This target is checked externally first; it is not client attachment proof.
option(GW_WINDOWS_IPC_FRONTEND "Build isolated existing-Wire IPC frontend" OFF)
set(GW_WINDOWS_BRIDGE_IMPORT_LIBRARY "" CACHE FILEPATH "Existing reviewed native bridge import library")
if(GW_WINDOWS_IPC_FRONTEND)
if(NOT EXISTS "${GW_WINDOWS_BRIDGE_IMPORT_LIBRARY}")
message(FATAL_ERROR "Existing native bridge import library required for IPC frontend")
endif()
add_library(GWNativeWireIPC SHARED
native/wine_wire_windows.c native/wine_wire_account.c native/wine_wire_listener.c
native/wine_engine_realm.c native/wine_pipe_host.c native/wine_channel_policy.c
native/wine_session_retirement.c native/windows_backend_ipc_client.cpp)
target_include_directories(GWNativeWireIPC PRIVATE native include)
target_compile_definitions(GWNativeWireIPC PRIVATE GW_NATIVE_WINDOWS=1 GW_NATIVE_OUT_OF_PROCESS=1 NOMINMAX _WIN32_WINNT=0x0A00)
target_link_libraries(GWNativeWireIPC PRIVATE "${GW_WINDOWS_BRIDGE_IMPORT_LIBRARY}" kernel32)
set_target_properties(GWNativeWireIPC PROPERTIES PREFIX "" OUTPUT_NAME "GWNativeWire" RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/windows-ipc-frontend" LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/windows-ipc-frontend")
add_executable(windows-wire-ipc-test tests/windows_wire_ipc_test.cpp)
target_include_directories(windows-wire-ipc-test PRIVATE native)
target_compile_definitions(windows-wire-ipc-test PRIVATE NOMINMAX WIN32_LEAN_AND_MEAN _WIN32_WINNT=0x0A00)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
target_compile_options(GWNativeWireIPC PRIVATE -Wall -Wextra -Werror $<$<COMPILE_LANGUAGE:CXX>:-Wpedantic>)
target_compile_options(windows-wire-ipc-test PRIVATE -Wall -Wextra -Wpedantic -Werror)
# Ordinary static runtime linkage keeps the thin frontend independent of
# backend crypto/runtime DLL imports; no module disguise/guard changes.
target_link_options(GWNativeWireIPC PRIVATE -static-libgcc -static-libstdc++ -Wl,--no-undefined -Wl,--exclude-all-symbols)
# Resolve the static C++ runtime's POSIX-thread references before selecting
# winpthread. A lone earlier winpthread archive is skipped before those
# references exist, leaving the driver's later defaults to import the DLL.
target_link_libraries(GWNativeWireIPC PRIVATE -Wl,-Bstatic stdc++ winpthread -Wl,-Bdynamic)
endif()
endif()