Skip to content

Commit

Permalink
FetchContent to fetch capstone and update capstone version from 4.0.2…
Browse files Browse the repository at this point in the history
… to 5.0-rc4
  • Loading branch information
kubo committed Jul 5, 2023
1 parent 094d830 commit 08e9901
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 37 deletions.
38 changes: 18 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,25 +87,26 @@ endfunction(add_subdirectory_pic)
# capstone
#
if (DISASM_CAPSTONE)
configure_file(cmake/capstone.cmake.in capstone-download/CMakeLists.txt)
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/capstone-download"
)
execute_process(COMMAND "${CMAKE_COMMAND}" --build .
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/capstone-download"
FetchContent_Declare(
capstone
GIT_REPOSITORY https://github.com/capstone-engine/capstone.git
GIT_TAG 5.0-rc4
GIT_SHALLOW TRUE
)
FetchContent_GetProperties(capstone)
if(NOT capstone_POPULATED)
FetchContent_Populate(capstone)
string(TOUPPER ${FUNCHOOK_CPU} FUNCHOOK_CPU_UPPER)
set(CAPSTONE_BUILD_SHARED OFF CACHE BOOL "")
set(CAPSTONE_BUILD_STATIC_RUNTIME OFF CACHE BOOL "")
set(CAPSTONE_BUILD_TESTS OFF CACHE BOOL "")
set(CAPSTONE_BUILD_CSTOOL OFF CACHE BOOL "")
set(CAPSTONE_ARCHITECTURE_DEFAULT OFF CACHE BOOL "")
set(CAPSTONE_${FUNCHOOK_CPU_UPPER}_SUPPORT ON CACHE BOOL "")
add_subdirectory_pic(${capstone_SOURCE_DIR} ${capstone_BINARY_DIR})
endif()

string(TOUPPER ${FUNCHOOK_CPU} FUNCHOOK_CPU_UPPER)

set(CAPSTONE_BUILD_SHARED OFF CACHE BOOL "")
set(CAPSTONE_BUILD_STATIC_RUNTIME OFF CACHE BOOL "")
set(CAPSTONE_BUILD_TESTS OFF CACHE BOOL "")
set(CAPSTONE_BUILD_CSTOOL OFF CACHE BOOL "")
set(CAPSTONE_ARCHITECTURE_DEFAULT OFF CACHE BOOL "")
set(CAPSTONE_${FUNCHOOK_CPU_UPPER}_SUPPORT ON CACHE BOOL "")
add_subdirectory_pic(${CMAKE_CURRENT_BINARY_DIR}/capstone-src ${CMAKE_CURRENT_BINARY_DIR}/capstone-build)

list(APPEND FUNCHOOK_DEPS capstone-static)
list(APPEND FUNCHOOK_DEPS capstone)
set(DISASM capstone)
endif ()

Expand Down Expand Up @@ -225,9 +226,6 @@ function (add_funchook_library target_name target_type)
set_target_properties(${target_name} PROPERTIES ${FUNCHOOK_PROPERTIES})
target_include_directories(${target_name} PUBLIC include)
target_include_directories(${target_name} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) # to include config.h
if (DISASM_CAPSTONE)
target_include_directories(${target_name} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/capstone-src/include)
endif()
target_link_libraries(${target_name} PRIVATE ${FUNCHOOK_DEPS})
if (HAVE_FVISIBILITY_HIDDEN)
target_compile_options(${target_name} PRIVATE -fvisibility=hidden)
Expand Down
17 changes: 0 additions & 17 deletions cmake/capstone.cmake.in

This file was deleted.

0 comments on commit 08e9901

Please sign in to comment.