Skip to content

Commit 78014b8

Browse files
authored
Merge pull request #6 from blshkv/fix-use-system-libs
cmake: prefer system capstone and zydis over CPM downloads
2 parents 4cfdfa6 + 41c92df commit 78014b8

2 files changed

Lines changed: 37 additions & 19 deletions

File tree

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
include(cmake/CPM.cmake)
22

33
function(setup_dependencies)
4-
CPMAddPackage(
5-
NAME capstone
6-
GIT_TAG "6.0.0-Alpha7"
7-
GITHUB_REPOSITORY "capstone-engine/capstone"
4+
find_package(capstone 6.0 QUIET)
85

9-
OPTIONS
10-
"CAPSTONE_ARCHITECTURE_DEFAULT OFF"
11-
"CAPSTONE_ARM_SUPPORT ON"
12-
"CAPSTONE_AARCH64_SUPPORT ON"
13-
)
6+
if(capstone_FOUND)
7+
if(NOT TARGET capstone)
8+
add_library(capstone ALIAS capstone::capstone_shared)
9+
endif()
10+
message(STATUS "Using system capstone")
11+
else()
12+
CPMAddPackage(
13+
NAME capstone
14+
GIT_TAG "6.0.0-Alpha7"
15+
GITHUB_REPOSITORY "capstone-engine/capstone"
16+
17+
OPTIONS
18+
"CAPSTONE_ARCHITECTURE_DEFAULT OFF"
19+
"CAPSTONE_ARM_SUPPORT ON"
20+
"CAPSTONE_AARCH64_SUPPORT ON"
21+
)
22+
endif()
1423
endfunction()

x86/cmake/Dependencies.cmake

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
include(cmake/CPM.cmake)
22

33
function(setup_dependencies)
4-
CPMAddPackage(
5-
NAME zydis
6-
VERSION "4.1.1"
7-
GITHUB_REPOSITORY "zyantific/zydis"
8-
EXCLUDE_FROM_ALL YES
4+
find_package(zydis QUIET)
95

10-
OPTIONS
11-
"CMAKE_POSITION_INDEPENDENT_CODE ON"
12-
"ZYDIS_BUILD_TOOLS OFF"
13-
"ZYDIS_BUILD_EXAMPLES OFF"
14-
)
6+
if(zydis_FOUND)
7+
if(NOT TARGET Zydis)
8+
add_library(Zydis ALIAS Zydis::Zydis)
9+
endif()
10+
message(STATUS "Using system zydis")
11+
else()
12+
CPMAddPackage(
13+
NAME zydis
14+
VERSION "4.1.1"
15+
GITHUB_REPOSITORY "zyantific/zydis"
16+
EXCLUDE_FROM_ALL YES
17+
18+
OPTIONS
19+
"CMAKE_POSITION_INDEPENDENT_CODE ON"
20+
"ZYDIS_BUILD_TOOLS OFF"
21+
"ZYDIS_BUILD_EXAMPLES OFF"
22+
)
23+
endif()
1524
endfunction()

0 commit comments

Comments
 (0)