Nguyen Anh Quynh | f1c3acb | 2014-05-28 22:39:23 +0800 | [diff] [blame] | 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 8 archtitectures supported by Capstone (Arm, Arm64, Mips, PPC, Sparc, |
Nguyen Anh Quynh | ea16de9 | 2014-05-29 00:14:50 +0800 | [diff] [blame] | 20 | SystemZ, X86 & XCore), if you just need several selected archs, run "cmake" |
| 21 | with the unwanted archs disabled (set to 0) as followings. |
Nguyen Anh Quynh | f1c3acb | 2014-05-28 22:39:23 +0800 | [diff] [blame] | 22 | |
Nguyen Anh Quynh | 9cb4d8b | 2014-09-20 10:59:01 +0800 | [diff] [blame] | 23 | - 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. |
| 25 | - CAPSTONE_MIPS_SUPPORT: support Mips. Run cmake with -DCAPSTONE_MIPS_SUPPORT=0 to remove Mips. |
| 26 | - CAPSTONE_PPC_SUPPORT: support PPC. Run cmake with -DCAPSTONE_PPC_SUPPORT=0 to remove PPC. |
| 27 | - CAPSTONE_SPARC_SUPPORT: support Sparc. Run cmake with -DCAPSTONE_SPARC_SUPPORT=0 to remove Sparc. |
| 28 | - CAPSTONE_SYSZ_SUPPORT: support SystemZ. Run cmake with -DCAPSTONE_SYSZ_SUPPORT=0 to remove SystemZ. |
| 29 | - CAPSTONE_XCORE_SUPPORT: support XCore. Run cmake with -DCAPSTONE_XCORE_SUPPORT=0 to remove XCore. |
| 30 | - CAPSTONE_X86_SUPPORT: support X86. Run cmake with -DCAPSTONE_X86_SUPPORT=0 to remove X86. |
Nguyen Anh Quynh | f1c3acb | 2014-05-28 22:39:23 +0800 | [diff] [blame] | 31 | |
| 32 | By default, all 8 architectures are compiled in. |
| 33 | |
| 34 | |
| 35 | Besides, Capstone also allows some more customization via following macros. |
| 36 | |
Nguyen Anh Quynh | 9cb4d8b | 2014-09-20 10:59:01 +0800 | [diff] [blame] | 37 | - CAPSTONE_USE_SYS_DYN_MEM: change this to OFF to use your own dynamic memory management. |
| 38 | - CAPSTONE_BUILD_DIET: change this to ON to make the binaries more compact. |
| 39 | - CAPSTONE_X86_REDUCE: change this to ON to make X86 binary smaller. |
| 40 | - CAPSTONE_X86_ATT_DISABLE: change this to ON to disable AT&T syntax on x86. |
Nguyen Anh Quynh | f1c3acb | 2014-05-28 22:39:23 +0800 | [diff] [blame] | 41 | |
| 42 | By default, Capstone use system dynamic memory management, and both DIET and X86_REDUCE |
obs | cb8e40c | 2014-08-17 21:07:13 +0200 | [diff] [blame] | 43 | modes are disabled. To use your own memory allocations, turn ON both DIET & |
Nguyen Anh Quynh | 9cb4d8b | 2014-09-20 10:59:01 +0800 | [diff] [blame] | 44 | X86_REDUCE, run "cmake" with: -DCAPSTONE_USE_SYS_DYN_MEM=0 -DCAPSTONE_BUILD_DIET=1 -DCAPSTONE_X86_REDUCE=1 |
Nguyen Anh Quynh | f1c3acb | 2014-05-28 22:39:23 +0800 | [diff] [blame] | 45 | |
| 46 | |
| 47 | For each option, refer to docs/README for more details. |
| 48 | |
| 49 | |
| 50 | |
| 51 | (1) CMake allows you to generate different generators to build Capstone. Below is |
| 52 | some examples on how to build Capstone on Windows with CMake. |
| 53 | |
| 54 | |
Nguyen Anh Quynh | 40012f1 | 2014-05-30 00:37:30 +0800 | [diff] [blame] | 55 | (*) To build Capstone using Nmake of Windows SDK, do: |
Nguyen Anh Quynh | f1c3acb | 2014-05-28 22:39:23 +0800 | [diff] [blame] | 56 | |
| 57 | mkdir build |
| 58 | cd build |
Nguyen Anh Quynh | 8aef143 | 2015-02-03 17:45:55 +0800 | [diff] [blame] | 59 | cmake -DCMAKE_BUILD_TYPE=RELEASE -G "NMake Makefiles" .. |
Nguyen Anh Quynh | f1c3acb | 2014-05-28 22:39:23 +0800 | [diff] [blame] | 60 | nmake |
| 61 | |
| 62 | After this, find the samples test*.exe, libcapstone_static.lib & libcapstone.dll |
| 63 | in the same directory. |
| 64 | |
| 65 | |
| 66 | |
Nguyen Anh Quynh | 40012f1 | 2014-05-30 00:37:30 +0800 | [diff] [blame] | 67 | (*) To build Capstone using Visual Studio, choose the generator accordingly to the |
Nguyen Anh Quynh | f1c3acb | 2014-05-28 22:39:23 +0800 | [diff] [blame] | 68 | version of Visual Studio on your machine. For example, with Visual Studio 2013, do: |
| 69 | |
| 70 | mkdir build |
| 71 | cd build |
| 72 | cmake -G "Visual Studio 12" .. |
| 73 | |
Nguyen Anh Quynh | 40012f1 | 2014-05-30 00:37:30 +0800 | [diff] [blame] | 74 | After this, find capstone.sln in the same directory. Open it with Visual Studio |
| 75 | and build the solution including libraries & all test as usual. |
Nguyen Anh Quynh | f1c3acb | 2014-05-28 22:39:23 +0800 | [diff] [blame] | 76 | |
| 77 | |
| 78 | |
| 79 | (2) You can make sure the prior steps successfully worked by launching one of the |
| 80 | testing binary (test*.exe). |
| 81 | |