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