mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-11 16:46:16 +00:00
cmake: rename MOMO_BUILD_AS_LIBRARY to SOGEN_BUILD_STATIC
Also adds FATAL_ERROR guard when SOGEN_STATIC_CRT=ON without SOGEN_BUILD_STATIC=ON, since static CRT with shared libraries causes heap corruption (each DLL gets its own allocator but sogen passes ownership across boundaries). These options are designed to be used together for full static linking, useful for embedding sogen in projects like IDA Pro plugins.
This commit is contained in:
@@ -31,10 +31,10 @@ endif()
|
||||
|
||||
##########################################
|
||||
|
||||
if(MOMO_BUILD_AS_LIBRARY)
|
||||
add_compile_definitions(MOMO_BUILD_AS_LIBRARY=1)
|
||||
if(SOGEN_BUILD_STATIC)
|
||||
add_compile_definitions(SOGEN_BUILD_STATIC=1)
|
||||
else()
|
||||
add_compile_definitions(MOMO_BUILD_AS_LIBRARY=0)
|
||||
add_compile_definitions(SOGEN_BUILD_STATIC=0)
|
||||
endif()
|
||||
|
||||
##########################################
|
||||
@@ -230,6 +230,13 @@ endif()
|
||||
|
||||
option(SOGEN_STATIC_CRT "Use static CRT (/MT) instead of dynamic (/MD)" OFF)
|
||||
|
||||
if(SOGEN_STATIC_CRT AND NOT SOGEN_BUILD_STATIC)
|
||||
message(FATAL_ERROR
|
||||
"SOGEN_STATIC_CRT=ON requires SOGEN_BUILD_STATIC=ON.\n"
|
||||
"Static CRT with shared libraries causes heap corruption - "
|
||||
"each DLL gets its own allocator, but sogen passes ownership across boundaries.")
|
||||
endif()
|
||||
|
||||
if(SOGEN_STATIC_CRT)
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||
elseif(DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
|
||||
|
||||
Reference in New Issue
Block a user