link the executable the same way whatever generator builds it

Two link settings were conditional on the Visual Studio generator, though
what they compensate for is the prebuilt libraries in the tree, which are the
same libraries under every generator. Ninja builds got away with it because
link.exe is quiet about both; lld-link is not.

legacy_stdio_definitions.lib: RakNetLibStatic.lib still calls _vsnprintf,
which the UCRT only exports through that compatibility library.

/SAFESEH:NO: lua51.lib and the smackw32 import library carry no safe
exception handler table, so no linker can emit one. The image never had it.
Before and after, JA2.exe reports SEHandlerTable 0x0 and SEHandlerCount 0,
with DYNAMIC_BASE, NX_COMPAT and TERMINAL_SERVER_AWARE unchanged -- the flag
states what link.exe was already doing silently.

Dbghelp.lib and Winmm.lib are also spelled as the SDK ships them, since a
cross-compile looks for them on a case sensitive filesystem.
This commit is contained in:
Marco Antonio J. Costa
2026-07-23 19:29:55 -03:00
committed by majcosta
parent 4d04a86bdf
commit c2379acd7a
+8 -4
View File
@@ -81,8 +81,8 @@ set(Ja2_Libraries
"${CMAKE_SOURCE_DIR}/libexpatMT.lib"
"${CMAKE_SOURCE_DIR}/lua51.lib"
"${CMAKE_SOURCE_DIR}/lua51.vc9.lib"
"Dbghelp.lib"
"Winmm.lib"
"dbghelp.lib"
"winmm.lib"
"ws2_32.lib"
bfVFS
Lua
@@ -146,8 +146,12 @@ foreach(app IN LISTS ApplicationTargets)
sgp/sgp.cpp
Ja2/Res/ja2.rc
)
target_link_libraries(${exe} PRIVATE ${Ja2_Libraries} $<IF:${usingMsBuild},legacy_stdio_definitions.lib,>)
target_link_options(${exe} PRIVATE $<IF:${usingMsBuild},/SAFESEH:NO,>)
# RakNetLibStatic.lib was built against an older CRT and still calls
# _vsnprintf, which the UCRT only exports through this compatibility library.
target_link_libraries(${exe} PRIVATE ${Ja2_Libraries} legacy_stdio_definitions.lib)
# The prebuilt lua51.lib and smackw32 import library carry no safe exception
# handler table, so the image cannot claim one whatever links it.
target_link_options(${exe} PRIVATE /SAFESEH:NO)
target_compile_definitions(${exe} PRIVATE ${compilationFlags} ${debugFlags})
# language library for the application, e.g. JA2MAPEDITOR_i18n — one per app, all 8