daniel | 96ecc33 | 2014-05-18 02:03:15 -0700 | [diff] [blame] | 1 | cmake_minimum_required(VERSION 2.6) |
| 2 | project(capstone) |
| 3 | |
Nguyen Anh Quynh | e4c0f6c | 2015-01-30 11:25:24 +0800 | [diff] [blame] | 4 | set(VERSION_MAJOR 3) |
| 5 | set(VERSION_MINOR 0) |
Nguyen Anh Quynh | cd3d186 | 2015-02-25 12:27:26 +0800 | [diff] [blame] | 6 | set(VERSION_PATCH 2) |
Nguyen Anh Quynh | 56e4efd | 2014-05-28 16:27:53 +0800 | [diff] [blame] | 7 | |
Nguyen Anh Quynh | 758fcbe | 2014-05-31 10:44:27 +0800 | [diff] [blame] | 8 | # to configure the options specify them in in the command line or change them in the cmake UI. |
| 9 | # Don't edit the makefile! |
Nguyen Anh Quynh | 4822f99 | 2015-02-03 18:25:12 +0800 | [diff] [blame] | 10 | option(CAPSTONE_BUILD_STATIC_RUNTIME "Embed static runtime" OFF) |
Yegor Derevenets | b4d78d9 | 2014-09-19 18:39:22 +0200 | [diff] [blame] | 11 | option(CAPSTONE_BUILD_STATIC "Build static library" ON) |
| 12 | option(CAPSTONE_BUILD_SHARED "Build shared library" ON) |
| 13 | option(CAPSTONE_BUILD_DIET "Build diet library" OFF) |
| 14 | option(CAPSTONE_BUILD_TESTS "Build tests" ON) |
| 15 | option(CAPSTONE_USE_DEFAULT_ALLOC "Use default memory allocation functions" ON) |
Nguyen Anh Quynh | a71a27b | 2014-05-28 21:20:30 +0800 | [diff] [blame] | 16 | |
Yegor Derevenets | b4d78d9 | 2014-09-19 18:39:22 +0200 | [diff] [blame] | 17 | option(CAPSTONE_ARM_SUPPORT "ARM support" ON) |
| 18 | option(CAPSTONE_ARM64_SUPPORT "ARM64 support" ON) |
| 19 | option(CAPSTONE_MIPS_SUPPORT "MIPS support" ON) |
| 20 | option(CAPSTONE_PPC_SUPPORT "PowerPC support" ON) |
Yegor Derevenets | ebc4ced | 2014-09-21 19:52:57 +0200 | [diff] [blame] | 21 | option(CAPSTONE_SPARC_SUPPORT "Sparc support" ON) |
Yegor Derevenets | b4d78d9 | 2014-09-19 18:39:22 +0200 | [diff] [blame] | 22 | option(CAPSTONE_SYSZ_SUPPORT "SystemZ support" ON) |
| 23 | option(CAPSTONE_XCORE_SUPPORT "XCore support" ON) |
| 24 | option(CAPSTONE_X86_SUPPORT "x86 support" ON) |
| 25 | option(CAPSTONE_X86_REDUCE "x86 with reduce instruction sets to minimize library" OFF) |
Nguyen Anh Quynh | a8fd71f | 2014-10-14 07:55:30 +0800 | [diff] [blame] | 26 | option(CAPSTONE_X86_ATT_DISABLE "Disable x86 AT&T syntax" OFF) |
reverser | bcf09f4 | 2015-04-09 18:28:19 +0100 | [diff] [blame] | 27 | option(CAPSTONE_OSXKERNEL_SUPPORT "Support to embed Capstone into OS X Kernel extensions" OFF) |
Nguyen Anh Quynh | a71a27b | 2014-05-28 21:20:30 +0800 | [diff] [blame] | 28 | |
Yegor Derevenets | b4d78d9 | 2014-09-19 18:39:22 +0200 | [diff] [blame] | 29 | if (CAPSTONE_BUILD_DIET) |
Nguyen Anh Quynh | 758fcbe | 2014-05-31 10:44:27 +0800 | [diff] [blame] | 30 | add_definitions(-DCAPSTONE_DIET) |
| 31 | endif () |
daniel | 96ecc33 | 2014-05-18 02:03:15 -0700 | [diff] [blame] | 32 | |
Yegor Derevenets | b4d78d9 | 2014-09-19 18:39:22 +0200 | [diff] [blame] | 33 | if (CAPSTONE_USE_DEFAULT_ALLOC) |
Nguyen Anh Quynh | d765ab2 | 2014-06-03 17:38:29 +0800 | [diff] [blame] | 34 | add_definitions(-DCAPSTONE_USE_SYS_DYN_MEM) |
Nguyen Anh Quynh | 758fcbe | 2014-05-31 10:44:27 +0800 | [diff] [blame] | 35 | endif () |
| 36 | |
Yegor Derevenets | b4d78d9 | 2014-09-19 18:39:22 +0200 | [diff] [blame] | 37 | if (CAPSTONE_X86_REDUCE) |
Nguyen Anh Quynh | 758fcbe | 2014-05-31 10:44:27 +0800 | [diff] [blame] | 38 | add_definitions(-DCAPSTONE_X86_REDUCE) |
daniel | 96ecc33 | 2014-05-18 02:03:15 -0700 | [diff] [blame] | 39 | endif () |
| 40 | |
Yegor Derevenets | b4d78d9 | 2014-09-19 18:39:22 +0200 | [diff] [blame] | 41 | if (CAPSTONE_X86_ATT_DISABLE) |
baguette | 86e8450 | 2014-08-17 20:59:05 +0200 | [diff] [blame] | 42 | add_definitions(-DCAPSTONE_X86_ATT_DISABLE) |
| 43 | endif () |
| 44 | |
Ali Rizvi-Santiago | 10053ba | 2014-06-03 21:04:23 +0000 | [diff] [blame] | 45 | ## sources |
learn_more | 317682b | 2015-04-15 20:31:32 +0200 | [diff] [blame] | 46 | set(SOURCES_ENGINE |
daniel | 96ecc33 | 2014-05-18 02:03:15 -0700 | [diff] [blame] | 47 | cs.c |
| 48 | MCInst.c |
| 49 | MCInstrDesc.c |
| 50 | MCRegisterInfo.c |
| 51 | SStream.c |
| 52 | utils.c |
| 53 | ) |
Nguyen Anh Quynh | f6af509 | 2014-05-28 14:29:20 +0800 | [diff] [blame] | 54 | |
learn_more | 317682b | 2015-04-15 20:31:32 +0200 | [diff] [blame] | 55 | set(HEADERS_ENGINE |
learn_more | 43f8ac1 | 2015-04-15 12:15:26 +0200 | [diff] [blame] | 56 | include/capstone.h |
| 57 | utils.h |
| 58 | MCRegisterInfo.h |
| 59 | MCInst.h |
| 60 | MCInstrDesc.h |
| 61 | SStream.h |
| 62 | cs_priv.h |
| 63 | myinttypes.h |
| 64 | include/platform.h |
| 65 | ) |
| 66 | |
| 67 | |
Nguyen Anh Quynh | 0a2eca7 | 2014-10-11 00:36:16 +0800 | [diff] [blame] | 68 | set(TEST_SOURCES test.c test_detail.c test_skipdata.c test_iter.c) |
Nguyen Anh Quynh | f6af509 | 2014-05-28 14:29:20 +0800 | [diff] [blame] | 69 | |
Ali Rizvi-Santiago | 10053ba | 2014-06-03 21:04:23 +0000 | [diff] [blame] | 70 | ## architecture support |
Yegor Derevenets | b4d78d9 | 2014-09-19 18:39:22 +0200 | [diff] [blame] | 71 | if (CAPSTONE_ARM_SUPPORT) |
daniel | 96ecc33 | 2014-05-18 02:03:15 -0700 | [diff] [blame] | 72 | add_definitions(-DCAPSTONE_HAS_ARM) |
learn_more | 43f8ac1 | 2015-04-15 12:15:26 +0200 | [diff] [blame] | 73 | set(SOURCES_ARM |
daniel | 96ecc33 | 2014-05-18 02:03:15 -0700 | [diff] [blame] | 74 | arch/ARM/ARMDisassembler.c |
| 75 | arch/ARM/ARMInstPrinter.c |
| 76 | arch/ARM/ARMMapping.c |
| 77 | arch/ARM/ARMModule.c |
| 78 | ) |
learn_more | 317682b | 2015-04-15 20:31:32 +0200 | [diff] [blame] | 79 | set(HEADERS_ARM |
| 80 | arch/ARM/ARMAddressingModes.h |
| 81 | arch/ARM/ARMBaseInfo.h |
| 82 | arch/ARM/ARMDisassembler.h |
| 83 | arch/ARM/ARMGenAsmWriter.inc |
| 84 | arch/ARM/ARMGenDisassemblerTables.inc |
| 85 | arch/ARM/ARMGenInstrInfo.inc |
| 86 | arch/ARM/ARMGenRegisterInfo.inc |
| 87 | arch/ARM/ARMGenSubtargetInfo.inc |
| 88 | arch/ARM/ARMInstPrinter.h |
| 89 | arch/ARM/ARMMapping.h |
| 90 | ) |
daniel | 96ecc33 | 2014-05-18 02:03:15 -0700 | [diff] [blame] | 91 | set(TEST_SOURCES ${TEST_SOURCES} test_arm.c) |
| 92 | endif () |
Nguyen Anh Quynh | f6af509 | 2014-05-28 14:29:20 +0800 | [diff] [blame] | 93 | |
Yegor Derevenets | b4d78d9 | 2014-09-19 18:39:22 +0200 | [diff] [blame] | 94 | if (CAPSTONE_ARM64_SUPPORT) |
daniel | 96ecc33 | 2014-05-18 02:03:15 -0700 | [diff] [blame] | 95 | add_definitions(-DCAPSTONE_HAS_ARM64) |
learn_more | 43f8ac1 | 2015-04-15 12:15:26 +0200 | [diff] [blame] | 96 | set(SOURCES_ARM64 |
daniel | 96ecc33 | 2014-05-18 02:03:15 -0700 | [diff] [blame] | 97 | arch/AArch64/AArch64BaseInfo.c |
| 98 | arch/AArch64/AArch64Disassembler.c |
| 99 | arch/AArch64/AArch64InstPrinter.c |
| 100 | arch/AArch64/AArch64Mapping.c |
| 101 | arch/AArch64/AArch64Module.c |
| 102 | ) |
learn_more | 317682b | 2015-04-15 20:31:32 +0200 | [diff] [blame] | 103 | set(HEADERS_ARM64 |
| 104 | arch/AArch64/AArch64AddressingModes.h |
| 105 | arch/AArch64/AArch64BaseInfo.h |
| 106 | arch/AArch64/AArch64Disassembler.h |
| 107 | arch/AArch64/AArch64GenAsmWriter.inc |
| 108 | arch/AArch64/AArch64GenDisassemblerTables.inc |
| 109 | arch/AArch64/AArch64GenInstrInfo.inc |
| 110 | arch/AArch64/AArch64GenRegisterInfo.inc |
| 111 | arch/AArch64/AArch64GenSubtargetInfo.inc |
| 112 | arch/AArch64/AArch64InstPrinter.h |
| 113 | arch/AArch64/AArch64Mapping.h |
| 114 | ) |
daniel | 96ecc33 | 2014-05-18 02:03:15 -0700 | [diff] [blame] | 115 | set(TEST_SOURCES ${TEST_SOURCES} test_arm64.c) |
| 116 | endif () |
| 117 | |
Yegor Derevenets | b4d78d9 | 2014-09-19 18:39:22 +0200 | [diff] [blame] | 118 | if (CAPSTONE_MIPS_SUPPORT) |
daniel | 96ecc33 | 2014-05-18 02:03:15 -0700 | [diff] [blame] | 119 | add_definitions(-DCAPSTONE_HAS_MIPS) |
learn_more | 43f8ac1 | 2015-04-15 12:15:26 +0200 | [diff] [blame] | 120 | set(SOURCES_MIPS |
daniel | 96ecc33 | 2014-05-18 02:03:15 -0700 | [diff] [blame] | 121 | arch/Mips/MipsDisassembler.c |
Nguyen Anh Quynh | f6af509 | 2014-05-28 14:29:20 +0800 | [diff] [blame] | 122 | arch/Mips/MipsInstPrinter.c |
daniel | 96ecc33 | 2014-05-18 02:03:15 -0700 | [diff] [blame] | 123 | arch/Mips/MipsMapping.c |
| 124 | arch/Mips/MipsModule.c |
| 125 | ) |
learn_more | 317682b | 2015-04-15 20:31:32 +0200 | [diff] [blame] | 126 | set(HEADERS_MIPS |
| 127 | arch/Mips/MipsDisassembler.h |
| 128 | arch/Mips/MipsGenAsmWriter.inc |
| 129 | arch/Mips/MipsGenDisassemblerTables.inc |
| 130 | arch/Mips/MipsGenInstrInfo.inc |
| 131 | arch/Mips/MipsGenRegisterInfo.inc |
| 132 | arch/Mips/MipsGenSubtargetInfo.inc |
| 133 | arch/Mips/MipsInstPrinter.h |
| 134 | arch/Mips/MipsMapping.h |
| 135 | ) |
daniel | 96ecc33 | 2014-05-18 02:03:15 -0700 | [diff] [blame] | 136 | set(TEST_SOURCES ${TEST_SOURCES} test_mips.c) |
| 137 | endif () |
| 138 | |
Yegor Derevenets | b4d78d9 | 2014-09-19 18:39:22 +0200 | [diff] [blame] | 139 | if (CAPSTONE_PPC_SUPPORT) |
daniel | 96ecc33 | 2014-05-18 02:03:15 -0700 | [diff] [blame] | 140 | add_definitions(-DCAPSTONE_HAS_POWERPC) |
learn_more | 43f8ac1 | 2015-04-15 12:15:26 +0200 | [diff] [blame] | 141 | set(SOURCES_PPC |
daniel | 96ecc33 | 2014-05-18 02:03:15 -0700 | [diff] [blame] | 142 | arch/PowerPC/PPCDisassembler.c |
| 143 | arch/PowerPC/PPCInstPrinter.c |
| 144 | arch/PowerPC/PPCMapping.c |
| 145 | arch/PowerPC/PPCModule.c |
| 146 | ) |
learn_more | 317682b | 2015-04-15 20:31:32 +0200 | [diff] [blame] | 147 | set(HEADERS_PPC |
| 148 | arch/PowerPC/PPCDisassembler.h |
| 149 | arch/PowerPC/PPCGenAsmWriter.inc |
| 150 | arch/PowerPC/PPCGenDisassemblerTables.inc |
| 151 | arch/PowerPC/PPCGenInstrInfo.inc |
| 152 | arch/PowerPC/PPCGenRegisterInfo.inc |
| 153 | arch/PowerPC/PPCGenSubtargetInfo.inc |
| 154 | arch/PowerPC/PPCInstPrinter.h |
| 155 | arch/PowerPC/PPCMapping.h |
| 156 | arch/PowerPC/PPCPredicates.h |
| 157 | ) |
daniel | 96ecc33 | 2014-05-18 02:03:15 -0700 | [diff] [blame] | 158 | set(TEST_SOURCES ${TEST_SOURCES} test_ppc.c) |
| 159 | endif () |
| 160 | |
Yegor Derevenets | b4d78d9 | 2014-09-19 18:39:22 +0200 | [diff] [blame] | 161 | if (CAPSTONE_X86_SUPPORT) |
daniel | 96ecc33 | 2014-05-18 02:03:15 -0700 | [diff] [blame] | 162 | add_definitions(-DCAPSTONE_HAS_X86) |
learn_more | 43f8ac1 | 2015-04-15 12:15:26 +0200 | [diff] [blame] | 163 | set(SOURCES_X86 |
Nguyen Anh Quynh | a71a27b | 2014-05-28 21:20:30 +0800 | [diff] [blame] | 164 | arch/X86/X86Disassembler.c |
| 165 | arch/X86/X86DisassemblerDecoder.c |
| 166 | arch/X86/X86IntelInstPrinter.c |
| 167 | arch/X86/X86Mapping.c |
| 168 | arch/X86/X86Module.c |
| 169 | ) |
learn_more | 317682b | 2015-04-15 20:31:32 +0200 | [diff] [blame] | 170 | set(HEADERS_X86 |
| 171 | arch/X86/X86BaseInfo.h |
| 172 | arch/X86/X86Disassembler.h |
| 173 | arch/X86/X86DisassemblerDecoder.h |
| 174 | arch/X86/X86DisassemblerDecoderCommon.h |
| 175 | arch/X86/X86GenAsmWriter.inc |
| 176 | arch/X86/X86GenAsmWriter1.inc |
| 177 | arch/X86/X86GenAsmWriter1_reduce.inc |
| 178 | arch/X86/X86GenAsmWriter_reduce.inc |
| 179 | arch/X86/X86GenDisassemblerTables.inc |
| 180 | arch/X86/X86GenDisassemblerTables_reduce.inc |
| 181 | arch/X86/X86GenInstrInfo.inc |
| 182 | arch/X86/X86GenInstrInfo_reduce.inc |
| 183 | arch/X86/X86GenRegisterInfo.inc |
| 184 | arch/X86/X86InstPrinter.h |
| 185 | arch/X86/X86Mapping.h |
| 186 | ) |
Yegor Derevenets | b4d78d9 | 2014-09-19 18:39:22 +0200 | [diff] [blame] | 187 | if (NOT CAPSTONE_BUILD_DIET) |
learn_more | 0749930 | 2015-04-15 21:39:10 +0200 | [diff] [blame^] | 188 | set(SOURCES_X86 ${SOURCES_X86} arch/X86/X86ATTInstPrinter.c) |
Nguyen Anh Quynh | 758fcbe | 2014-05-31 10:44:27 +0800 | [diff] [blame] | 189 | endif () |
daniel | 96ecc33 | 2014-05-18 02:03:15 -0700 | [diff] [blame] | 190 | set(TEST_SOURCES ${TEST_SOURCES} test_x86.c) |
| 191 | endif () |
Nguyen Anh Quynh | f6af509 | 2014-05-28 14:29:20 +0800 | [diff] [blame] | 192 | |
Yegor Derevenets | ebc4ced | 2014-09-21 19:52:57 +0200 | [diff] [blame] | 193 | if (CAPSTONE_SPARC_SUPPORT) |
Nguyen Anh Quynh | d002319 | 2014-05-28 15:15:00 +0800 | [diff] [blame] | 194 | add_definitions(-DCAPSTONE_HAS_SPARC) |
learn_more | 43f8ac1 | 2015-04-15 12:15:26 +0200 | [diff] [blame] | 195 | set(SOURCES_SPARC |
| 196 | arch/Sparc/SparcDisassembler.c |
| 197 | arch/Sparc/SparcInstPrinter.c |
| 198 | arch/Sparc/SparcMapping.c |
| 199 | arch/Sparc/SparcModule.c |
Nguyen Anh Quynh | d002319 | 2014-05-28 15:15:00 +0800 | [diff] [blame] | 200 | ) |
learn_more | 317682b | 2015-04-15 20:31:32 +0200 | [diff] [blame] | 201 | set(HEADERS_SPARC |
| 202 | arch/Sparc/Sparc.h |
| 203 | arch/Sparc/SparcDisassembler.h |
| 204 | arch/Sparc/SparcGenAsmWriter.inc |
| 205 | arch/Sparc/SparcGenDisassemblerTables.inc |
| 206 | arch/Sparc/SparcGenInstrInfo.inc |
| 207 | arch/Sparc/SparcGenRegisterInfo.inc |
| 208 | arch/Sparc/SparcGenSubtargetInfo.inc |
| 209 | arch/Sparc/SparcInstPrinter.h |
| 210 | arch/Sparc/SparcMapping.h |
| 211 | ) |
Nguyen Anh Quynh | d002319 | 2014-05-28 15:15:00 +0800 | [diff] [blame] | 212 | set(TEST_SOURCES ${TEST_SOURCES} test_sparc.c) |
| 213 | endif () |
| 214 | |
Yegor Derevenets | b4d78d9 | 2014-09-19 18:39:22 +0200 | [diff] [blame] | 215 | if (CAPSTONE_SYSZ_SUPPORT) |
Nguyen Anh Quynh | d002319 | 2014-05-28 15:15:00 +0800 | [diff] [blame] | 216 | add_definitions(-DCAPSTONE_HAS_SYSZ) |
learn_more | 43f8ac1 | 2015-04-15 12:15:26 +0200 | [diff] [blame] | 217 | set(SOURCES_SYSZ |
| 218 | arch/SystemZ/SystemZDisassembler.c |
| 219 | arch/SystemZ/SystemZInstPrinter.c |
| 220 | arch/SystemZ/SystemZMapping.c |
| 221 | arch/SystemZ/SystemZModule.c |
| 222 | arch/SystemZ/SystemZMCTargetDesc.c |
Nguyen Anh Quynh | d002319 | 2014-05-28 15:15:00 +0800 | [diff] [blame] | 223 | ) |
learn_more | 317682b | 2015-04-15 20:31:32 +0200 | [diff] [blame] | 224 | set(HEADERS_SYSZ |
| 225 | arch/SystemZ/SystemZDisassembler.h |
| 226 | arch/SystemZ/SystemZGenAsmWriter.inc |
| 227 | arch/SystemZ/SystemZGenDisassemblerTables.inc |
| 228 | arch/SystemZ/SystemZGenInstrInfo.inc |
| 229 | arch/SystemZ/SystemZGenRegisterInfo.inc |
| 230 | arch/SystemZ/SystemZGenSubtargetInfo.inc |
| 231 | arch/SystemZ/SystemZInstPrinter.h |
| 232 | arch/SystemZ/SystemZMCTargetDesc.h |
| 233 | arch/SystemZ/SystemZMapping.h |
| 234 | ) |
Nguyen Anh Quynh | d002319 | 2014-05-28 15:15:00 +0800 | [diff] [blame] | 235 | set(TEST_SOURCES ${TEST_SOURCES} test_systemz.c) |
| 236 | endif () |
| 237 | |
Yegor Derevenets | b4d78d9 | 2014-09-19 18:39:22 +0200 | [diff] [blame] | 238 | if (CAPSTONE_XCORE_SUPPORT) |
Nguyen Anh Quynh | d002319 | 2014-05-28 15:15:00 +0800 | [diff] [blame] | 239 | add_definitions(-DCAPSTONE_HAS_XCORE) |
learn_more | 43f8ac1 | 2015-04-15 12:15:26 +0200 | [diff] [blame] | 240 | set(SOURCES_XCORE |
| 241 | arch/XCore/XCoreDisassembler.c |
| 242 | arch/XCore/XCoreInstPrinter.c |
| 243 | arch/XCore/XCoreMapping.c |
| 244 | arch/XCore/XCoreModule.c |
Nguyen Anh Quynh | d002319 | 2014-05-28 15:15:00 +0800 | [diff] [blame] | 245 | ) |
learn_more | 317682b | 2015-04-15 20:31:32 +0200 | [diff] [blame] | 246 | set(HEADERS_XCORE |
| 247 | arch/XCore/XCoreDisassembler.h |
| 248 | arch/XCore/XCoreGenAsmWriter.inc |
| 249 | arch/XCore/XCoreGenDisassemblerTables.inc |
| 250 | arch/XCore/XCoreGenInstrInfo.inc |
| 251 | arch/XCore/XCoreGenRegisterInfo.inc |
| 252 | arch/XCore/XCoreInstPrinter.h |
| 253 | arch/XCore/XCoreMapping.h |
| 254 | ) |
Nguyen Anh Quynh | d002319 | 2014-05-28 15:15:00 +0800 | [diff] [blame] | 255 | set(TEST_SOURCES ${TEST_SOURCES} test_xcore.c) |
| 256 | endif () |
| 257 | |
reverser | bcf09f4 | 2015-04-09 18:28:19 +0100 | [diff] [blame] | 258 | if (CAPSTONE_OSXKERNEL_SUPPORT) |
| 259 | add_definitions(-DCAPSTONE_HAS_OSXKERNEL) |
| 260 | endif () |
| 261 | |
learn_more | 43f8ac1 | 2015-04-15 12:15:26 +0200 | [diff] [blame] | 262 | set(ALL_SOURCES |
learn_more | 317682b | 2015-04-15 20:31:32 +0200 | [diff] [blame] | 263 | ${SOURCES_ENGINE} |
learn_more | 43f8ac1 | 2015-04-15 12:15:26 +0200 | [diff] [blame] | 264 | ${SOURCES_ARM} |
| 265 | ${SOURCES_ARM64} |
| 266 | ${SOURCES_MIPS} |
| 267 | ${SOURCES_PPC} |
| 268 | ${SOURCES_X86} |
| 269 | ${SOURCES_SPARC} |
| 270 | ${SOURCES_SYSZ} |
| 271 | ${SOURCES_XCORE} |
| 272 | ) |
| 273 | |
learn_more | 317682b | 2015-04-15 20:31:32 +0200 | [diff] [blame] | 274 | set(ALL_HEADERS |
| 275 | ${HEADERS_ENGINE} |
| 276 | ${HEADERS_ARM} |
| 277 | ${HEADERS_ARM64} |
| 278 | ${HEADERS_MIPS} |
| 279 | ${HEADERS_PPC} |
| 280 | ${HEADERS_X86} |
| 281 | ${HEADERS_SPARC} |
| 282 | ${HEADERS_SYSZ} |
| 283 | ${HEADERS_XCORE} |
| 284 | ) |
| 285 | |
daniel | 96ecc33 | 2014-05-18 02:03:15 -0700 | [diff] [blame] | 286 | include_directories("${PROJECT_SOURCE_DIR}/include") |
| 287 | |
Ali Rizvi-Santiago | 10053ba | 2014-06-03 21:04:23 +0000 | [diff] [blame] | 288 | ## properties |
| 289 | # version info |
| 290 | set_property(GLOBAL PROPERTY VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) |
| 291 | set_property(GLOBAL PROPERTY SOVERSION SOVERSION ${VERSION_MAJOR}) |
| 292 | |
| 293 | ## targets |
Yegor Derevenets | b4d78d9 | 2014-09-19 18:39:22 +0200 | [diff] [blame] | 294 | if (CAPSTONE_BUILD_STATIC) |
learn_more | 317682b | 2015-04-15 20:31:32 +0200 | [diff] [blame] | 295 | add_library(capstone-static STATIC ${ALL_SOURCES} ${ALL_HEADERS}) |
Ali Rizvi-Santiago | 10053ba | 2014-06-03 21:04:23 +0000 | [diff] [blame] | 296 | set_property(TARGET capstone-static PROPERTY OUTPUT_NAME capstone) |
Ali Rizvi-Santiago | 10053ba | 2014-06-03 21:04:23 +0000 | [diff] [blame] | 297 | set(default-target capstone-static) |
Nguyen Anh Quynh | d002319 | 2014-05-28 15:15:00 +0800 | [diff] [blame] | 298 | endif () |
| 299 | |
Nguyen Anh Quynh | 4822f99 | 2015-02-03 18:25:12 +0800 | [diff] [blame] | 300 | # Force static runtime libraries |
| 301 | if (CAPSTONE_BUILD_STATIC_RUNTIME) |
| 302 | FOREACH(flag |
learn_more | 43f8ac1 | 2015-04-15 12:15:26 +0200 | [diff] [blame] | 303 | CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO |
| 304 | CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_DEBUG_INIT |
| 305 | CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELWITHDEBINFO |
| 306 | CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG_INIT) |
| 307 | STRING(REPLACE "/MD" "/MT" "${flag}" "${${flag}}") |
| 308 | SET("${flag}" "${${flag}} /EHsc") |
Nguyen Anh Quynh | 4822f99 | 2015-02-03 18:25:12 +0800 | [diff] [blame] | 309 | ENDFOREACH() |
| 310 | endif () |
| 311 | |
Yegor Derevenets | b4d78d9 | 2014-09-19 18:39:22 +0200 | [diff] [blame] | 312 | if (CAPSTONE_BUILD_SHARED) |
learn_more | 317682b | 2015-04-15 20:31:32 +0200 | [diff] [blame] | 313 | add_library(capstone-shared SHARED ${ALL_SOURCES} ${ALL_HEADERS}) |
Ali Rizvi-Santiago | 10053ba | 2014-06-03 21:04:23 +0000 | [diff] [blame] | 314 | set_property(TARGET capstone-shared PROPERTY OUTPUT_NAME capstone) |
| 315 | set_property(TARGET capstone-shared PROPERTY COMPILE_FLAGS -DCAPSTONE_SHARED) |
| 316 | |
learn_more | 455fa06 | 2015-04-14 17:00:57 +0200 | [diff] [blame] | 317 | if (MSVC) |
learn_more | c85e3c3 | 2015-04-14 15:39:07 +0200 | [diff] [blame] | 318 | set_target_properties(capstone-shared PROPERTIES IMPORT_SUFFIX _dll.lib) |
learn_more | 455fa06 | 2015-04-14 17:00:57 +0200 | [diff] [blame] | 319 | endif () |
learn_more | c85e3c3 | 2015-04-14 15:39:07 +0200 | [diff] [blame] | 320 | |
Ali Rizvi-Santiago | 10053ba | 2014-06-03 21:04:23 +0000 | [diff] [blame] | 321 | if(NOT DEFINED default-target) # honor `capstone-static` for tests first. |
learn_more | 43f8ac1 | 2015-04-15 12:15:26 +0200 | [diff] [blame] | 322 | set(default-target capstone-shared) |
| 323 | add_definitions(-DCAPSTONE_SHARED) |
Ali Rizvi-Santiago | 10053ba | 2014-06-03 21:04:23 +0000 | [diff] [blame] | 324 | endif () |
| 325 | endif () |
daniel | 96ecc33 | 2014-05-18 02:03:15 -0700 | [diff] [blame] | 326 | |
Yegor Derevenets | b4d78d9 | 2014-09-19 18:39:22 +0200 | [diff] [blame] | 327 | if (CAPSTONE_BUILD_TESTS) |
daniel | 96ecc33 | 2014-05-18 02:03:15 -0700 | [diff] [blame] | 328 | foreach (TSRC ${TEST_SOURCES}) |
flyingsymbols | d91f964 | 2014-10-22 03:21:43 -0400 | [diff] [blame] | 329 | STRING(REGEX REPLACE ".c$" "" TBIN ${TSRC}) |
| 330 | add_executable(${TBIN} "tests/${TSRC}") |
| 331 | target_link_libraries(${TBIN} ${default-target}) |
daniel | 96ecc33 | 2014-05-18 02:03:15 -0700 | [diff] [blame] | 332 | endforeach () |
flyingsymbols | d91f964 | 2014-10-22 03:21:43 -0400 | [diff] [blame] | 333 | if (CAPSTONE_ARM_SUPPORT) |
| 334 | set(ARM_REGRESS_TEST test_arm_regression.c) |
| 335 | STRING(REGEX REPLACE ".c$" "" ARM_REGRESS_BIN ${ARM_REGRESS_TEST}) |
| 336 | add_executable(${ARM_REGRESS_BIN} "suite/arm/${ARM_REGRESS_TEST}") |
| 337 | target_link_libraries(${ARM_REGRESS_BIN} ${default-target}) |
| 338 | endif() |
daniel | 96ecc33 | 2014-05-18 02:03:15 -0700 | [diff] [blame] | 339 | endif () |
| 340 | |
learn_more | 317682b | 2015-04-15 20:31:32 +0200 | [diff] [blame] | 341 | source_group("Source\\Engine" FILES ${SOURCES_ENGINE}) |
| 342 | source_group("Source\\ARM" FILES ${SOURCES_ARM}) |
| 343 | source_group("Source\\ARM64" FILES ${SOURCES_ARM64}) |
| 344 | source_group("Source\\Mips" FILES ${SOURCES_MIPS}) |
| 345 | source_group("Source\\PowerPC" FILES ${SOURCES_PPC}) |
| 346 | source_group("Source\\Sparc" FILES ${SOURCES_X86}) |
| 347 | source_group("Source\\SystemZ" FILES ${SOURCES_SPARC}) |
| 348 | source_group("Source\\X86" FILES ${SOURCES_SYSZ}) |
| 349 | source_group("Source\\XCore" FILES ${SOURCES_XCORE}) |
| 350 | |
| 351 | source_group("Include\\Engine" FILES ${HEADERS_ENGINE}) |
| 352 | source_group("Include\\ARM" FILES ${HEADERS_ARM}) |
| 353 | source_group("Include\\ARM64" FILES ${HEADERS_ARM64}) |
| 354 | source_group("Include\\Mips" FILES ${HEADERS_MIPS}) |
| 355 | source_group("Include\\PowerPC" FILES ${HEADERS_PPC}) |
| 356 | source_group("Include\\Sparc" FILES ${HEADERS_X86}) |
| 357 | source_group("Include\\SystemZ" FILES ${HEADERS_SPARC}) |
| 358 | source_group("Include\\X86" FILES ${HEADERS_SYSZ}) |
| 359 | source_group("Include\\XCore" FILES ${HEADERS_XCORE}) |
| 360 | |
Ali Rizvi-Santiago | 10053ba | 2014-06-03 21:04:23 +0000 | [diff] [blame] | 361 | ## installation |
Yegor Derevenets | 17176cd | 2014-09-20 18:44:21 +0200 | [diff] [blame] | 362 | set(INCLUDES arm64.h arm.h capstone.h mips.h ppc.h x86.h sparc.h systemz.h xcore.h platform.h) |
daniel | 96ecc33 | 2014-05-18 02:03:15 -0700 | [diff] [blame] | 363 | foreach (INC ${INCLUDES}) |
| 364 | install(FILES "include/${INC}" DESTINATION include/capstone) |
| 365 | endforeach () |
Nguyen Anh Quynh | 7343848 | 2014-05-28 21:55:37 +0800 | [diff] [blame] | 366 | |
Yegor Derevenets | b4d78d9 | 2014-09-19 18:39:22 +0200 | [diff] [blame] | 367 | if (CAPSTONE_BUILD_STATIC) |
Ali Rizvi-Santiago | 10053ba | 2014-06-03 21:04:23 +0000 | [diff] [blame] | 368 | install(TARGETS capstone-static |
| 369 | RUNTIME DESTINATION bin |
| 370 | LIBRARY DESTINATION lib |
| 371 | ARCHIVE DESTINATION lib) |
| 372 | endif () |
| 373 | |
Yegor Derevenets | b4d78d9 | 2014-09-19 18:39:22 +0200 | [diff] [blame] | 374 | if (CAPSTONE_BUILD_SHARED) |
Ali Rizvi-Santiago | 10053ba | 2014-06-03 21:04:23 +0000 | [diff] [blame] | 375 | install(TARGETS capstone-shared |
| 376 | RUNTIME DESTINATION bin |
| 377 | LIBRARY DESTINATION lib |
| 378 | ARCHIVE DESTINATION lib) |
| 379 | endif () |