Debian Codegraph @

COMPILE_CMAKE.TXT

raw
1 This documentation explains how to compile Capstone with CMake, focus on
2 using Microsoft Visual C as the compiler.
3
4 To compile Capstone on *nix, see COMPILE.TXT.
5
6 To compile Capstone on Windows using Visual Studio, see COMPILE_MSVC.TXT.
7
8 *-*-*-*-*-*
9
10 This documentation requires CMake & Windows SDK or MS Visual Studio installed on
11 your machine.
12
13 Get CMake for free from http://www.cmake.org.
14
15
16
17 (0) Tailor Capstone to your need.
18
19 Out of archtitectures supported by Capstone, if you just need several selected archs,
20 run "cmake" with the unwanted archs disabled (set to 0) as followings.
21
22 - CAPSTONE_ARM_SUPPORT: support ARM. Run cmake with -DCAPSTONE_ARM_SUPPORT=0 to remove ARM.
23 - CAPSTONE_ARM64_SUPPORT: support ARM64. Run cmake with -DCAPSTONE_ARM64_SUPPORT=0 to remove ARM64.
24 - CAPSTONE_M680X_SUPPORT: support M680X. Run cmake with -DCAPSTONE_M680X_SUPPORT=0 to remove M680X.
25 - CAPSTONE_M68K_SUPPORT: support M68K. Run cmake with -DCAPSTONE_M68K_SUPPORT=0 to remove M68K.
26 - CAPSTONE_MIPS_SUPPORT: support Mips. Run cmake with -DCAPSTONE_MIPS_SUPPORT=0 to remove Mips.
27 - CAPSTONE_MOS65XX_SUPPORT: support MOS65XX. Run cmake with -DCAPSTONE_MOS65XX_SUPPORT=0 to remove MOS65XX.
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_TRICORE_SUPPORT: support TriCore. Run cmake with -DCAPSTONE_TRICORE_SUPPORT=0 to remove TriCore.
33 - CAPSTONE_X86_SUPPORT: support X86. Run cmake with -DCAPSTONE_X86_SUPPORT=0 to remove X86.
34 - CAPSTONE_X86_TMS320C64X: support TMS320C64X. Run cmake with -DCAPSTONE_TMS320C64X_SUPPORT=0 to remove TMS320C64X.
35 - CAPSTONE_X86_M680X: support M680X. Run cmake with -DCAPSTONE_M680X_SUPPORT=0 to remove M680X.
36 - CAPSTONE_X86_EVM: support EVM. Run cmake with -DCAPSTONE_EVM_SUPPORT=0 to remove EVM.
37 - CAPSTONE_X86_WASM: support Web Assembly. Run cmake with -DCAPSTONE_WASM_SUPPORT=0 to remove WASM.
38 - CAPSTONE_BPF_SUPPORT: support BPF. Run cmake with -DCAPSTONE_BPF_SUPPORT=0 to remove BPF.
39 - CAPSTONE_RISCV_SUPPORT: support RISCV. Run cmake with -DCAPSTONE_RISCV_SUPPORT=0 to remove RISCV.
40 - CAPSTONE_ARCHITECUTRE_DEFAULT: Whether architectures are enabled by default.
41 Set this of OFF with -DCAPSTONE_ARCHITECUTRE_DEFAULT=OFF to dissable all architectures by default.
42 You can then enable them again with one of the CAPSTONE_<ARCH>_SUPPORT options.
43
44 By default, all architectures are compiled in.
45
46
47 Besides, Capstone also allows some more customization via following macros.
48
49 - CAPSTONE_USE_SYS_DYN_MEM: change this to OFF to use your own dynamic memory management.
50 - CAPSTONE_BUILD_DIET: change this to ON to make the binaries more compact.
51 - CAPSTONE_X86_REDUCE: change this to ON to make X86 binary smaller.
52 - CAPSTONE_X86_ATT_DISABLE: change this to ON to disable AT&T syntax on x86.
53 - CAPSTONE_DEBUG: change this to ON to enable extra debug assertions.
54
55 By default, Capstone use system dynamic memory management, and both DIET and X86_REDUCE
56 modes are disabled. To use your own memory allocations, turn ON both DIET &
57 X86_REDUCE, run "cmake" with: -DCAPSTONE_USE_SYS_DYN_MEM=0 -DCAPSTONE_BUILD_DIET=1 -DCAPSTONE_X86_REDUCE=1
58
59
60 For each option, refer to docs/README for more details.
61
62
63
64 (1) CMake allows you to generate different generators to build Capstone. Below is
65 some examples on how to build Capstone on Windows with CMake.
66
67 (*) You can let CMake select a generator for you. Do:
68
69 mkdir build
70 cd build
71 cmake ..
72
73 This last command is also where you can pass additional CMake configuration flags
74 using `-D<key>=<value>`.
75 For a debug build add `-DCMAKE_BUILD_TYPE=Debug`.
76 To export `compile_commands.json` add `-DCMAKE_EXPORT_COMPILE_COMMANDS=ON`.
77
78 Then to build use:
79
80 cmake --build . --config [Release/Debug]
81
82
83 (*) To build Capstone using Nmake of Windows SDK, do:
84
85 mkdir build
86 cd build
87 ..\nmake.bat
88
89 After this, find the samples test*.exe, capstone.lib & capstone.dll
90 in the same directory.
91
92
93
94 (*) To build Capstone using Visual Studio, choose the generator accordingly to the
95 version of Visual Studio on your machine. For example, with Visual Studio 2013, do:
96
97 mkdir build
98 cd build
99 cmake -G "Visual Studio 12" ..
100
101 After this, find capstone.sln in the same directory. Open it with Visual Studio
102 and build the solution including libraries & all test as usual.
103
104
105
106 (2) You can make sure the prior steps successfully worked by launching one of the
107 testing binary (test*.exe).
108
109 (3) You can also enable just one specific architecture by passing the architecture name
110 to either the cmake.sh or nmake.bat scripts. e.g.:
111
112 ../cmake.sh x86
113
114 Will just target the x86 architecture. The list of available architectures is: ARM,
115 ARM64, M68K, MIPS, PowerPC, Sparc, SystemZ, XCore, x86, TMS320C64x, M680x, EVM, MOS65XX,
116 WASM, BPF, RISCV.
117
118 (4) You can also create an installation image with cmake, by using the 'install' target.
119 Use:
120
121 cmake --build . --config Release --target install
122
123 This will normally install an image in a default location (`C:\Program Files` on Windows),
124 so it's good to explicitly set this location when configuring CMake. Use: `-DCMAKE_INSTALL_PREFIX=image`
125 for instance, to put the installation in the 'image' subdirectory of the build directory.