Skip to content

Commit

Permalink
Fix problems building vcpkg Debug libs for UE.
Browse files Browse the repository at this point in the history
  • Loading branch information
kring committed Nov 11, 2024
1 parent 38e44c3 commit e238e1c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion extern/vcpkg-overlays/triplets/x64-windows-unreal.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_ENV_PASSTHROUGH "UNREAL_ENGINE_ROOT")
set(VCPKG_POLICY_ONLY_RELEASE_CRT enabled)

# Unreal Engine adds /Zp8 in 64-bit Windows builds to align structs to 8 bytes instead of the
# default of 16 bytes. There's this nice note in the documentation for that option:
Expand All @@ -15,9 +16,17 @@ set(VCPKG_ENV_PASSTHROUGH "UNREAL_ENGINE_ROOT")
# between compilation units using different versions of that flag. We compile cesium-native
# with this same option to avoid super-dodgy and hard to debug issues.
# https://github.com/EpicGames/UnrealEngine/blob/5.2.1-release/Engine/Source/Programs/UnrealBuildTool/Platform/Windows/VCToolChain.cs
set(VCPKG_CXX_FLAGS "/MD /Zp8")
set(VCPKG_CXX_FLAGS "/Zp8")
set(VCPKG_C_FLAGS "${VCPKG_CXX_FLAGS}")

# Use an unreasonable amount of force to replace /MDd (MultiThreadedDebugDLL) with /MD (MultiThreadedDLL)
# and ensure that `_DEBUG` is not defined, as required by Unreal Engine's use of the release runtime library.
# Only CMAKE_MSVC_RUNTIME_LIBRARY would be required if all our third-party libraries used CMake 3.15+, but alas.
set(VCPKG_CMAKE_CONFIGURE_OPTIONS "")
list(APPEND VCPKG_CMAKE_CONFIGURE_OPTIONS "-DCMAKE_MSVC_RUNTIME_LIBRARY:STRING=MultiThreadedDLL")
list(APPEND VCPKG_CMAKE_CONFIGURE_OPTIONS "-DCMAKE_CXX_FLAGS_DEBUG:STRING=/MD /Z7 /Ob0 /Od /RTC1")
list(APPEND VCPKG_CMAKE_CONFIGURE_OPTIONS "-DCMAKE_C_FLAGS_DEBUG:STRING=/MD /Z7 /Ob0 /Od /RTC1")

# When building official binaries on CI, use a very specific MSVC toolset version (which must be installed).
# When building locally, use the default.
if(DEFINED ENV{CI})
Expand Down

0 comments on commit e238e1c

Please sign in to comment.