cmake: add option to build unicorn as a static library (#1275)
This commit is contained in:
@ -21,6 +21,8 @@ set(UNICORN_VERSION_MAJOR 1)
|
|||||||
set(UNICORN_VERSION_MINOR 0)
|
set(UNICORN_VERSION_MINOR 0)
|
||||||
set(UNICORN_VERSION_PATCH 2)
|
set(UNICORN_VERSION_PATCH 2)
|
||||||
|
|
||||||
|
option(UNICORN_BUILD_SHARED "Build shared instead of static library" ON)
|
||||||
|
|
||||||
if(NOT UNICORN_ARCH)
|
if(NOT UNICORN_ARCH)
|
||||||
# build all architectures
|
# build all architectures
|
||||||
set(UNICORN_ARCH "x86 arm aarch64 m68k mips sparc")
|
set(UNICORN_ARCH "x86 arm aarch64 m68k mips sparc")
|
||||||
@ -830,9 +832,15 @@ else()
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (UNICORN_BUILD_SHARED)
|
||||||
add_library(unicorn SHARED
|
add_library(unicorn SHARED
|
||||||
${UNICORN_SRCS}
|
${UNICORN_SRCS}
|
||||||
)
|
)
|
||||||
|
else()
|
||||||
|
add_library(unicorn STATIC
|
||||||
|
${UNICORN_SRCS}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (UNICORN_HAS_X86)
|
if (UNICORN_HAS_X86)
|
||||||
set(UNICRON_COMPILE_OPTIONS ${UNICRON_COMPILE_OPTIONS} -DUNICORN_HAS_X86)
|
set(UNICRON_COMPILE_OPTIONS ${UNICRON_COMPILE_OPTIONS} -DUNICORN_HAS_X86)
|
||||||
@ -865,19 +873,21 @@ if (UNICORN_HAS_SPARC)
|
|||||||
set(UNICRON_SAMPLE_FILE ${UNICRON_SAMPLE_FILE} sample_sparc)
|
set(UNICRON_SAMPLE_FILE ${UNICRON_SAMPLE_FILE} sample_sparc)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
if(MSVC)
|
|
||||||
target_compile_options(unicorn PRIVATE
|
target_compile_options(unicorn PRIVATE
|
||||||
${UNICRON_COMPILE_OPTIONS}
|
${UNICRON_COMPILE_OPTIONS}
|
||||||
|
)
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
if (UNICORN_BUILD_SHARED)
|
||||||
|
target_compile_options(unicorn PRIVATE
|
||||||
-DUNICORN_SHARED
|
-DUNICORN_SHARED
|
||||||
)
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
target_link_libraries(unicorn
|
target_link_libraries(unicorn
|
||||||
${UNICRON_LINK_LIBRARIES}
|
${UNICRON_LINK_LIBRARIES}
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
target_compile_options(unicorn PRIVATE
|
|
||||||
${UNICRON_COMPILE_OPTIONS}
|
|
||||||
)
|
|
||||||
target_link_libraries(unicorn
|
target_link_libraries(unicorn
|
||||||
${UNICRON_LINK_LIBRARIES}
|
${UNICRON_LINK_LIBRARIES}
|
||||||
m
|
m
|
||||||
|
Reference in New Issue
Block a user