blob: 6b35d8d8e46a024c37532ab26e61c55c700dfb16 [file] [log] [blame]
Nguyen Anh Quynhf1c3acb2014-05-28 22:39:23 +08001This documentation explains how to compile Capstone with CMake, focus on
2using Microsoft Visual C as the compiler.
3
4To compile Capstone on *nix, see COMPILE.TXT.
5
6To compile Capstone on Windows using Visual Studio, see COMPILE_MSVC.TXT.
7
8 *-*-*-*-*-*
9
10This documentation requires CMake & Windows SDK or MS Visual Studio installed on
11your machine.
12
13Get CMake for free from http://www.cmake.org.
14
15
16
17(0) Tailor Capstone to your need.
18
Nguyen Anh Quynhed1246d2018-03-31 17:29:22 +080019 Out of 12 archtitectures supported by Capstone (Arm, Arm64, M68K, Mips, PPC,
20 Sparc, SystemZ, X86, XCore, M680X, TMS320C64x & EVM), if you just need several selected archs,
Nguyen Anh Quynh74a114e2015-10-05 16:14:19 +080021 run "cmake" with the unwanted archs disabled (set to 0) as followings.
Nguyen Anh Quynhf1c3acb2014-05-28 22:39:23 +080022
Nguyen Anh Quynh9cb4d8b2014-09-20 10:59:01 +080023 - CAPSTONE_ARM_SUPPORT: support ARM. Run cmake with -DCAPSTONE_ARM_SUPPORT=0 to remove ARM.
24 - CAPSTONE_ARM64_SUPPORT: support ARM64. Run cmake with -DCAPSTONE_ARM64_SUPPORT=0 to remove ARM64.
Wolfgang Schwotzer22b4d0e2017-10-21 15:44:36 +020025 - CAPSTONE_M680X_SUPPORT: support M680X. Run cmake with -DCAPSTONE_M680X_SUPPORT=0 to remove M680X.
Nguyen Anh Quynh74a114e2015-10-05 16:14:19 +080026 - CAPSTONE_M68K_SUPPORT: support M68K. Run cmake with -DCAPSTONE_M68K_SUPPORT=0 to remove M68K.
Nguyen Anh Quynh9cb4d8b2014-09-20 10:59:01 +080027 - CAPSTONE_MIPS_SUPPORT: support Mips. Run cmake with -DCAPSTONE_MIPS_SUPPORT=0 to remove Mips.
28 - CAPSTONE_PPC_SUPPORT: support PPC. Run cmake with -DCAPSTONE_PPC_SUPPORT=0 to remove PPC.
29 - CAPSTONE_SPARC_SUPPORT: support Sparc. Run cmake with -DCAPSTONE_SPARC_SUPPORT=0 to remove Sparc.
30 - CAPSTONE_SYSZ_SUPPORT: support SystemZ. Run cmake with -DCAPSTONE_SYSZ_SUPPORT=0 to remove SystemZ.
31 - CAPSTONE_XCORE_SUPPORT: support XCore. Run cmake with -DCAPSTONE_XCORE_SUPPORT=0 to remove XCore.
32 - CAPSTONE_X86_SUPPORT: support X86. Run cmake with -DCAPSTONE_X86_SUPPORT=0 to remove X86.
Nguyen Anh Quynhed1246d2018-03-31 17:29:22 +080033 - CAPSTONE_X86_TMS320C64X: support TMS320C64X. Run cmake with -DCAPSTONE_TMS320C64X_SUPPORT=0 to remove TMS320C64X.
34 - CAPSTONE_X86_M680X: support M680X. Run cmake with -DCAPSTONE_M680X_SUPPORT=0 to remove M680X.
35 - CAPSTONE_X86_EVM: support EVM. Run cmake with -DCAPSTONE_EVM_SUPPORT=0 to remove EVM.
Nguyen Anh Quynhf1c3acb2014-05-28 22:39:23 +080036
Wolfgang Schwotzer22b4d0e2017-10-21 15:44:36 +020037 By default, all 10 architectures are compiled in.
Nguyen Anh Quynhf1c3acb2014-05-28 22:39:23 +080038
39
40 Besides, Capstone also allows some more customization via following macros.
41
Nguyen Anh Quynh9cb4d8b2014-09-20 10:59:01 +080042 - CAPSTONE_USE_SYS_DYN_MEM: change this to OFF to use your own dynamic memory management.
43 - CAPSTONE_BUILD_DIET: change this to ON to make the binaries more compact.
44 - CAPSTONE_X86_REDUCE: change this to ON to make X86 binary smaller.
45 - CAPSTONE_X86_ATT_DISABLE: change this to ON to disable AT&T syntax on x86.
Nguyen Anh Quynhf1c3acb2014-05-28 22:39:23 +080046
47 By default, Capstone use system dynamic memory management, and both DIET and X86_REDUCE
obscb8e40c2014-08-17 21:07:13 +020048 modes are disabled. To use your own memory allocations, turn ON both DIET &
Nguyen Anh Quynh9cb4d8b2014-09-20 10:59:01 +080049 X86_REDUCE, run "cmake" with: -DCAPSTONE_USE_SYS_DYN_MEM=0 -DCAPSTONE_BUILD_DIET=1 -DCAPSTONE_X86_REDUCE=1
Nguyen Anh Quynhf1c3acb2014-05-28 22:39:23 +080050
51
52 For each option, refer to docs/README for more details.
53
54
55
56(1) CMake allows you to generate different generators to build Capstone. Below is
57 some examples on how to build Capstone on Windows with CMake.
58
59
Nguyen Anh Quynh40012f12014-05-30 00:37:30 +080060 (*) To build Capstone using Nmake of Windows SDK, do:
Nguyen Anh Quynhf1c3acb2014-05-28 22:39:23 +080061
62 mkdir build
63 cd build
Nguyen Anh Quynhf7a3cc22017-03-13 15:06:32 +080064 ..\nmake.bat
Nguyen Anh Quynhf1c3acb2014-05-28 22:39:23 +080065
Nguyen Anh Quynhf7a3cc22017-03-13 15:06:32 +080066 After this, find the samples test*.exe, capstone.lib & capstone.dll
Nguyen Anh Quynhf1c3acb2014-05-28 22:39:23 +080067 in the same directory.
68
69
70
Nguyen Anh Quynh40012f12014-05-30 00:37:30 +080071 (*) To build Capstone using Visual Studio, choose the generator accordingly to the
Nguyen Anh Quynhf1c3acb2014-05-28 22:39:23 +080072 version of Visual Studio on your machine. For example, with Visual Studio 2013, do:
73
74 mkdir build
75 cd build
76 cmake -G "Visual Studio 12" ..
77
Nguyen Anh Quynh40012f12014-05-30 00:37:30 +080078 After this, find capstone.sln in the same directory. Open it with Visual Studio
79 and build the solution including libraries & all test as usual.
Nguyen Anh Quynhf1c3acb2014-05-28 22:39:23 +080080
81
82
83(2) You can make sure the prior steps successfully worked by launching one of the
84 testing binary (test*.exe).
85