Sync with dev and resolve conflicts

This commit is contained in:
mio
2022-01-19 20:09:25 +01:00
2 changed files with 169 additions and 158 deletions

View File

@ -4,30 +4,36 @@
cmake_minimum_required(VERSION 3.1) cmake_minimum_required(VERSION 3.1)
# Workaround to fix wrong compiler on macos. # Workaround to fix wrong compiler on macos.
if ((APPLE) AND (NOT CMAKE_C_COMPILER)) if(APPLE AND NOT CMAKE_C_COMPILER)
set(CMAKE_C_COMPILER "/usr/bin/cc") set(CMAKE_C_COMPILER "/usr/bin/cc")
endif() endif()
# Detect if unicorn is compiled as the top-level project
set(PROJECT_IS_TOP_LEVEL OFF)
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(PROJECT_IS_TOP_LEVEL ON)
# Enable folder support
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
endif()
project(unicorn C) project(unicorn C)
set(UNICORN_VERSION_MAJOR 2) set(UNICORN_VERSION_MAJOR 2)
set(UNICORN_VERSION_MINOR 0) set(UNICORN_VERSION_MINOR 0)
set(UNICORN_VERSION_PATCH 0) set(UNICORN_VERSION_PATCH 0)
option(UNICORN_BUILD_SHARED "Build shared instead of static library" ON) option(BUILD_SHARED_LIBS "Build shared instead of static library" ${PROJECT_IS_TOP_LEVEL})
option(UNICORN_FUZZ "Enable fuzzing" OFF)
if (NOT UNICORN_ARCH) option(UNICORN_BUILD_TESTS "Build unicorn tests" ${PROJECT_IS_TOP_LEVEL})
# build all architectures option(UNICORN_INSTALL "Enable unicorn installation" ${PROJECT_IS_TOP_LEVEL})
set(UNICORN_ARCH "x86 arm aarch64 riscv mips sparc m68k ppc s390x") set(UNICORN_ARCH "x86;arm;aarch64;riscv;mips;sparc;m68k;ppc" CACHE STRING "Enabled unicorn architectures")
endif()
option(UNICORN_TRACER "Trace unicorn execution" OFF) option(UNICORN_TRACER "Trace unicorn execution" OFF)
string(TOUPPER ${UNICORN_ARCH} UNICORN_ARCH) foreach(ARCH_LOOP ${UNICORN_ARCH})
string(REPLACE " " ";" UNICORN_ARCH_LIST ${UNICORN_ARCH}) string(TOUPPER "${ARCH_LOOP}" ARCH_LOOP)
foreach(ARCH_LOOP ${UNICORN_ARCH_LIST})
set(UNICORN_HAS_${ARCH_LOOP} TRUE) set(UNICORN_HAS_${ARCH_LOOP} TRUE)
endforeach(ARCH_LOOP) endforeach()
if(MSVC) if(MSVC)
include_directories( include_directories(
@ -63,23 +69,29 @@ if(MSVC)
${MSVC_FLAG} ${MSVC_FLAG}
/I${CMAKE_CURRENT_SOURCE_DIR}/qemu/tcg/i386 /I${CMAKE_CURRENT_SOURCE_DIR}/qemu/tcg/i386
) )
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4018 /wd4098 /wd4244 /wd4267") # Disable some warnings
add_compile_options(
/wd4018
/wd4098
/wd4244
/wd4267
)
if(CMAKE_BUILD_TYPE STREQUAL "Debug") if(CMAKE_BUILD_TYPE STREQUAL "Debug")
string(REPLACE "/ZI" "/Zi" CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}) string(REPLACE "/ZI" "/Zi" CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
endif() endif()
# default use the multithread, static version of the run-time library. # default use the multithread, static version of the run-time library.
option(UNICORN_STATIC_MSVCRT "Embed static runtime library" ON) option(UNICORN_STATIC_MSVCRT "Embed static runtime library" ${PROJECT_IS_TOP_LEVEL})
if (UNICORN_STATIC_MSVCRT) if(UNICORN_STATIC_MSVCRT)
string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}) string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE}) string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
endif() endif()
else() else()
if (MINGW) if(MINGW)
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpmachine execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpmachine
OUTPUT_VARIABLE UC_COMPILER_VERSION) OUTPUT_VARIABLE UC_COMPILER_VERSION)
string(FIND "${UC_COMPILER_VERSION}" "i686" UC_RET) string(FIND "${UC_COMPILER_VERSION}" "i686" UC_RET)
if (${UC_RET} GREATER_EQUAL "0") if(${UC_RET} GREATER_EQUAL "0")
set(UNICORN_TARGET_ARCH "i386") set(UNICORN_TARGET_ARCH "i386")
set(UNICORN_CFLAGS -m32) set(UNICORN_CFLAGS -m32)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32")
@ -94,12 +106,12 @@ else()
string(FIND "${ANDROID_ABI}" "arm64" UC_RET) string(FIND "${ANDROID_ABI}" "arm64" UC_RET)
file(WRITE ${CMAKE_BINARY_DIR}/adb.sh "#!/bin/bash\n\n# Auto-generated by CMakeLists.txt\n\nadb shell mkdir -p /data/local/tmp/build\n") file(WRITE ${CMAKE_BINARY_DIR}/adb.sh "#!/bin/bash\n\n# Auto-generated by CMakeLists.txt\n\nadb shell mkdir -p /data/local/tmp/build\n")
if (${UC_RET} GREATER_EQUAL "0") if(${UC_RET} GREATER_EQUAL "0")
set(UNICORN_TARGET_ARCH "aarch64") set(UNICORN_TARGET_ARCH "aarch64")
else() else()
string(FIND "${ANDROID_ABI}" "armeabi" UC_RET) string(FIND "${ANDROID_ABI}" "armeabi" UC_RET)
if (${UC_RET} GREATER_EQUAL "0") if(${UC_RET} GREATER_EQUAL "0")
set(UNICORN_TARGET_ARCH "arm") set(UNICORN_TARGET_ARCH "arm")
else() else()
set(UNICORN_TARGET_ARCH "i386") set(UNICORN_TARGET_ARCH "i386")
@ -112,10 +124,10 @@ else()
while(TRUE) while(TRUE)
string(FIND "${UC_COMPILER_MACRO}" "__x86_64__" UC_RET) string(FIND "${UC_COMPILER_MACRO}" "__x86_64__" UC_RET)
if (${UC_RET} GREATER_EQUAL "0") if(${UC_RET} GREATER_EQUAL "0")
set(UNICORN_TARGET_ARCH "i386") set(UNICORN_TARGET_ARCH "i386")
string(FIND "${UC_COMPILER_MACRO}" "__ILP32__" UC_RET) string(FIND "${UC_COMPILER_MACRO}" "__ILP32__" UC_RET)
if (${UC_RET} GREATER_EQUAL "0") if(${UC_RET} GREATER_EQUAL "0")
set(UNICORN_CFLAGS -mx32) set(UNICORN_CFLAGS -mx32)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -mx32") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -mx32")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -mx32") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -mx32")
@ -127,47 +139,47 @@ else()
break() break()
endif() endif()
string(FIND "${UC_COMPILER_MACRO}" "__i386__" UC_RET) string(FIND "${UC_COMPILER_MACRO}" "__i386__" UC_RET)
if (${UC_RET} GREATER_EQUAL "0") if(${UC_RET} GREATER_EQUAL "0")
set(UNICORN_TARGET_ARCH "i386") set(UNICORN_TARGET_ARCH "i386")
break() break()
endif() endif()
string(FIND "${UC_COMPILER_MACRO}" "__arm__" UC_RET) string(FIND "${UC_COMPILER_MACRO}" "__arm__" UC_RET)
if (${UC_RET} GREATER_EQUAL "0") if(${UC_RET} GREATER_EQUAL "0")
set(UNICORN_TARGET_ARCH "arm") set(UNICORN_TARGET_ARCH "arm")
break() break()
endif() endif()
string(FIND "${UC_COMPILER_MACRO}" "__aarch64__" UC_RET) string(FIND "${UC_COMPILER_MACRO}" "__aarch64__" UC_RET)
if (${UC_RET} GREATER_EQUAL "0") if(${UC_RET} GREATER_EQUAL "0")
set(UNICORN_TARGET_ARCH "aarch64") set(UNICORN_TARGET_ARCH "aarch64")
break() break()
endif() endif()
string(FIND "${UC_COMPILER_MACRO}" "__mips__" UC_RET) string(FIND "${UC_COMPILER_MACRO}" "__mips__" UC_RET)
if (${UC_RET} GREATER_EQUAL "0") if(${UC_RET} GREATER_EQUAL "0")
set(UNICORN_TARGET_ARCH "mips") set(UNICORN_TARGET_ARCH "mips")
break() break()
endif() endif()
string(FIND "${UC_COMPILER_MACRO}" "__sparc__" UC_RET) string(FIND "${UC_COMPILER_MACRO}" "__sparc__" UC_RET)
if (${UC_RET} GREATER_EQUAL "0") if(${UC_RET} GREATER_EQUAL "0")
set(UNICORN_TARGET_ARCH "sparc") set(UNICORN_TARGET_ARCH "sparc")
break() break()
endif() endif()
string(FIND "${UC_COMPILER_MACRO}" "__ia64__" UC_RET) string(FIND "${UC_COMPILER_MACRO}" "__ia64__" UC_RET)
if (${UC_RET} GREATER_EQUAL "0") if(${UC_RET} GREATER_EQUAL "0")
set(UNICORN_TARGET_ARCH "ia64") set(UNICORN_TARGET_ARCH "ia64")
break() break()
endif() endif()
string(FIND "${UC_COMPILER_MACRO}" "_ARCH_PPC" UC_RET) string(FIND "${UC_COMPILER_MACRO}" "_ARCH_PPC" UC_RET)
if (${UC_RET} GREATER_EQUAL "0") if(${UC_RET} GREATER_EQUAL "0")
set(UNICORN_TARGET_ARCH "ppc") set(UNICORN_TARGET_ARCH "ppc")
break() break()
endif() endif()
string(FIND "${UC_COMPILER_MACRO}" "__riscv" UC_RET) string(FIND "${UC_COMPILER_MACRO}" "__riscv" UC_RET)
if (${UC_RET} GREATER_EQUAL "0") if(${UC_RET} GREATER_EQUAL "0")
set(UNICORN_TARGET_ARCH "riscv") set(UNICORN_TARGET_ARCH "riscv")
break() break()
endif() endif()
string(FIND "${UC_COMPILER_MACRO}" "__s390__" UC_RET) string(FIND "${UC_COMPILER_MACRO}" "__s390__" UC_RET)
if (${UC_RET} GREATER_EQUAL "0") if(${UC_RET} GREATER_EQUAL "0")
set(UNICORN_TARGET_ARCH "s390") set(UNICORN_TARGET_ARCH "s390")
break() break()
endif() endif()
@ -176,75 +188,75 @@ else()
endif() endif()
set(EXTRA_CFLAGS "--extra-cflags=") set(EXTRA_CFLAGS "--extra-cflags=")
if (UNICORN_HAS_X86) if(UNICORN_HAS_X86)
set (EXTRA_CFLAGS "${EXTRA_CFLAGS}-DUNICORN_HAS_X86 ") set(EXTRA_CFLAGS "${EXTRA_CFLAGS}-DUNICORN_HAS_X86 ")
endif() endif()
if (UNICORN_HAS_ARM) if(UNICORN_HAS_ARM)
set (EXTRA_CFLAGS "${EXTRA_CFLAGS}-DUNICORN_HAS_ARM -DUNICORN_HAS_ARMEB ") set(EXTRA_CFLAGS "${EXTRA_CFLAGS}-DUNICORN_HAS_ARM -DUNICORN_HAS_ARMEB ")
endif() endif()
if (UNICORN_HAS_AARCH64) if(UNICORN_HAS_AARCH64)
set (EXTRA_CFLAGS "${EXTRA_CFLAGS}-DUNICORN_HAS_ARM64 -DUNICORN_HAS_ARM64EB ") set(EXTRA_CFLAGS "${EXTRA_CFLAGS}-DUNICORN_HAS_ARM64 -DUNICORN_HAS_ARM64EB ")
endif() endif()
if (UNICORN_HAS_M68K) if(UNICORN_HAS_M68K)
set (EXTRA_CFLAGS "${EXTRA_CFLAGS}-DUNICORN_HAS_M68K ") set(EXTRA_CFLAGS "${EXTRA_CFLAGS}-DUNICORN_HAS_M68K ")
endif() endif()
if (UNICORN_HAS_MIPS) if(UNICORN_HAS_MIPS)
set (EXTRA_CFLAGS "${EXTRA_CFLAGS}-DUNICORN_HAS_MIPS -DUNICORN_HAS_MIPSEL -DUNICORN_HAS_MIPS64 -DUNICORN_HAS_MIPS64EL ") set(EXTRA_CFLAGS "${EXTRA_CFLAGS}-DUNICORN_HAS_MIPS -DUNICORN_HAS_MIPSEL -DUNICORN_HAS_MIPS64 -DUNICORN_HAS_MIPS64EL ")
endif() endif()
if (UNICORN_HAS_SPARC) if(UNICORN_HAS_SPARC)
set (EXTRA_CFLAGS "${EXTRA_CFLAGS}-DUNICORN_HAS_SPARC ") set(EXTRA_CFLAGS "${EXTRA_CFLAGS}-DUNICORN_HAS_SPARC ")
endif() endif()
if (UNICORN_HAS_PPC) if(UNICORN_HAS_PPC)
set (EXTRA_CFLAGS "${EXTRA_CFLAGS}-DUNICORN_HAS_PPC ") set(EXTRA_CFLAGS "${EXTRA_CFLAGS}-DUNICORN_HAS_PPC ")
endif() endif()
if (UNICORN_HAS_RISCV) if(UNICORN_HAS_RISCV)
set (EXTRA_CFLAGS "${EXTRA_CFLAGS}-DUNICORN_HAS_RISCV ") set(EXTRA_CFLAGS "${EXTRA_CFLAGS}-DUNICORN_HAS_RISCV ")
endif() endif()
if (UNICORN_HAS_S390X) if (UNICORN_HAS_S390X)
set (EXTRA_CFLAGS "${EXTRA_CFLAGS}-DUNICORN_HAS_S390X ") set (EXTRA_CFLAGS "${EXTRA_CFLAGS}-DUNICORN_HAS_S390X ")
endif() endif()
set (EXTRA_CFLAGS "${EXTRA_CFLAGS}-fPIC") set(EXTRA_CFLAGS "${EXTRA_CFLAGS}-fPIC")
if(ANDROID_ABI) if(ANDROID_ABI)
set (EXTRA_CFLAGS "${EXTRA_CFLAGS} --target=${CMAKE_C_COMPILER_TARGET}") set(EXTRA_CFLAGS "${EXTRA_CFLAGS} --target=${CMAKE_C_COMPILER_TARGET}")
set (EXTRA_CFLAGS "${EXTRA_CFLAGS} --sysroot=${CMAKE_SYSROOT}") set(EXTRA_CFLAGS "${EXTRA_CFLAGS} --sysroot=${CMAKE_SYSROOT}")
endif() endif()
if (UNICORN_FUZZ) if(UNICORN_FUZZ)
set (EXTRA_CFLAGS "${EXTRA_CFLAGS} ${CMAKE_C_FLAGS}") set(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${CMAKE_C_FLAGS}")
endif() endif()
if(UNICORN_TRACER) if(UNICORN_TRACER)
set (EXTRA_CFLAGS "${EXTRA_CFLAGS} -DUNICORN_TRACER") set (EXTRA_CFLAGS "${EXTRA_CFLAGS} -DUNICORN_TRACER")
endif() endif()
set(TARGET_LIST "--target-list=") set(TARGET_LIST "--target-list=")
if (UNICORN_HAS_X86) if(UNICORN_HAS_X86)
set (TARGET_LIST "${TARGET_LIST}x86_64-softmmu, ") set(TARGET_LIST "${TARGET_LIST}x86_64-softmmu, ")
endif() endif()
if (UNICORN_HAS_ARM) if(UNICORN_HAS_ARM)
set (TARGET_LIST "${TARGET_LIST}arm-softmmu, armeb-softmmu, ") set(TARGET_LIST "${TARGET_LIST}arm-softmmu, armeb-softmmu, ")
endif() endif()
if (UNICORN_HAS_AARCH64) if(UNICORN_HAS_AARCH64)
set (TARGET_LIST "${TARGET_LIST}aarch64-softmmu, aarch64eb-softmmu, ") set(TARGET_LIST "${TARGET_LIST}aarch64-softmmu, aarch64eb-softmmu, ")
endif() endif()
if (UNICORN_HAS_M68K) if(UNICORN_HAS_M68K)
set (TARGET_LIST "${TARGET_LIST}m68k-softmmu, ") set(TARGET_LIST "${TARGET_LIST}m68k-softmmu, ")
endif() endif()
if (UNICORN_HAS_MIPS) if(UNICORN_HAS_MIPS)
set (TARGET_LIST "${TARGET_LIST}mips-softmmu, mipsel-softmmu, mips64-softmmu, mips64el-softmmu, ") set(TARGET_LIST "${TARGET_LIST}mips-softmmu, mipsel-softmmu, mips64-softmmu, mips64el-softmmu, ")
endif() endif()
if (UNICORN_HAS_SPARC) if(UNICORN_HAS_SPARC)
set (TARGET_LIST "${TARGET_LIST}sparc-softmmu, sparc64-softmmu, ") set(TARGET_LIST "${TARGET_LIST}sparc-softmmu, sparc64-softmmu, ")
endif() endif()
if (UNICORN_HAS_PPC) if(UNICORN_HAS_PPC)
set (TARGET_LIST "${TARGET_LIST}ppc-softmmu, ppc64-softmmu, ") set(TARGET_LIST "${TARGET_LIST}ppc-softmmu, ppc64-softmmu, ")
endif() endif()
if (UNICORN_HAS_RISCV) if(UNICORN_HAS_RISCV)
set (TARGET_LIST "${TARGET_LIST}riscv32-softmmu, riscv64-softmmu, ") set(TARGET_LIST "${TARGET_LIST}riscv32-softmmu, riscv64-softmmu, ")
endif() endif()
if (UNICORN_HAS_S390X) if(UNICORN_HAS_S390X)
set (TARGET_LIST "${TARGET_LIST}s390x-softmmu, ") set(TARGET_LIST "${TARGET_LIST}s390x-softmmu, ")
endif() endif()
set (TARGET_LIST "${TARGET_LIST} ") set(TARGET_LIST "${TARGET_LIST} ")
# GEN config-host.mak & target directories # GEN config-host.mak & target directories
execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/configure execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/configure
@ -257,13 +269,13 @@ else()
INPUT_FILE ${CMAKE_BINARY_DIR}/config-host.mak INPUT_FILE ${CMAKE_BINARY_DIR}/config-host.mak
OUTPUT_FILE ${CMAKE_BINARY_DIR}/config-host.h OUTPUT_FILE ${CMAKE_BINARY_DIR}/config-host.h
) )
if (UNICORN_HAS_X86) if(UNICORN_HAS_X86)
execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/create_config execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/create_config
INPUT_FILE ${CMAKE_BINARY_DIR}/x86_64-softmmu/config-target.mak INPUT_FILE ${CMAKE_BINARY_DIR}/x86_64-softmmu/config-target.mak
OUTPUT_FILE ${CMAKE_BINARY_DIR}/x86_64-softmmu/config-target.h OUTPUT_FILE ${CMAKE_BINARY_DIR}/x86_64-softmmu/config-target.h
) )
endif() endif()
if (UNICORN_HAS_ARM) if(UNICORN_HAS_ARM)
execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/create_config execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/create_config
INPUT_FILE ${CMAKE_BINARY_DIR}/arm-softmmu/config-target.mak INPUT_FILE ${CMAKE_BINARY_DIR}/arm-softmmu/config-target.mak
OUTPUT_FILE ${CMAKE_BINARY_DIR}/arm-softmmu/config-target.h OUTPUT_FILE ${CMAKE_BINARY_DIR}/arm-softmmu/config-target.h
@ -273,7 +285,7 @@ else()
OUTPUT_FILE ${CMAKE_BINARY_DIR}/armeb-softmmu/config-target.h OUTPUT_FILE ${CMAKE_BINARY_DIR}/armeb-softmmu/config-target.h
) )
endif() endif()
if (UNICORN_HAS_AARCH64) if(UNICORN_HAS_AARCH64)
execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/create_config execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/create_config
INPUT_FILE ${CMAKE_BINARY_DIR}/aarch64-softmmu/config-target.mak INPUT_FILE ${CMAKE_BINARY_DIR}/aarch64-softmmu/config-target.mak
OUTPUT_FILE ${CMAKE_BINARY_DIR}/aarch64-softmmu/config-target.h OUTPUT_FILE ${CMAKE_BINARY_DIR}/aarch64-softmmu/config-target.h
@ -283,13 +295,13 @@ else()
OUTPUT_FILE ${CMAKE_BINARY_DIR}/aarch64eb-softmmu/config-target.h OUTPUT_FILE ${CMAKE_BINARY_DIR}/aarch64eb-softmmu/config-target.h
) )
endif() endif()
if (UNICORN_HAS_M68K) if(UNICORN_HAS_M68K)
execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/create_config execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/create_config
INPUT_FILE ${CMAKE_BINARY_DIR}/m68k-softmmu/config-target.mak INPUT_FILE ${CMAKE_BINARY_DIR}/m68k-softmmu/config-target.mak
OUTPUT_FILE ${CMAKE_BINARY_DIR}/m68k-softmmu/config-target.h OUTPUT_FILE ${CMAKE_BINARY_DIR}/m68k-softmmu/config-target.h
) )
endif() endif()
if (UNICORN_HAS_MIPS) if(UNICORN_HAS_MIPS)
execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/create_config execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/create_config
INPUT_FILE ${CMAKE_BINARY_DIR}/mips-softmmu/config-target.mak INPUT_FILE ${CMAKE_BINARY_DIR}/mips-softmmu/config-target.mak
OUTPUT_FILE ${CMAKE_BINARY_DIR}/mips-softmmu/config-target.h OUTPUT_FILE ${CMAKE_BINARY_DIR}/mips-softmmu/config-target.h
@ -307,7 +319,7 @@ else()
OUTPUT_FILE ${CMAKE_BINARY_DIR}/mips64el-softmmu/config-target.h OUTPUT_FILE ${CMAKE_BINARY_DIR}/mips64el-softmmu/config-target.h
) )
endif() endif()
if (UNICORN_HAS_SPARC) if(UNICORN_HAS_SPARC)
execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/create_config execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/create_config
INPUT_FILE ${CMAKE_BINARY_DIR}/sparc-softmmu/config-target.mak INPUT_FILE ${CMAKE_BINARY_DIR}/sparc-softmmu/config-target.mak
OUTPUT_FILE ${CMAKE_BINARY_DIR}/sparc-softmmu/config-target.h OUTPUT_FILE ${CMAKE_BINARY_DIR}/sparc-softmmu/config-target.h
@ -317,7 +329,7 @@ else()
OUTPUT_FILE ${CMAKE_BINARY_DIR}/sparc64-softmmu/config-target.h OUTPUT_FILE ${CMAKE_BINARY_DIR}/sparc64-softmmu/config-target.h
) )
endif() endif()
if (UNICORN_HAS_PPC) if(UNICORN_HAS_PPC)
execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/create_config execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/create_config
INPUT_FILE ${CMAKE_BINARY_DIR}/ppc-softmmu/config-target.mak INPUT_FILE ${CMAKE_BINARY_DIR}/ppc-softmmu/config-target.mak
OUTPUT_FILE ${CMAKE_BINARY_DIR}/ppc-softmmu/config-target.h OUTPUT_FILE ${CMAKE_BINARY_DIR}/ppc-softmmu/config-target.h
@ -327,7 +339,7 @@ else()
OUTPUT_FILE ${CMAKE_BINARY_DIR}/ppc64-softmmu/config-target.h OUTPUT_FILE ${CMAKE_BINARY_DIR}/ppc64-softmmu/config-target.h
) )
endif() endif()
if (UNICORN_HAS_RISCV) if(UNICORN_HAS_RISCV)
execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/create_config execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/create_config
INPUT_FILE ${CMAKE_BINARY_DIR}/riscv32-softmmu/config-target.mak INPUT_FILE ${CMAKE_BINARY_DIR}/riscv32-softmmu/config-target.mak
OUTPUT_FILE ${CMAKE_BINARY_DIR}/riscv32-softmmu/config-target.h OUTPUT_FILE ${CMAKE_BINARY_DIR}/riscv32-softmmu/config-target.h
@ -352,7 +364,7 @@ else()
-Wall -Wall
-fPIC -fPIC
) )
if (APPLE) if(APPLE)
# This warning is disabled by default for gcc and doesn't cause any bug. # This warning is disabled by default for gcc and doesn't cause any bug.
add_compile_options( add_compile_options(
-Wno-missing-braces -Wno-missing-braces
@ -387,8 +399,8 @@ set(UNICORN_ARCH_COMMON
qemu/accel/tcg/translator.c qemu/accel/tcg/translator.c
) )
if (UNICORN_HAS_X86) if(UNICORN_HAS_X86)
add_library(x86_64-softmmu add_library(x86_64-softmmu STATIC
${UNICORN_ARCH_COMMON} ${UNICORN_ARCH_COMMON}
qemu/hw/i386/x86.c qemu/hw/i386/x86.c
@ -429,7 +441,7 @@ else()
) )
# Log and pow # Log and pow
target_link_libraries(x86_64-softmmu m) target_link_libraries(x86_64-softmmu PRIVATE m)
endif() endif()
if(UNICORN_TRACER) if(UNICORN_TRACER)
@ -438,8 +450,8 @@ endif()
endif() endif()
if (UNICORN_HAS_ARM) if(UNICORN_HAS_ARM)
add_library(arm-softmmu add_library(arm-softmmu STATIC
${UNICORN_ARCH_COMMON} ${UNICORN_ARCH_COMMON}
qemu/target/arm/cpu.c qemu/target/arm/cpu.c
@ -478,7 +490,7 @@ if(UNICORN_TRACER)
target_compile_options(arm-softmmu PRIVATE -DUNICORN_TRACER) target_compile_options(arm-softmmu PRIVATE -DUNICORN_TRACER)
endif() endif()
add_library(armeb-softmmu add_library(armeb-softmmu STATIC
${UNICORN_ARCH_COMMON} ${UNICORN_ARCH_COMMON}
qemu/target/arm/cpu.c qemu/target/arm/cpu.c
@ -519,8 +531,8 @@ endif()
endif() endif()
if (UNICORN_HAS_AARCH64) if(UNICORN_HAS_AARCH64)
add_library(aarch64-softmmu add_library(aarch64-softmmu STATIC
${UNICORN_ARCH_COMMON} ${UNICORN_ARCH_COMMON}
qemu/target/arm/cpu64.c qemu/target/arm/cpu64.c
@ -565,7 +577,7 @@ if(UNICORN_TRACER)
target_compile_options(aarch64-softmmu PRIVATE -DUNICORN_TRACER) target_compile_options(aarch64-softmmu PRIVATE -DUNICORN_TRACER)
endif() endif()
add_library(aarch64eb-softmmu add_library(aarch64eb-softmmu STATIC
${UNICORN_ARCH_COMMON} ${UNICORN_ARCH_COMMON}
qemu/target/arm/cpu64.c qemu/target/arm/cpu64.c
@ -612,8 +624,8 @@ endif()
endif() endif()
if (UNICORN_HAS_M68K) if(UNICORN_HAS_M68K)
add_library(m68k-softmmu add_library(m68k-softmmu STATIC
${UNICORN_ARCH_COMMON} ${UNICORN_ARCH_COMMON}
qemu/target/m68k/cpu.c qemu/target/m68k/cpu.c
@ -647,8 +659,8 @@ endif()
endif() endif()
if (UNICORN_HAS_MIPS) if(UNICORN_HAS_MIPS)
add_library(mips-softmmu add_library(mips-softmmu STATIC
${UNICORN_ARCH_COMMON} ${UNICORN_ARCH_COMMON}
qemu/target/mips/cp0_helper.c qemu/target/mips/cp0_helper.c
@ -684,7 +696,7 @@ if(UNICORN_TRACER)
target_compile_options(mips-softmmu PRIVATE -DUNICORN_TRACER) target_compile_options(mips-softmmu PRIVATE -DUNICORN_TRACER)
endif() endif()
add_library(mipsel-softmmu add_library(mipsel-softmmu STATIC
${UNICORN_ARCH_COMMON} ${UNICORN_ARCH_COMMON}
qemu/target/mips/cp0_helper.c qemu/target/mips/cp0_helper.c
@ -720,7 +732,7 @@ if(UNICORN_TRACER)
target_compile_options(mipsel-softmmu PRIVATE -DUNICORN_TRACER) target_compile_options(mipsel-softmmu PRIVATE -DUNICORN_TRACER)
endif() endif()
add_library(mips64-softmmu add_library(mips64-softmmu STATIC
${UNICORN_ARCH_COMMON} ${UNICORN_ARCH_COMMON}
qemu/target/mips/cp0_helper.c qemu/target/mips/cp0_helper.c
@ -756,7 +768,7 @@ if(UNICORN_TRACER)
target_compile_options(mips64-softmmu PRIVATE -DUNICORN_TRACER) target_compile_options(mips64-softmmu PRIVATE -DUNICORN_TRACER)
endif() endif()
add_library(mips64el-softmmu add_library(mips64el-softmmu STATIC
${UNICORN_ARCH_COMMON} ${UNICORN_ARCH_COMMON}
qemu/target/mips/cp0_helper.c qemu/target/mips/cp0_helper.c
@ -794,8 +806,8 @@ endif()
endif() endif()
if (UNICORN_HAS_SPARC) if(UNICORN_HAS_SPARC)
add_library(sparc-softmmu add_library(sparc-softmmu STATIC
${UNICORN_ARCH_COMMON} ${UNICORN_ARCH_COMMON}
qemu/target/sparc/cc_helper.c qemu/target/sparc/cc_helper.c
@ -830,7 +842,7 @@ if(UNICORN_TRACER)
target_compile_options(sparc-softmmu PRIVATE -DUNICORN_TRACER) target_compile_options(sparc-softmmu PRIVATE -DUNICORN_TRACER)
endif() endif()
add_library(sparc64-softmmu add_library(sparc64-softmmu STATIC
${UNICORN_ARCH_COMMON} ${UNICORN_ARCH_COMMON}
qemu/target/sparc/cc_helper.c qemu/target/sparc/cc_helper.c
@ -868,8 +880,8 @@ endif()
endif() endif()
if (UNICORN_HAS_PPC) if(UNICORN_HAS_PPC)
add_library(ppc-softmmu add_library(ppc-softmmu STATIC
${UNICORN_ARCH_COMMON} ${UNICORN_ARCH_COMMON}
qemu/hw/ppc/ppc.c qemu/hw/ppc/ppc.c
@ -917,7 +929,7 @@ if(UNICORN_TRACER)
target_compile_options(ppc-softmmu PRIVATE -DUNICORN_TRACER) target_compile_options(ppc-softmmu PRIVATE -DUNICORN_TRACER)
endif() endif()
add_library(ppc64-softmmu add_library(ppc64-softmmu STATIC
${UNICORN_ARCH_COMMON} ${UNICORN_ARCH_COMMON}
qemu/hw/ppc/ppc.c qemu/hw/ppc/ppc.c
@ -971,8 +983,8 @@ endif()
endif() endif()
if (UNICORN_HAS_RISCV) if(UNICORN_HAS_RISCV)
add_library(riscv32-softmmu add_library(riscv32-softmmu STATIC
${UNICORN_ARCH_COMMON} ${UNICORN_ARCH_COMMON}
qemu/target/riscv/cpu.c qemu/target/riscv/cpu.c
@ -1005,7 +1017,7 @@ if(UNICORN_TRACER)
target_compile_options(riscv32-softmmu PRIVATE -DUNICORN_TRACER) target_compile_options(riscv32-softmmu PRIVATE -DUNICORN_TRACER)
endif() endif()
add_library(riscv64-softmmu add_library(riscv64-softmmu STATIC
${UNICORN_ARCH_COMMON} ${UNICORN_ARCH_COMMON}
qemu/target/riscv/cpu.c qemu/target/riscv/cpu.c
@ -1130,14 +1142,14 @@ set(UNICORN_COMMON_SRCS
) )
# A workaround to avoid circle dependency between unicorn and *-softmmu # A workaround to avoid circle dependency between unicorn and *-softmmu
if (MSVC) if(MSVC)
set(UNICORN_COMMON_SRCS set(UNICORN_COMMON_SRCS
${UNICORN_COMMON_SRCS} ${UNICORN_COMMON_SRCS}
qemu/util/oslib-win32.c qemu/util/oslib-win32.c
qemu/util/qemu-thread-win32.c qemu/util/qemu-thread-win32.c
) )
if (CMAKE_SIZEOF_VOID_P EQUAL 8) if(CMAKE_SIZEOF_VOID_P EQUAL 8)
if (MSVC_VERSION LESS 1600 AND MSVC_IDE) if(MSVC_VERSION LESS 1600 AND MSVC_IDE)
add_custom_command(OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/build/setjmp-wrapper-win32.dir/setjmp-wrapper-win32.obj" add_custom_command(OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/build/setjmp-wrapper-win32.dir/setjmp-wrapper-win32.obj"
COMMAND ml64 /c /nologo /Fo"${CMAKE_CURRENT_SOURCE_DIR}/build/setjmp-wrapper-win32.dir/setjmp-wrapper-win32.obj" /W3 /errorReport:prompt /Ta"${CMAKE_CURRENT_SOURCE_DIR}/qemu/util/setjmp-wrapper-win32.asm" COMMAND ml64 /c /nologo /Fo"${CMAKE_CURRENT_SOURCE_DIR}/build/setjmp-wrapper-win32.dir/setjmp-wrapper-win32.obj" /W3 /errorReport:prompt /Ta"${CMAKE_CURRENT_SOURCE_DIR}/qemu/util/setjmp-wrapper-win32.asm"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/qemu/util/setjmp-wrapper-win32.asm" DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/qemu/util/setjmp-wrapper-win32.asm"
@ -1156,91 +1168,87 @@ else()
) )
endif() endif()
add_library(unicorn-common add_library(unicorn-common STATIC
${UNICORN_COMMON_SRCS} ${UNICORN_COMMON_SRCS}
) )
if (NOT MSVC AND NOT ANDROID_ABI) if(NOT MSVC AND NOT ANDROID_ABI)
target_link_libraries(unicorn-common pthread) target_link_libraries(unicorn-common PRIVATE pthread)
endif() endif()
if (UNICORN_BUILD_SHARED) add_library(unicorn
add_library(unicorn SHARED
${UNICORN_SRCS} ${UNICORN_SRCS}
) )
if (ANDROID_ABI)
if(BUILD_SHARED_LIBS)
if(ANDROID_ABI)
file(APPEND ${CMAKE_BINARY_DIR}/adb.sh "adb push ./libunicorn.so /data/local/tmp/build/\n") file(APPEND ${CMAKE_BINARY_DIR}/adb.sh "adb push ./libunicorn.so /data/local/tmp/build/\n")
endif() endif()
else()
add_library(unicorn STATIC
${UNICORN_SRCS}
)
endif() endif()
enable_testing()
set(UNICORN_LINK_LIBRARIES ${UNICORN_LINK_LIBRARIES} unicorn-common) set(UNICORN_LINK_LIBRARIES ${UNICORN_LINK_LIBRARIES} unicorn-common)
if (UNICORN_HAS_X86) if(UNICORN_HAS_X86)
set(UNICORN_COMPILE_OPTIONS ${UNICORN_COMPILE_OPTIONS} -DUNICORN_HAS_X86) set(UNICORN_COMPILE_OPTIONS ${UNICORN_COMPILE_OPTIONS} -DUNICORN_HAS_X86)
set(UNICORN_LINK_LIBRARIES ${UNICORN_LINK_LIBRARIES} x86_64-softmmu) set(UNICORN_LINK_LIBRARIES ${UNICORN_LINK_LIBRARIES} x86_64-softmmu)
set(UNICORN_SAMPLE_FILE ${UNICORN_SAMPLE_FILE} sample_x86 sample_x86_32_gdt_and_seg_regs sample_batch_reg mem_apis shellcode) set(UNICORN_SAMPLE_FILE ${UNICORN_SAMPLE_FILE} sample_x86 sample_x86_32_gdt_and_seg_regs sample_batch_reg mem_apis shellcode)
target_link_libraries(x86_64-softmmu unicorn-common) target_link_libraries(x86_64-softmmu PRIVATE unicorn-common)
set(UNICORN_TEST_FILE ${UNICORN_TEST_FILE} test_x86) set(UNICORN_TEST_FILE ${UNICORN_TEST_FILE} test_x86)
endif() endif()
if (UNICORN_HAS_ARM) if(UNICORN_HAS_ARM)
set(UNICORN_COMPILE_OPTIONS ${UNICORN_COMPILE_OPTIONS} -DUNICORN_HAS_ARM) set(UNICORN_COMPILE_OPTIONS ${UNICORN_COMPILE_OPTIONS} -DUNICORN_HAS_ARM)
set(UNICORN_LINK_LIBRARIES ${UNICORN_LINK_LIBRARIES} arm-softmmu armeb-softmmu) set(UNICORN_LINK_LIBRARIES ${UNICORN_LINK_LIBRARIES} arm-softmmu armeb-softmmu)
set(UNICORN_SAMPLE_FILE ${UNICORN_SAMPLE_FILE} sample_arm) set(UNICORN_SAMPLE_FILE ${UNICORN_SAMPLE_FILE} sample_arm)
target_link_libraries(arm-softmmu unicorn-common) target_link_libraries(arm-softmmu PRIVATE unicorn-common)
target_link_libraries(armeb-softmmu unicorn-common) target_link_libraries(armeb-softmmu PRIVATE unicorn-common)
set(UNICORN_TEST_FILE ${UNICORN_TEST_FILE} test_arm) set(UNICORN_TEST_FILE ${UNICORN_TEST_FILE} test_arm)
endif() endif()
if (UNICORN_HAS_AARCH64) if(UNICORN_HAS_AARCH64)
set(UNICORN_COMPILE_OPTIONS ${UNICORN_COMPILE_OPTIONS} -DUNICORN_HAS_ARM64) set(UNICORN_COMPILE_OPTIONS ${UNICORN_COMPILE_OPTIONS} -DUNICORN_HAS_ARM64)
set(UNICORN_LINK_LIBRARIES ${UNICORN_LINK_LIBRARIES} aarch64-softmmu aarch64eb-softmmu) set(UNICORN_LINK_LIBRARIES ${UNICORN_LINK_LIBRARIES} aarch64-softmmu aarch64eb-softmmu)
set(UNICORN_SAMPLE_FILE ${UNICORN_SAMPLE_FILE} sample_arm64) set(UNICORN_SAMPLE_FILE ${UNICORN_SAMPLE_FILE} sample_arm64)
target_link_libraries(aarch64-softmmu unicorn-common) target_link_libraries(aarch64-softmmu PRIVATE unicorn-common)
target_link_libraries(aarch64eb-softmmu unicorn-common) target_link_libraries(aarch64eb-softmmu PRIVATE unicorn-common)
set(UNICORN_TEST_FILE ${UNICORN_TEST_FILE} test_arm64) set(UNICORN_TEST_FILE ${UNICORN_TEST_FILE} test_arm64)
endif() endif()
if (UNICORN_HAS_M68K) if(UNICORN_HAS_M68K)
set(UNICORN_COMPILE_OPTIONS ${UNICORN_COMPILE_OPTIONS} -DUNICORN_HAS_M68K) set(UNICORN_COMPILE_OPTIONS ${UNICORN_COMPILE_OPTIONS} -DUNICORN_HAS_M68K)
set(UNICORN_LINK_LIBRARIES ${UNICORN_LINK_LIBRARIES} m68k-softmmu) set(UNICORN_LINK_LIBRARIES ${UNICORN_LINK_LIBRARIES} m68k-softmmu)
set(UNICORN_SAMPLE_FILE ${UNICORN_SAMPLE_FILE} sample_m68k) set(UNICORN_SAMPLE_FILE ${UNICORN_SAMPLE_FILE} sample_m68k)
target_link_libraries(m68k-softmmu unicorn-common) target_link_libraries(m68k-softmmu PRIVATE unicorn-common)
set(UNICORN_TEST_FILE ${UNICORN_TEST_FILE} test_m68k) set(UNICORN_TEST_FILE ${UNICORN_TEST_FILE} test_m68k)
endif() endif()
if (UNICORN_HAS_MIPS) if(UNICORN_HAS_MIPS)
set(UNICORN_COMPILE_OPTIONS ${UNICORN_COMPILE_OPTIONS} -DUNICORN_HAS_MIPS -DUNICORN_HAS_MIPSEL -DUNICORN_HAS_MIPS64 -DUNICORN_HAS_MIPS64EL) set(UNICORN_COMPILE_OPTIONS ${UNICORN_COMPILE_OPTIONS} -DUNICORN_HAS_MIPS -DUNICORN_HAS_MIPSEL -DUNICORN_HAS_MIPS64 -DUNICORN_HAS_MIPS64EL)
set(UNICORN_LINK_LIBRARIES ${UNICORN_LINK_LIBRARIES} mips-softmmu mipsel-softmmu mips64-softmmu mips64el-softmmu) set(UNICORN_LINK_LIBRARIES ${UNICORN_LINK_LIBRARIES} mips-softmmu mipsel-softmmu mips64-softmmu mips64el-softmmu)
set(UNICORN_SAMPLE_FILE ${UNICORN_SAMPLE_FILE} sample_mips) set(UNICORN_SAMPLE_FILE ${UNICORN_SAMPLE_FILE} sample_mips)
target_link_libraries(mips-softmmu unicorn-common) target_link_libraries(mips-softmmu PRIVATE unicorn-common)
target_link_libraries(mipsel-softmmu unicorn-common) target_link_libraries(mipsel-softmmu PRIVATE unicorn-common)
target_link_libraries(mips64-softmmu unicorn-common) target_link_libraries(mips64-softmmu PRIVATE unicorn-common)
target_link_libraries(mips64el-softmmu unicorn-common) target_link_libraries(mips64el-softmmu PRIVATE unicorn-common)
set(UNICORN_TEST_FILE ${UNICORN_TEST_FILE} test_mips) set(UNICORN_TEST_FILE ${UNICORN_TEST_FILE} test_mips)
endif() endif()
if (UNICORN_HAS_SPARC) if(UNICORN_HAS_SPARC)
set(UNICORN_COMPILE_OPTIONS ${UNICORN_COMPILE_OPTIONS} -DUNICORN_HAS_SPARC) set(UNICORN_COMPILE_OPTIONS ${UNICORN_COMPILE_OPTIONS} -DUNICORN_HAS_SPARC)
set(UNICORN_LINK_LIBRARIES ${UNICORN_LINK_LIBRARIES} sparc-softmmu sparc64-softmmu) set(UNICORN_LINK_LIBRARIES ${UNICORN_LINK_LIBRARIES} sparc-softmmu sparc64-softmmu)
set(UNICORN_SAMPLE_FILE ${UNICORN_SAMPLE_FILE} sample_sparc) set(UNICORN_SAMPLE_FILE ${UNICORN_SAMPLE_FILE} sample_sparc)
target_link_libraries(sparc-softmmu unicorn-common) target_link_libraries(sparc-softmmu PRIVATE unicorn-common)
target_link_libraries(sparc64-softmmu unicorn-common) target_link_libraries(sparc64-softmmu PRIVATE unicorn-common)
set(UNICORN_TEST_FILE ${UNICORN_TEST_FILE} test_sparc) set(UNICORN_TEST_FILE ${UNICORN_TEST_FILE} test_sparc)
endif() endif()
if (UNICORN_HAS_PPC) if(UNICORN_HAS_PPC)
set(UNICORN_COMPILE_OPTIONS ${UNICORN_COMPILE_OPTIONS} -DUNICORN_HAS_PPC) set(UNICORN_COMPILE_OPTIONS ${UNICORN_COMPILE_OPTIONS} -DUNICORN_HAS_PPC)
set(UNICORN_LINK_LIBRARIES ${UNICORN_LINK_LIBRARIES} ppc-softmmu ppc64-softmmu) set(UNICORN_LINK_LIBRARIES ${UNICORN_LINK_LIBRARIES} ppc-softmmu ppc64-softmmu)
set(UNICORN_SAMPLE_FILE ${UNICORN_SAMPLE_FILE} sample_ppc) set(UNICORN_SAMPLE_FILE ${UNICORN_SAMPLE_FILE} sample_ppc)
target_link_libraries(ppc-softmmu unicorn-common) target_link_libraries(ppc-softmmu PRIVATE unicorn-common)
target_link_libraries(ppc64-softmmu unicorn-common) target_link_libraries(ppc64-softmmu PRIVATE unicorn-common)
set(UNICORN_TEST_FILE ${UNICORN_TEST_FILE} test_ppc) set(UNICORN_TEST_FILE ${UNICORN_TEST_FILE} test_ppc)
endif() endif()
if (UNICORN_HAS_RISCV) if(UNICORN_HAS_RISCV)
set(UNICORN_COMPILE_OPTIONS ${UNICORN_COMPILE_OPTIONS} -DUNICORN_HAS_RISCV) set(UNICORN_COMPILE_OPTIONS ${UNICORN_COMPILE_OPTIONS} -DUNICORN_HAS_RISCV)
set(UNICORN_LINK_LIBRARIES ${UNICORN_LINK_LIBRARIES} riscv32-softmmu riscv64-softmmu) set(UNICORN_LINK_LIBRARIES ${UNICORN_LINK_LIBRARIES} riscv32-softmmu riscv64-softmmu)
set(UNICORN_SAMPLE_FILE ${UNICORN_SAMPLE_FILE} sample_riscv) set(UNICORN_SAMPLE_FILE ${UNICORN_SAMPLE_FILE} sample_riscv)
target_link_libraries(riscv32-softmmu unicorn-common) target_link_libraries(riscv32-softmmu PRIVATE unicorn-common)
target_link_libraries(riscv64-softmmu unicorn-common) target_link_libraries(riscv64-softmmu PRIVATE unicorn-common)
set(UNICORN_TEST_FILE ${UNICORN_TEST_FILE} test_riscv) set(UNICORN_TEST_FILE ${UNICORN_TEST_FILE} test_riscv)
endif() endif()
if (UNICORN_HAS_S390X) if (UNICORN_HAS_S390X)
@ -1269,7 +1277,7 @@ target_compile_options(unicorn PRIVATE
${UNICORN_COMPILE_OPTIONS} ${UNICORN_COMPILE_OPTIONS}
) )
if (MINGW) if(MINGW)
set(UNICORN_LINK_LIBRARIES ${UNICORN_LINK_LIBRARIES} pthread) set(UNICORN_LINK_LIBRARIES ${UNICORN_LINK_LIBRARIES} pthread)
endif() endif()
@ -1278,7 +1286,7 @@ if(UNICORN_TARGET_ARCH STREQUAL "riscv")
endif() endif()
if(MSVC) if(MSVC)
if (UNICORN_BUILD_SHARED) if(BUILD_SHARED_LIBS)
target_compile_options(unicorn PRIVATE target_compile_options(unicorn PRIVATE
-DUNICORN_SHARED -DUNICORN_SHARED
) )
@ -1328,45 +1336,48 @@ if(UNICORN_FUZZ)
${CMAKE_CURRENT_SOURCE_DIR}/tests/fuzz/fuzz_emu_${SUFFIX}.c ${CMAKE_CURRENT_SOURCE_DIR}/tests/fuzz/fuzz_emu_${SUFFIX}.c
${CMAKE_CURRENT_SOURCE_DIR}/tests/fuzz/onedir.c ${CMAKE_CURRENT_SOURCE_DIR}/tests/fuzz/onedir.c
) )
target_link_libraries(fuzz_emu_${SUFFIX} target_link_libraries(fuzz_emu_${SUFFIX} PRIVATE
${SAMPLES_LIB} ${SAMPLES_LIB}
) )
endforeach() endforeach()
else() endif()
if(UNICORN_BUILD_TESTS)
enable_testing()
foreach(SAMPLE_FILE ${UNICORN_SAMPLE_FILE}) foreach(SAMPLE_FILE ${UNICORN_SAMPLE_FILE})
add_executable(${SAMPLE_FILE} add_executable(${SAMPLE_FILE}
${CMAKE_CURRENT_SOURCE_DIR}/samples/${SAMPLE_FILE}.c ${CMAKE_CURRENT_SOURCE_DIR}/samples/${SAMPLE_FILE}.c
) )
target_link_libraries(${SAMPLE_FILE} target_link_libraries(${SAMPLE_FILE} PRIVATE
${SAMPLES_LIB} ${SAMPLES_LIB}
) )
endforeach(SAMPLE_FILE) endforeach()
foreach(TEST_FILE ${UNICORN_TEST_FILE}) foreach(TEST_FILE ${UNICORN_TEST_FILE})
add_executable(${TEST_FILE} add_executable(${TEST_FILE}
${CMAKE_CURRENT_SOURCE_DIR}/tests/unit/${TEST_FILE}.c ${CMAKE_CURRENT_SOURCE_DIR}/tests/unit/${TEST_FILE}.c
) )
target_link_libraries(${TEST_FILE} target_link_libraries(${TEST_FILE} PRIVATE
${SAMPLES_LIB} ${SAMPLES_LIB}
) )
add_test(${TEST_FILE} ${TEST_FILE}) add_test(${TEST_FILE} ${TEST_FILE})
if (ANDROID_ABI) if(ANDROID_ABI)
file(APPEND ${CMAKE_BINARY_DIR}/adb.sh "adb push ${TEST_FILE} /data/local/tmp/build/\n") file(APPEND ${CMAKE_BINARY_DIR}/adb.sh "adb push ${TEST_FILE} /data/local/tmp/build/\n")
file(APPEND ${CMAKE_BINARY_DIR}/adb.sh "adb shell \"chmod +x /data/local/tmp/build/${TEST_FILE}\"\n") file(APPEND ${CMAKE_BINARY_DIR}/adb.sh "adb shell \"chmod +x /data/local/tmp/build/${TEST_FILE}\"\n")
file(APPEND ${CMAKE_BINARY_DIR}/adb.sh "adb shell \'LD_LIBRARY_PATH=/data/local/tmp/build:$LD_LIBRARY_PATH /data/local/tmp/build/${TEST_FILE}\' || exit -1\n") file(APPEND ${CMAKE_BINARY_DIR}/adb.sh "adb shell \'LD_LIBRARY_PATH=/data/local/tmp/build:$LD_LIBRARY_PATH /data/local/tmp/build/${TEST_FILE}\' || exit -1\n")
endif() endif()
endforeach(TEST_FILE) endforeach()
endif() endif()
target_include_directories(unicorn PUBLIC target_include_directories(unicorn PUBLIC
include include
) )
if(NOT MSVC) if(UNICORN_INSTALL AND NOT MSVC)
include("GNUInstallDirs") include("GNUInstallDirs")
file(GLOB UNICORN_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/unicorn/*.h) file(GLOB UNICORN_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/unicorn/*.h)
install(TARGETS unicorn install(TARGETS unicorn
RUNTIME DESTINATION bin RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
) )

View File

@ -87,7 +87,7 @@ fn main() {
cmd.current_dir(&unicorn_dir) cmd.current_dir(&unicorn_dir)
.arg("-B") .arg("-B")
.arg("rust_build") .arg("rust_build")
.arg("-DUNICORN_BUILD_SHARED=off") .arg("-DBUILD_SHARED_LIBS=OFF")
.arg("-G") .arg("-G")
.arg("Visual Studio 16 2019"); .arg("Visual Studio 16 2019");
@ -127,7 +127,7 @@ fn main() {
cmd.current_dir(&unicorn_dir) cmd.current_dir(&unicorn_dir)
.arg("-B") .arg("-B")
.arg("rust_build") .arg("rust_build")
.arg("-DUNICORN_BUILD_SHARED=off"); .arg("-DBUILD_SHARED_LIBS=OFF");
if profile == "debug" { if profile == "debug" {
cmd.arg("-DCMAKE_BUILD_TYPE=Debug"); cmd.arg("-DCMAKE_BUILD_TYPE=Debug");