mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-19 19:53:56 +00:00
Changes to make the 'emulator' project suitable for submodules (#76)
- Added the MOMO_BUILD_AS_LIBRARY CMake option to allow ease of using of the emulator project as a library/submodule. - windows_emulator project also brings in the 'common' dependency - 'common' dependency now renamed to 'emulator-common'
This commit is contained in:
@@ -3,6 +3,13 @@ cmake_minimum_required(VERSION 3.26.4)
|
||||
##########################################
|
||||
|
||||
option(MOMO_ENABLE_SANITIZER "Enable sanitizer" OFF)
|
||||
option(MOMO_BUILD_AS_LIBRARY "Configure and Build the emulator as a shared library (without the samples and tests)" OFF)
|
||||
|
||||
if(MOMO_BUILD_AS_LIBRARY)
|
||||
add_compile_definitions(MOMO_BUILD_AS_LIBRARY=1)
|
||||
else()
|
||||
add_compile_definitions(MOMO_BUILD_AS_LIBRARY=0)
|
||||
endif()
|
||||
|
||||
##########################################
|
||||
|
||||
|
||||
@@ -2,11 +2,13 @@ add_subdirectory(common)
|
||||
add_subdirectory(emulator)
|
||||
add_subdirectory(unicorn-emulator)
|
||||
add_subdirectory(windows-emulator)
|
||||
add_subdirectory(analyzer)
|
||||
add_subdirectory(fuzzing-engine)
|
||||
add_subdirectory(fuzzer)
|
||||
if(WIN32)
|
||||
add_subdirectory(bad-sample)
|
||||
add_subdirectory(test-sample)
|
||||
if (NOT MOMO_BUILD_AS_LIBRARY)
|
||||
add_subdirectory(analyzer)
|
||||
add_subdirectory(fuzzing-engine)
|
||||
add_subdirectory(fuzzer)
|
||||
if(WIN32)
|
||||
add_subdirectory(bad-sample)
|
||||
add_subdirectory(test-sample)
|
||||
endif()
|
||||
add_subdirectory(windows-emulator-test)
|
||||
endif()
|
||||
add_subdirectory(windows-emulator-test)
|
||||
|
||||
@@ -13,7 +13,6 @@ momo_assign_source_group(${SRC_FILES})
|
||||
target_precompile_headers(analyzer PRIVATE std_include.hpp)
|
||||
|
||||
target_link_libraries(analyzer PRIVATE
|
||||
common
|
||||
reflect
|
||||
windows-emulator
|
||||
)
|
||||
|
||||
@@ -7,6 +7,6 @@ file(GLOB_RECURSE SRC_FILES CONFIGURE_DEPENDS
|
||||
list(SORT SRC_FILES)
|
||||
|
||||
add_executable(bad-sample ${SRC_FILES})
|
||||
target_link_libraries(bad-sample PRIVATE common)
|
||||
target_link_libraries(bad-sample PRIVATE emulator-common)
|
||||
|
||||
momo_assign_source_group(${SRC_FILES})
|
||||
|
||||
@@ -3,14 +3,14 @@ file(GLOB_RECURSE SRC_FILES CONFIGURE_DEPENDS
|
||||
*.hpp
|
||||
)
|
||||
|
||||
add_library(common ${SRC_FILES})
|
||||
add_library(emulator-common ${SRC_FILES})
|
||||
|
||||
momo_assign_source_group(${SRC_FILES})
|
||||
|
||||
target_include_directories(common INTERFACE "${CMAKE_CURRENT_LIST_DIR}")
|
||||
target_include_directories(emulator-common INTERFACE "${CMAKE_CURRENT_LIST_DIR}")
|
||||
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
target_link_libraries(common PUBLIC
|
||||
target_link_libraries(emulator-common PUBLIC
|
||||
Threads::Threads
|
||||
)
|
||||
|
||||
@@ -13,7 +13,6 @@ momo_assign_source_group(${SRC_FILES})
|
||||
target_precompile_headers(fuzzer PRIVATE std_include.hpp)
|
||||
|
||||
target_link_libraries(fuzzer PRIVATE
|
||||
common
|
||||
fuzzing-engine
|
||||
windows-emulator
|
||||
)
|
||||
|
||||
@@ -11,7 +11,7 @@ add_library(fuzzing-engine ${SRC_FILES})
|
||||
momo_assign_source_group(${SRC_FILES})
|
||||
|
||||
target_link_libraries(fuzzing-engine PRIVATE
|
||||
common
|
||||
emulator-common
|
||||
)
|
||||
|
||||
target_include_directories(fuzzing-engine INTERFACE
|
||||
|
||||
@@ -6,11 +6,15 @@ file(GLOB_RECURSE SRC_FILES CONFIGURE_DEPENDS
|
||||
|
||||
list(SORT SRC_FILES)
|
||||
|
||||
add_library(unicorn-emulator SHARED ${SRC_FILES})
|
||||
if(MOMO_BUILD_AS_LIBRARY)
|
||||
add_library(unicorn-emulator STATIC ${SRC_FILES})
|
||||
else()
|
||||
add_library(unicorn-emulator SHARED ${SRC_FILES})
|
||||
endif()
|
||||
|
||||
target_include_directories(unicorn-emulator INTERFACE
|
||||
"${CMAKE_CURRENT_LIST_DIR}"
|
||||
)
|
||||
|
||||
target_link_libraries(unicorn-emulator PUBLIC emulator)
|
||||
target_link_libraries(unicorn-emulator PRIVATE unicorn common)
|
||||
target_link_libraries(unicorn-emulator PRIVATE unicorn emulator-common)
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
namespace unicorn
|
||||
{
|
||||
#if !MOMO_BUILD_AS_LIBRARY
|
||||
UNICORN_EMULATOR_DLL_STORAGE
|
||||
#endif
|
||||
std::unique_ptr<x64_emulator> create_x64_emulator();
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ momo_assign_source_group(${SRC_FILES})
|
||||
|
||||
target_link_libraries(windows-emulator-test PRIVATE
|
||||
gtest
|
||||
common
|
||||
windows-emulator
|
||||
)
|
||||
|
||||
|
||||
@@ -13,12 +13,12 @@ momo_assign_source_group(${SRC_FILES})
|
||||
target_precompile_headers(windows-emulator PRIVATE std_include.hpp)
|
||||
|
||||
target_link_libraries(windows-emulator PRIVATE
|
||||
common
|
||||
unicorn-emulator
|
||||
mini-gdbstub
|
||||
)
|
||||
|
||||
target_link_libraries(windows-emulator PUBLIC
|
||||
emulator-common
|
||||
emulator
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user