84884660b0e6d91fdc68f05962c88c61b56e589b
[WebKit-https.git] / Source / ThirdParty / capstone / Source / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.6)
2 project(capstone)
3
4 set(VERSION_MAJOR 4)
5 set(VERSION_MINOR 0)
6 set(VERSION_PATCH 0)
7
8 if(POLICY CMP0042)
9   # http://www.cmake.org/cmake/help/v3.0/policy/CMP0042.html
10   cmake_policy(SET CMP0042 NEW)
11 endif(POLICY CMP0042)
12
13 if (POLICY CMP0048)
14   # use old policy to honor version set using VERSION_* variables to preserve backwards
15   # compatibility. change OLD to NEW when minimum cmake version is updated to 3.* and
16   # set VERSION using project(capstone VERSION 4.0.0).
17   # http://www.cmake.org/cmake/help/v3.0/policy/CMP0048.html
18   cmake_policy (SET CMP0048 OLD)
19 endif()
20
21 # to configure the options specify them in in the command line or change them in the cmake UI.
22 # Don't edit the makefile!
23 option(CAPSTONE_BUILD_STATIC_RUNTIME "Embed static runtime" ON)
24 option(CAPSTONE_BUILD_STATIC "Build static library" ON)
25 option(CAPSTONE_BUILD_SHARED "Build shared library" ON)
26 option(CAPSTONE_BUILD_DIET "Build diet library" OFF)
27 option(CAPSTONE_BUILD_TESTS "Build tests" ON)
28 option(CAPSTONE_BUILD_CSTOOL "Build cstool" ON)
29 option(CAPSTONE_USE_DEFAULT_ALLOC "Use default memory allocation functions" ON)
30
31 set(SUPPORTED_ARCHITECTURES ARM ARM64 M68K MIPS PPC SPARC SYSZ XCORE X86 TMS320C64X M680X EVM)
32 set(SUPPORTED_ARCHITECTURE_LABELS ARM ARM64 M68K MIPS PowerPC Sparc SystemZ XCore x86 TMS320C64x M680x EVM)
33
34 list(LENGTH SUPPORTED_ARCHITECTURES count)
35 math(EXPR count "${count}-1")
36 # create options controlling whether support for a particular architecture is needed
37 foreach(i RANGE ${count})
38   list(GET SUPPORTED_ARCHITECTURES ${i} supported_architecture)
39   list(GET SUPPORTED_ARCHITECTURE_LABELS ${i} supported_architecture_label)
40   option("CAPSTONE_${supported_architecture}_SUPPORT" "${supported_architecture_label} support" ON)
41 endforeach(i)
42
43 # propagate achitecture support variables to preprocessor
44 foreach(supported_architecture ${SUPPORTED_ARCHITECTURES})
45   set(option_name "CAPSTONE_${supported_architecture}_SUPPORT")
46   if(${option_name})
47     message("Enabling ${option_name}")
48     add_definitions("-D${option_name}")
49   endif()
50 endforeach(supported_architecture)
51
52 option(CAPSTONE_X86_REDUCE "x86 with reduce instruction sets to minimize library" OFF)
53 option(CAPSTONE_X86_ATT_DISABLE "Disable x86 AT&T syntax" OFF)
54 option(CAPSTONE_OSXKERNEL_SUPPORT "Support to embed Capstone into OS X Kernel extensions" OFF)
55
56 if (MSVC)
57     set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
58     set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
59 endif ()
60
61 enable_testing()
62
63 if (CAPSTONE_BUILD_DIET)
64     add_definitions(-DCAPSTONE_DIET)
65 endif ()
66
67 if (CAPSTONE_USE_DEFAULT_ALLOC)
68     add_definitions(-DCAPSTONE_USE_SYS_DYN_MEM)
69 endif ()
70
71 if (CAPSTONE_X86_REDUCE)
72     add_definitions(-DCAPSTONE_X86_REDUCE)
73 endif ()
74
75 if (CAPSTONE_X86_ATT_DISABLE)
76     add_definitions(-DCAPSTONE_X86_ATT_DISABLE)
77 endif ()
78
79 ## sources
80 set(SOURCES_ENGINE
81     cs.c
82     MCInst.c
83     MCInstrDesc.c
84     MCRegisterInfo.c
85     SStream.c
86     utils.c
87 )
88 set(HEADERS_ENGINE
89     cs_priv.h
90     LEB128.h
91     MathExtras.h
92     MCDisassembler.h
93     MCFixedLenDisassembler.h
94     MCInst.h
95     MCInstrDesc.h
96     MCRegisterInfo.h
97     SStream.h
98     utils.h
99     )
100
101 set(HEADERS_COMMON
102     include/capstone/arm64.h
103     include/capstone/arm.h
104     include/capstone/capstone.h
105     include/capstone/mips.h
106     include/capstone/ppc.h
107     include/capstone/x86.h
108     include/capstone/sparc.h
109     include/capstone/systemz.h
110     include/capstone/xcore.h
111     include/capstone/m68k.h
112     include/capstone/tms320c64x.h
113     include/capstone/m680x.h
114     include/capstone/platform.h
115     )
116
117
118 set(TEST_SOURCES test_basic.c test_detail.c test_skipdata.c test_iter.c)
119
120 ## architecture support
121 if (CAPSTONE_ARM_SUPPORT)
122     add_definitions(-DCAPSTONE_HAS_ARM)
123     set(SOURCES_ARM
124         arch/ARM/ARMDisassembler.c
125         arch/ARM/ARMInstPrinter.c
126         arch/ARM/ARMMapping.c
127         arch/ARM/ARMModule.c
128     )
129     set(HEADERS_ARM
130         arch/ARM/ARMAddressingModes.h
131         arch/ARM/ARMBaseInfo.h
132         arch/ARM/ARMDisassembler.h
133         arch/ARM/ARMGenAsmWriter.inc
134         arch/ARM/ARMGenDisassemblerTables.inc
135         arch/ARM/ARMGenInstrInfo.inc
136         arch/ARM/ARMGenRegisterInfo.inc
137         arch/ARM/ARMGenSubtargetInfo.inc
138         arch/ARM/ARMInstPrinter.h
139         arch/ARM/ARMMapping.h
140         arch/ARM/ARMMappingInsn.inc
141         arch/ARM/ARMMappingInsnOp.inc
142         )
143     set(TEST_SOURCES ${TEST_SOURCES} test_arm.c)
144 endif ()
145
146 if (CAPSTONE_ARM64_SUPPORT)
147     add_definitions(-DCAPSTONE_HAS_ARM64)
148     set(SOURCES_ARM64
149         arch/AArch64/AArch64BaseInfo.c
150         arch/AArch64/AArch64Disassembler.c
151         arch/AArch64/AArch64InstPrinter.c
152         arch/AArch64/AArch64Mapping.c
153         arch/AArch64/AArch64Module.c
154     )
155     set(HEADERS_ARM64
156         arch/AArch64/AArch64AddressingModes.h
157         arch/AArch64/AArch64BaseInfo.h
158         arch/AArch64/AArch64Disassembler.h
159         arch/AArch64/AArch64GenAsmWriter.inc
160         arch/AArch64/AArch64GenDisassemblerTables.inc
161         arch/AArch64/AArch64GenInstrInfo.inc
162         arch/AArch64/AArch64GenRegisterInfo.inc
163         arch/AArch64/AArch64GenSubtargetInfo.inc
164         arch/AArch64/AArch64InstPrinter.h
165         arch/AArch64/AArch64Mapping.h
166         arch/AArch64/AArch64MappingInsn.inc
167         )
168     set(TEST_SOURCES ${TEST_SOURCES} test_arm64.c)
169 endif ()
170
171 if (CAPSTONE_MIPS_SUPPORT)
172     add_definitions(-DCAPSTONE_HAS_MIPS)
173     set(SOURCES_MIPS
174         arch/Mips/MipsDisassembler.c
175         arch/Mips/MipsInstPrinter.c
176         arch/Mips/MipsMapping.c
177         arch/Mips/MipsModule.c
178     )
179     set(HEADERS_MIPS
180         arch/Mips/MipsDisassembler.h
181         arch/Mips/MipsGenAsmWriter.inc
182         arch/Mips/MipsGenDisassemblerTables.inc
183         arch/Mips/MipsGenInstrInfo.inc
184         arch/Mips/MipsGenRegisterInfo.inc
185         arch/Mips/MipsGenSubtargetInfo.inc
186         arch/Mips/MipsInstPrinter.h
187         arch/Mips/MipsMapping.h
188         arch/Mips/MipsMappingInsn.inc
189         )
190     set(TEST_SOURCES ${TEST_SOURCES} test_mips.c)
191 endif ()
192
193 if (CAPSTONE_PPC_SUPPORT)
194     add_definitions(-DCAPSTONE_HAS_POWERPC)
195     set(SOURCES_PPC
196         arch/PowerPC/PPCDisassembler.c
197         arch/PowerPC/PPCInstPrinter.c
198         arch/PowerPC/PPCMapping.c
199         arch/PowerPC/PPCModule.c
200     )
201     set(HEADERS_PPC
202         arch/PowerPC/PPCDisassembler.h
203         arch/PowerPC/PPCGenAsmWriter.inc
204         arch/PowerPC/PPCGenDisassemblerTables.inc
205         arch/PowerPC/PPCGenInstrInfo.inc
206         arch/PowerPC/PPCGenRegisterInfo.inc
207         arch/PowerPC/PPCGenSubtargetInfo.inc
208         arch/PowerPC/PPCInstPrinter.h
209         arch/PowerPC/PPCMapping.h
210         arch/PowerPC/PPCMappingInsn.inc
211         arch/PowerPC/PPCPredicates.h
212         )
213     set(TEST_SOURCES ${TEST_SOURCES} test_ppc.c)
214 endif ()
215
216 if (CAPSTONE_X86_SUPPORT)
217     add_definitions(-DCAPSTONE_HAS_X86)
218     set(SOURCES_X86
219         arch/X86/X86Disassembler.c
220         arch/X86/X86DisassemblerDecoder.c
221         arch/X86/X86IntelInstPrinter.c
222         arch/X86/X86Mapping.c
223         arch/X86/X86Module.c
224     )
225     set(HEADERS_X86
226         arch/X86/X86BaseInfo.h
227         arch/X86/X86Disassembler.h
228         arch/X86/X86DisassemblerDecoder.h
229         arch/X86/X86DisassemblerDecoderCommon.h
230         arch/X86/X86GenAsmWriter.inc
231         arch/X86/X86GenAsmWriter1.inc
232         arch/X86/X86GenAsmWriter1_reduce.inc
233         arch/X86/X86GenAsmWriter_reduce.inc
234         arch/X86/X86GenDisassemblerTables.inc
235         arch/X86/X86GenDisassemblerTables_reduce.inc
236         arch/X86/X86GenInstrInfo.inc
237         arch/X86/X86GenInstrInfo_reduce.inc
238         arch/X86/X86GenRegisterInfo.inc
239         arch/X86/X86InstPrinter.h
240         arch/X86/X86Mapping.h
241         arch/X86/X86MappingInsn.inc
242         arch/X86/X86MappingInsnOp.inc
243         arch/X86/X86MappingInsnOp_reduce.inc
244         arch/X86/X86MappingInsn_reduce.inc
245         )
246     if (NOT CAPSTONE_BUILD_DIET)
247         set(SOURCES_X86 ${SOURCES_X86} arch/X86/X86ATTInstPrinter.c)
248     endif ()
249     set(TEST_SOURCES ${TEST_SOURCES} test_x86.c test_customized_mnem.c)
250 endif ()
251
252 if (CAPSTONE_SPARC_SUPPORT)
253     add_definitions(-DCAPSTONE_HAS_SPARC)
254     set(SOURCES_SPARC
255         arch/Sparc/SparcDisassembler.c
256         arch/Sparc/SparcInstPrinter.c
257         arch/Sparc/SparcMapping.c
258         arch/Sparc/SparcModule.c
259     )
260     set(HEADERS_SPARC
261         arch/Sparc/Sparc.h
262         arch/Sparc/SparcDisassembler.h
263         arch/Sparc/SparcGenAsmWriter.inc
264         arch/Sparc/SparcGenDisassemblerTables.inc
265         arch/Sparc/SparcGenInstrInfo.inc
266         arch/Sparc/SparcGenRegisterInfo.inc
267         arch/Sparc/SparcGenSubtargetInfo.inc
268         arch/Sparc/SparcInstPrinter.h
269         arch/Sparc/SparcMapping.h
270         arch/Sparc/SparcMappingInsn.inc
271         )
272     set(TEST_SOURCES ${TEST_SOURCES} test_sparc.c)
273 endif ()
274
275 if (CAPSTONE_SYSZ_SUPPORT)
276     add_definitions(-DCAPSTONE_HAS_SYSZ)
277     set(SOURCES_SYSZ
278         arch/SystemZ/SystemZDisassembler.c
279         arch/SystemZ/SystemZInstPrinter.c
280         arch/SystemZ/SystemZMapping.c
281         arch/SystemZ/SystemZMCTargetDesc.c
282         arch/SystemZ/SystemZModule.c
283     )
284     set(HEADERS_SYSZ
285         arch/SystemZ/SystemZDisassembler.h
286         arch/SystemZ/SystemZGenAsmWriter.inc
287         arch/SystemZ/SystemZGenDisassemblerTables.inc
288         arch/SystemZ/SystemZGenInstrInfo.inc
289         arch/SystemZ/SystemZGenRegisterInfo.inc
290         arch/SystemZ/SystemZGenSubtargetInfo.inc
291         arch/SystemZ/SystemZInstPrinter.h
292         arch/SystemZ/SystemZMapping.h
293         arch/SystemZ/SystemZMappingInsn.inc
294         arch/SystemZ/SystemZMCTargetDesc.h
295         )
296     set(TEST_SOURCES ${TEST_SOURCES} test_systemz.c)
297 endif ()
298
299 if (CAPSTONE_XCORE_SUPPORT)
300     add_definitions(-DCAPSTONE_HAS_XCORE)
301     set(SOURCES_XCORE
302         arch/XCore/XCoreDisassembler.c
303         arch/XCore/XCoreInstPrinter.c
304         arch/XCore/XCoreMapping.c
305         arch/XCore/XCoreModule.c
306     )
307     set(HEADERS_XCORE
308         arch/XCore/XCoreDisassembler.h
309         arch/XCore/XCoreGenAsmWriter.inc
310         arch/XCore/XCoreGenDisassemblerTables.inc
311         arch/XCore/XCoreGenInstrInfo.inc
312         arch/XCore/XCoreGenRegisterInfo.inc
313         arch/XCore/XCoreInstPrinter.h
314         arch/XCore/XCoreMapping.h
315         arch/XCore/XCoreMappingInsn.inc
316         )
317     set(TEST_SOURCES ${TEST_SOURCES} test_xcore.c)
318 endif ()
319
320 if (CAPSTONE_M68K_SUPPORT)
321     add_definitions(-DCAPSTONE_HAS_M68K)
322     set(SOURCES_M68K
323                 arch/M68K/M68KDisassembler.c
324                 arch/M68K/M68KInstPrinter.c
325                 arch/M68K/M68KModule.c
326     )
327     set(HEADERS_M68K
328                 arch/M68K/M68KDisassembler.h
329         )
330     set(TEST_SOURCES ${TEST_SOURCES} test_m68k.c)
331 endif ()
332
333 if (CAPSTONE_TMS320C64X_SUPPORT)
334     add_definitions(-DCAPSTONE_HAS_TMS320C64X)
335     set(SOURCES_TMS320C64X
336         arch/TMS320C64x/TMS320C64xDisassembler.c
337         arch/TMS320C64x/TMS320C64xInstPrinter.c
338         arch/TMS320C64x/TMS320C64xMapping.c
339         arch/TMS320C64x/TMS320C64xModule.c
340         )
341     set(HEADERS_TMS320C64X
342         arch/TMS320C64x/TMS320C64xDisassembler.h
343         arch/TMS320C64x/TMS320C64xGenAsmWriter.inc
344         arch/TMS320C64x/TMS320C64xGenDisassemblerTables.inc
345         arch/TMS320C64x/TMS320C64xGenInstrInfo.inc
346         arch/TMS320C64x/TMS320C64xGenRegisterInfo.inc
347         arch/TMS320C64x/TMS320C64xInstPrinter.h
348         arch/TMS320C64x/TMS320C64xMapping.h
349         )
350     set(TEST_SOURCES ${TEST_SOURCES} test_tms320c64x.c)
351 endif ()
352
353 if (CAPSTONE_M680X_SUPPORT)
354     add_definitions(-DCAPSTONE_HAS_M680X)
355     set(SOURCES_M680X
356                 arch/M680X/M680XDisassembler.c
357                 arch/M680X/M680XInstPrinter.c
358                 arch/M680X/M680XModule.c
359     )
360     set(HEADERS_M680X
361                 arch/M680X/M680XInstPrinter.h
362                 arch/M680X/M680XDisassembler.h
363                 arch/M680X/M680XDisassemblerInternals.h
364         )
365     set(TEST_SOURCES ${TEST_SOURCES} test_m680x.c)
366 endif ()
367
368 if (CAPSTONE_EVM_SUPPORT)
369     add_definitions(-DCAPSTONE_HAS_EVM)
370     set(SOURCES_EVM
371         arch/EVM/EVMDisassembler.c
372         arch/EVM/EVMInstPrinter.c
373         arch/EVM/EVMMapping.c
374         arch/EVM/EVMModule.c
375     )
376     set(HEADERS_EVM
377         arch/EVM/EVMDisassembler.h
378         arch/EVM/EVMInstPrinter.h
379         arch/EVM/EVMMapping.h
380         arch/EVM/EVMMappingInsn.inc
381         )
382     set(TEST_SOURCES ${TEST_SOURCES} test_evm.c)
383 endif ()
384
385 if (CAPSTONE_OSXKERNEL_SUPPORT)
386     add_definitions(-DCAPSTONE_HAS_OSXKERNEL)
387 endif ()
388
389 set(ALL_SOURCES
390     ${SOURCES_ENGINE}
391     ${SOURCES_ARM}
392     ${SOURCES_ARM64}
393     ${SOURCES_MIPS}
394     ${SOURCES_PPC}
395     ${SOURCES_X86}
396     ${SOURCES_SPARC}
397     ${SOURCES_SYSZ}
398     ${SOURCES_XCORE}
399     ${SOURCES_M68K}
400     ${SOURCES_TMS320C64X}
401     ${SOURCES_M680X}
402     ${SOURCES_EVM}
403     )
404
405 set(ALL_HEADERS
406     ${HEADERS_COMMON}
407     ${HEADERS_ENGINE}
408     ${HEADERS_ARM}
409     ${HEADERS_ARM64}
410     ${HEADERS_MIPS}
411     ${HEADERS_PPC}
412     ${HEADERS_X86}
413     ${HEADERS_SPARC}
414     ${HEADERS_SYSZ}
415     ${HEADERS_XCORE}
416     ${HEADERS_M68K}
417     ${HEADERS_TMS320C64X}
418     ${HEADERS_M680X}
419     ${HEADERS_EVM}
420     )
421
422 include_directories("${PROJECT_SOURCE_DIR}/include")
423
424 ## properties
425 # version info
426 set_property(GLOBAL PROPERTY VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
427
428 ## targets
429 if (CAPSTONE_BUILD_STATIC)
430     add_library(capstone-static STATIC ${ALL_SOURCES} ${ALL_HEADERS})
431     set_property(TARGET capstone-static PROPERTY OUTPUT_NAME capstone)
432     set(default-target capstone-static)
433 endif ()
434
435 # Force static runtime libraries
436 if (CAPSTONE_BUILD_STATIC_RUNTIME)
437     FOREACH(flag
438         CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO
439         CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_DEBUG_INIT
440         CMAKE_CXX_FLAGS_RELEASE  CMAKE_CXX_FLAGS_RELWITHDEBINFO
441         CMAKE_CXX_FLAGS_DEBUG  CMAKE_CXX_FLAGS_DEBUG_INIT)
442         if (MSVC)
443             STRING(REPLACE "/MD"  "/MT" "${flag}" "${${flag}}")
444             SET("${flag}" "${${flag}} /EHsc")
445         endif (MSVC)
446     ENDFOREACH()
447 endif ()
448
449 if (CAPSTONE_BUILD_SHARED)
450     add_library(capstone-shared SHARED ${ALL_SOURCES} ${ALL_HEADERS})
451     set_property(TARGET capstone-shared PROPERTY OUTPUT_NAME capstone)
452     set_property(TARGET capstone-shared PROPERTY COMPILE_FLAGS -DCAPSTONE_SHARED)
453
454     if (MSVC)
455         set_target_properties(capstone-shared PROPERTIES IMPORT_SUFFIX _dll.lib)
456     else()
457         set_target_properties(capstone-shared PROPERTIES
458             VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
459             SOVERSION ${VERSION_MAJOR})
460     endif ()
461
462     if(NOT DEFINED default-target)      # honor `capstone-static` for tests first.
463         set(default-target capstone-shared)
464         add_definitions(-DCAPSTONE_SHARED)
465     endif ()
466 endif ()
467
468 if (CAPSTONE_BUILD_TESTS)
469     foreach (TSRC ${TEST_SOURCES})
470         STRING(REGEX REPLACE ".c$" "" TBIN ${TSRC})
471         add_executable(${TBIN} "tests/${TSRC}")
472         target_link_libraries(${TBIN} ${default-target})
473         add_test(NAME "capstone_${TBIN}" COMMAND ${TBIN})
474     endforeach ()
475     if (CAPSTONE_ARM_SUPPORT)
476         set(ARM_REGRESS_TEST test_arm_regression.c)
477         STRING(REGEX REPLACE ".c$" "" ARM_REGRESS_BIN ${ARM_REGRESS_TEST})
478         add_executable(${ARM_REGRESS_BIN} "suite/arm/${ARM_REGRESS_TEST}")
479         target_link_libraries(${ARM_REGRESS_BIN} ${default-target})
480         add_test(NAME "capstone_${ARM_REGRESS_BIN}" COMMAND ${ARM_REGRESS_BIN})
481     endif()
482 endif ()
483
484 source_group("Source\\Engine" FILES ${SOURCES_ENGINE})
485 source_group("Source\\ARM" FILES ${SOURCES_ARM})
486 source_group("Source\\ARM64" FILES ${SOURCES_ARM64})
487 source_group("Source\\Mips" FILES ${SOURCES_MIPS})
488 source_group("Source\\PowerPC" FILES ${SOURCES_PPC})
489 source_group("Source\\Sparc" FILES ${SOURCES_SPARC})
490 source_group("Source\\SystemZ" FILES ${SOURCES_SYSZ})
491 source_group("Source\\X86" FILES ${SOURCES_X86})
492 source_group("Source\\XCore" FILES ${SOURCES_XCORE})
493 source_group("Source\\M68K" FILES ${SOURCES_M68K})
494 source_group("Source\\TMS320C64x" FILES ${SOURCES_TMS320C64X})
495 source_group("Source\\M680X" FILES ${SOURCES_M680X})
496 source_group("Source\\EVM" FILES ${SOURCES_EVM})
497
498 source_group("Include\\Common" FILES ${HEADERS_COMMON})
499 source_group("Include\\Engine" FILES ${HEADERS_ENGINE})
500 source_group("Include\\ARM" FILES ${HEADERS_ARM})
501 source_group("Include\\ARM64" FILES ${HEADERS_ARM64})
502 source_group("Include\\Mips" FILES ${HEADERS_MIPS})
503 source_group("Include\\PowerPC" FILES ${HEADERS_PPC})
504 source_group("Include\\Sparc" FILES ${HEADERS_SPARC})
505 source_group("Include\\SystemZ" FILES ${HEADERS_SYSZ})
506 source_group("Include\\X86" FILES ${HEADERS_X86})
507 source_group("Include\\XCore" FILES ${HEADERS_XCORE})
508 source_group("Include\\M68K" FILES ${HEADERS_M68K})
509 source_group("Include\\TMS320C64x" FILES ${HEADERS_TMS320C64X})
510 source_group("Include\\M680X" FILES ${HEADERS_MC680X})
511 source_group("Include\\EVM" FILES ${HEADERS_EVM})
512
513 ### test library 64bit routine:
514 get_property(LIB64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
515
516 if (NOT APPLE AND "${LIB64}" STREQUAL "TRUE")
517     set(LIBSUFFIX 64)
518 else()
519     set(LIBSUFFIX "")
520 endif()
521
522 set(INSTALL_LIB_DIR     lib${LIBSUFFIX} CACHE PATH "Installation directory for libraries")
523 mark_as_advanced(INSTALL_LIB_DIR)
524
525 ## installation
526 install(FILES ${HEADERS_COMMON} DESTINATION include/capstone)
527 configure_file(capstone.pc.in capstone.pc @ONLY)
528
529 if (CAPSTONE_BUILD_STATIC)
530     install(TARGETS capstone-static
531             RUNTIME DESTINATION bin
532             LIBRARY DESTINATION ${INSTALL_LIB_DIR}
533             ARCHIVE DESTINATION ${INSTALL_LIB_DIR})
534 endif ()
535
536 if (CAPSTONE_BUILD_SHARED)
537     install(TARGETS capstone-shared
538             RUNTIME DESTINATION bin
539             LIBRARY DESTINATION ${INSTALL_LIB_DIR}
540             ARCHIVE DESTINATION ${INSTALL_LIB_DIR})
541 endif ()
542
543 if (CAPSTONE_BUILD_SHARED AND CAPSTONE_BUILD_CSTOOL)
544 FILE(GLOB CSTOOL_SRC cstool/*.c)
545 add_executable(cstool ${CSTOOL_SRC})
546 target_link_libraries(cstool ${default-target})
547
548 install(TARGETS cstool DESTINATION bin)
549 install(FILES ${CMAKE_BINARY_DIR}/capstone.pc DESTINATION lib/pkgconfig)
550 endif ()