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