MSVC static library split hack

This commit is contained in:
Jack Andersen 2019-02-06 18:10:07 -10:00
parent 825acbaa0d
commit 5600bf5172
1 changed files with 89 additions and 73 deletions

View File

@ -48,7 +48,7 @@ if(APPLE)
list(APPEND PLAT_SRCS startButton.cpp CGameOptionsTouchBarMac.mm)
endif()
add_library(RuntimeCommon
set(RUNTIME_SOURCES_A
RetroTypes.hpp RetroTypes.cpp
${CLIENT_SOURCES}
${MP1_SOURCES}
@ -56,7 +56,9 @@ add_library(RuntimeCommon
${AUTOMAPPER_SOURCES}
${CAMERA_SOURCES}
${CHARACTER_SOURCES}
${COLLISION_SOURCES}
${COLLISION_SOURCES})
set(RUNTIME_SOURCES_B
${GRAPHICS_SOURCES}
${GUISYS_SOURCES}
${INPUT_SOURCES}
@ -116,15 +118,29 @@ add_library(RuntimeCommon
TCastTo.hpp TCastTo.cpp
GCNTypes.hpp
${PLAT_SRCS})
function(add_runtime_common_library name)
add_library(${name} ${ARGN})
if(COMMAND add_sanitizers)
add_sanitizers(RuntimeCommon)
add_sanitizers(${name})
endif()
if(COMMAND cotire)
set_target_properties(RuntimeCommon PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE)
cotire(RuntimeCommon)
set_target_properties(${name} PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE)
cotire(${name})
endif()
add_dependencies(RuntimeCommon ${HECL_APPLICATION_REPS_TARGETS_LIST})
add_dependencies(${name} ${HECL_APPLICATION_REPS_TARGETS_LIST})
if(WINDOWS_STORE)
set_property(TARGET RuntimeCommon PROPERTY VS_WINRT_COMPONENT TRUE)
set_property(TARGET ${name} PROPERTY VS_WINRT_COMPONENT TRUE)
endif()
endfunction()
if(MSVC)
# WTF MS???? LINK.EXE is unable to address static libraries larger than 4GB.
# This is a hack to split this large library in two.
add_runtime_common_library(RuntimeCommon ${RUNTIME_SOURCES_A})
add_runtime_common_library(RuntimeCommonB ${RUNTIME_SOURCES_B})
target_link_libraries(RuntimeCommon RuntimeCommonB)
else()
add_runtime_common_library(RuntimeCommon ${RUNTIME_SOURCES_A} ${RUNTIME_SOURCES_B})
endif()