mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-10 16:16: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:
@@ -44,7 +44,7 @@ endif()
|
|||||||
|
|
||||||
##########################################
|
##########################################
|
||||||
|
|
||||||
option(MOMO_BUILD_AS_LIBRARY "Configure and Build the sogen as a shared library (without the samples and tests)" ${MOMO_IS_SUBPROJECT})
|
option(SOGEN_BUILD_STATIC "Build sogen as static libraries for embedding (e.g., IDA plugins)" ${MOMO_IS_SUBPROJECT})
|
||||||
|
|
||||||
##########################################
|
##########################################
|
||||||
|
|
||||||
|
|||||||
@@ -31,10 +31,10 @@ endif()
|
|||||||
|
|
||||||
##########################################
|
##########################################
|
||||||
|
|
||||||
if(MOMO_BUILD_AS_LIBRARY)
|
if(SOGEN_BUILD_STATIC)
|
||||||
add_compile_definitions(MOMO_BUILD_AS_LIBRARY=1)
|
add_compile_definitions(SOGEN_BUILD_STATIC=1)
|
||||||
else()
|
else()
|
||||||
add_compile_definitions(MOMO_BUILD_AS_LIBRARY=0)
|
add_compile_definitions(SOGEN_BUILD_STATIC=0)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
##########################################
|
##########################################
|
||||||
@@ -230,6 +230,13 @@ endif()
|
|||||||
|
|
||||||
option(SOGEN_STATIC_CRT "Use static CRT (/MT) instead of dynamic (/MD)" OFF)
|
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)
|
if(SOGEN_STATIC_CRT)
|
||||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||||
elseif(DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
|
elseif(DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ add_subdirectory(backend-selection)
|
|||||||
momo_add_subdirectory_and_get_targets("backends" BACKEND_TARGETS)
|
momo_add_subdirectory_and_get_targets("backends" BACKEND_TARGETS)
|
||||||
momo_targets_set_folder("backends" ${BACKEND_TARGETS})
|
momo_targets_set_folder("backends" ${BACKEND_TARGETS})
|
||||||
|
|
||||||
if (NOT MOMO_BUILD_AS_LIBRARY)
|
if (NOT SOGEN_BUILD_STATIC)
|
||||||
add_subdirectory(analyzer)
|
add_subdirectory(analyzer)
|
||||||
add_subdirectory(debugger)
|
add_subdirectory(debugger)
|
||||||
add_subdirectory(fuzzing-engine)
|
add_subdirectory(fuzzing-engine)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ file(GLOB_RECURSE SRC_FILES CONFIGURE_DEPENDS
|
|||||||
|
|
||||||
list(SORT SRC_FILES)
|
list(SORT SRC_FILES)
|
||||||
|
|
||||||
if(MOMO_BUILD_AS_LIBRARY)
|
if(SOGEN_BUILD_STATIC)
|
||||||
add_library(icicle-emulator STATIC ${SRC_FILES})
|
add_library(icicle-emulator STATIC ${SRC_FILES})
|
||||||
else()
|
else()
|
||||||
add_library(icicle-emulator SHARED ${SRC_FILES})
|
add_library(icicle-emulator SHARED ${SRC_FILES})
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
namespace icicle
|
namespace icicle
|
||||||
{
|
{
|
||||||
#if !MOMO_BUILD_AS_LIBRARY
|
#if !SOGEN_BUILD_STATIC
|
||||||
ICICLE_EMULATOR_DLL_STORAGE
|
ICICLE_EMULATOR_DLL_STORAGE
|
||||||
#endif
|
#endif
|
||||||
std::unique_ptr<x86_64_emulator> create_x86_64_emulator();
|
std::unique_ptr<x86_64_emulator> create_x86_64_emulator();
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ file(GLOB_RECURSE SRC_FILES CONFIGURE_DEPENDS
|
|||||||
|
|
||||||
list(SORT SRC_FILES)
|
list(SORT SRC_FILES)
|
||||||
|
|
||||||
if(MOMO_BUILD_AS_LIBRARY)
|
if(SOGEN_BUILD_STATIC)
|
||||||
add_library(unicorn-emulator STATIC ${SRC_FILES})
|
add_library(unicorn-emulator STATIC ${SRC_FILES})
|
||||||
else()
|
else()
|
||||||
add_library(unicorn-emulator SHARED ${SRC_FILES})
|
add_library(unicorn-emulator SHARED ${SRC_FILES})
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
namespace unicorn
|
namespace unicorn
|
||||||
{
|
{
|
||||||
#if !MOMO_BUILD_AS_LIBRARY
|
#if !SOGEN_BUILD_STATIC
|
||||||
UNICORN_EMULATOR_DLL_STORAGE
|
UNICORN_EMULATOR_DLL_STORAGE
|
||||||
#endif
|
#endif
|
||||||
std::unique_ptr<x86_64_emulator> create_x86_64_emulator();
|
std::unique_ptr<x86_64_emulator> create_x86_64_emulator();
|
||||||
|
|||||||
Reference in New Issue
Block a user