mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-10 16:16:16 +00:00
cmake: add SOGEN_STATIC_CRT option for static runtime linking
Add option to use static CRT (/MT) instead of dynamic (/MD) for projects that require static linking, such as IDA Pro plugins. - Default remains /MD (no change for existing users) - Set -DSOGEN_STATIC_CRT=ON to use /MT - Also respects parent's CMAKE_MSVC_RUNTIME_LIBRARY if already set Includes warning about potential heap corruption when allocations cross library boundaries with static CRT.
This commit is contained in:
@@ -217,10 +217,26 @@ if(MOMO_ENABLE_SANITIZER)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
##########################################
|
##########################################
|
||||||
# Must be a dynamic runtime (/MD or /MDd) to enforce
|
# MSVC Runtime Library Selection
|
||||||
# shared allocators between emulator and implementation
|
#
|
||||||
|
# Default is dynamic runtime (/MD or /MDd) to enforce shared allocators
|
||||||
|
# between emulator and implementation.
|
||||||
|
#
|
||||||
|
# Use SOGEN_STATIC_CRT=ON for static runtime (/MT or /MTd) when embedding
|
||||||
|
# in projects that require it (e.g., IDA plugins).
|
||||||
|
#
|
||||||
|
# WARNING: Static CRT may cause heap corruption if memory is allocated
|
||||||
|
# in one module and freed in another. Ensure allocation ownership is clear.
|
||||||
|
|
||||||
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded$<$<CONFIG:Debug>:Debug>DLL)
|
option(SOGEN_STATIC_CRT "Use static CRT (/MT) instead of dynamic (/MD)" OFF)
|
||||||
|
|
||||||
|
if(SOGEN_STATIC_CRT)
|
||||||
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||||
|
elseif(DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
|
||||||
|
# Respect parent project's setting
|
||||||
|
else()
|
||||||
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
|
||||||
|
endif()
|
||||||
|
|
||||||
##########################################
|
##########################################
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user