2018-01-10 15:33:15 +00:00
|
|
|
include(ExternalProject)
|
2018-01-05 10:26:55 +00:00
|
|
|
|
2018-01-22 15:20:10 +00:00
|
|
|
if(CMAKE_C_COMPILER)
|
|
|
|
set(CMAKE_C_COMPILER_OPTION "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}")
|
|
|
|
endif()
|
|
|
|
if(CMAKE_CXX_COMPILER)
|
|
|
|
set(CMAKE_CXX_COMPILER_OPTION "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}")
|
|
|
|
endif()
|
|
|
|
|
2019-04-25 12:07:45 +00:00
|
|
|
if(CAPSTONE_LOCAL_DIR)
|
|
|
|
message(STATUS "Capstone: using local Capstone directory.")
|
|
|
|
|
|
|
|
ExternalProject_Add(capstone-project
|
|
|
|
DOWNLOAD_COMMAND ""
|
|
|
|
SOURCE_DIR "${CAPSTONE_LOCAL_DIR}"
|
|
|
|
CMAKE_ARGS
|
|
|
|
# This does not work on MSVC, but may be useful on Linux.
|
|
|
|
-DCMAKE_BUILD_TYPE=Release
|
|
|
|
-DCAPSTONE_BUILD_STATIC=ON
|
|
|
|
-DCAPSTONE_BUILD_SHARED=OFF
|
2020-03-23 09:01:03 +00:00
|
|
|
-DCAPSTONE_BUILD_STATIC_RUNTIME=${RETDEC_MSVC_STATIC_RUNTIME}
|
2019-04-25 12:07:45 +00:00
|
|
|
-DCAPSTONE_BUILD_TESTS=OFF
|
|
|
|
-DCAPSTONE_X86_ATT_DISABLE=OFF
|
|
|
|
# Enabled architectures.
|
|
|
|
-DCAPSTONE_ARM_SUPPORT=ON
|
|
|
|
-DCAPSTONE_MIPS_SUPPORT=ON
|
|
|
|
-DCAPSTONE_PPC_SUPPORT=ON
|
|
|
|
-DCAPSTONE_X86_SUPPORT=ON
|
|
|
|
# Disabled architectures.
|
|
|
|
-DCAPSTONE_ARM64_SUPPORT=OFF
|
|
|
|
-DCAPSTONE_M68K_SUPPORT=OFF
|
|
|
|
-DCAPSTONE_SPARC_SUPPORT=OFF
|
|
|
|
-DCAPSTONE_SYSZ_SUPPORT=OFF
|
|
|
|
-DCAPSTONE_XCORE_SUPPORT=OFF
|
|
|
|
-DCAPSTONE_TMS320C64X_SUPPORT=OFF
|
|
|
|
-DCAPSTONE_M680X_SUPPORT=OFF
|
|
|
|
# Force the use of the same compiler as used to build the top-level
|
|
|
|
# project. Otherwise, the external project may pick up a different
|
|
|
|
# compiler, which may result in link errors.
|
|
|
|
"${CMAKE_C_COMPILER_OPTION}"
|
|
|
|
"${CMAKE_CXX_COMPILER_OPTION}"
|
2020-01-22 12:02:53 +00:00
|
|
|
# Patch the Capstone sources.
|
|
|
|
PATCH_COMMAND
|
|
|
|
${CMAKE_COMMAND} -Dcapstone_path=<SOURCE_DIR> -P ${CMAKE_CURRENT_SOURCE_DIR}/patch.cmake
|
2019-04-25 12:07:45 +00:00
|
|
|
# Disable the update step.
|
|
|
|
UPDATE_COMMAND ""
|
|
|
|
# Disable the install step.
|
|
|
|
INSTALL_COMMAND ""
|
|
|
|
)
|
|
|
|
force_configure_step(capstone-project)
|
|
|
|
else()
|
|
|
|
message(STATUS "Capstone: using remote Capstone revision.")
|
2019-05-30 11:39:34 +00:00
|
|
|
|
2019-04-25 12:07:45 +00:00
|
|
|
ExternalProject_Add(capstone-project
|
2020-01-27 09:13:41 +00:00
|
|
|
URL ${CAPSTONE_URL}
|
|
|
|
URL_HASH SHA256=${CAPSTONE_ARCHIVE_SHA256}
|
2019-04-25 12:07:45 +00:00
|
|
|
DOWNLOAD_NAME capstone.zip
|
|
|
|
CMAKE_ARGS
|
|
|
|
# This does not work on MSVC, but may be useful on Linux.
|
|
|
|
-DCMAKE_BUILD_TYPE=Release
|
|
|
|
-DCAPSTONE_BUILD_STATIC=ON
|
|
|
|
-DCAPSTONE_BUILD_SHARED=OFF
|
2020-03-23 09:01:03 +00:00
|
|
|
-DCAPSTONE_BUILD_STATIC_RUNTIME=${RETDEC_MSVC_STATIC_RUNTIME}
|
2019-04-25 12:07:45 +00:00
|
|
|
-DCAPSTONE_BUILD_TESTS=OFF
|
|
|
|
-DCAPSTONE_X86_ATT_DISABLE=OFF
|
|
|
|
# Enabled architectures.
|
|
|
|
-DCAPSTONE_ARM_SUPPORT=ON
|
|
|
|
-DCAPSTONE_MIPS_SUPPORT=ON
|
|
|
|
-DCAPSTONE_PPC_SUPPORT=ON
|
|
|
|
-DCAPSTONE_X86_SUPPORT=ON
|
2019-05-27 08:28:42 +00:00
|
|
|
-DCAPSTONE_ARM64_SUPPORT=ON
|
2019-04-25 12:07:45 +00:00
|
|
|
# Disabled architectures.
|
|
|
|
-DCAPSTONE_M68K_SUPPORT=OFF
|
|
|
|
-DCAPSTONE_SPARC_SUPPORT=OFF
|
|
|
|
-DCAPSTONE_SYSZ_SUPPORT=OFF
|
|
|
|
-DCAPSTONE_XCORE_SUPPORT=OFF
|
|
|
|
-DCAPSTONE_TMS320C64X_SUPPORT=OFF
|
|
|
|
-DCAPSTONE_M680X_SUPPORT=OFF
|
|
|
|
# Force the use of the same compiler as used to build the top-level
|
|
|
|
# project. Otherwise, the external project may pick up a different
|
|
|
|
# compiler, which may result in link errors.
|
|
|
|
"${CMAKE_C_COMPILER_OPTION}"
|
|
|
|
"${CMAKE_CXX_COMPILER_OPTION}"
|
2020-01-22 12:02:53 +00:00
|
|
|
# Patch the Capstone sources.
|
|
|
|
PATCH_COMMAND
|
|
|
|
${CMAKE_COMMAND} -Dcapstone_path=<SOURCE_DIR> -P ${CMAKE_CURRENT_SOURCE_DIR}/patch.cmake
|
2019-04-25 12:07:45 +00:00
|
|
|
# Disable the update step.
|
|
|
|
UPDATE_COMMAND ""
|
|
|
|
# Disable the install step.
|
|
|
|
INSTALL_COMMAND ""
|
|
|
|
LOG_DOWNLOAD ON
|
|
|
|
LOG_CONFIGURE ON
|
|
|
|
LOG_BUILD ON
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
check_if_variable_changed(CAPSTONE_LOCAL_DIR CHANGED)
|
|
|
|
if(CHANGED)
|
|
|
|
ExternalProject_Get_Property(capstone-project binary_dir)
|
|
|
|
message(STATUS "Capstone: path to Capstone directory changed -> cleaning CMake files in ${binary_dir}.")
|
|
|
|
clean_cmake_files(${binary_dir})
|
|
|
|
endif()
|
2018-01-05 10:26:55 +00:00
|
|
|
|
2018-01-10 15:33:15 +00:00
|
|
|
ExternalProject_Get_Property(capstone-project source_dir)
|
|
|
|
ExternalProject_Get_Property(capstone-project binary_dir)
|
|
|
|
|
|
|
|
# Add libraries.
|
|
|
|
add_library(capstone INTERFACE)
|
|
|
|
add_dependencies(capstone capstone-project)
|
|
|
|
target_include_directories(capstone SYSTEM INTERFACE ${source_dir}/include)
|
2019-04-17 09:50:05 +00:00
|
|
|
target_include_directories(capstone SYSTEM INTERFACE ${source_dir}/arch)
|
2018-01-12 11:25:13 +00:00
|
|
|
target_link_libraries(capstone INTERFACE debug ${binary_dir}/${DEBUG_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}capstone${CMAKE_STATIC_LIBRARY_SUFFIX})
|
|
|
|
target_link_libraries(capstone INTERFACE optimized ${binary_dir}/${RELEASE_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}capstone${CMAKE_STATIC_LIBRARY_SUFFIX})
|