forked from whoozle/android-file-transfer-linux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
140 lines (110 loc) · 3.64 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
project(mtp)
set(CPACK_PACKAGE_VERSION "2.5")
set(CPACK_PACKAGE_VERSION_MAJOR 2)
set(CPACK_PACKAGE_VERSION_MAJOR 5)
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE)
set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_SOURCE_DIR}/README.md)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Android File Transfer for Linux (and Mac OS X) - open source implementation of MTP protocol used on every modern android device")
set(MTP_LIBRARIES mtp-ng-static)
message(STATUS "building for ${CMAKE_SYSTEM_NAME}")
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(USB_BACKEND_DARWIN TRUE)
#set(CPACK_GENERATOR Bundle)
endif()
include(CPack)
cmake_minimum_required(VERSION 2.8)
set(CMAKE_USE_RELATIVE_PATHS TRUE)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
include(FindPkgConfig)
include(CheckFunctionExists)
include(CheckIncludeFiles)
find_package ( Threads )
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
pkg_check_modules ( FUSE fuse )
endif()
if (FUSE_FOUND)
message(STATUS "fuse found, building mount helper")
add_definitions(${FUSE_CFLAGS} -DFUSE_USE_VERSION=26)
endif()
check_include_files (magic.h HAVE_MAGIC_H)
check_library_exists(magic magic_open "" HAVE_LIBMAGIC)
if (HAVE_MAGIC_H AND HAVE_LIBMAGIC)
message(STATUS "libmagic found")
add_definitions(-DHAVE_LIBMAGIC)
list(APPEND MTP_LIBRARIES magic)
endif()
option(BUILD_QT_UI "Build reference Qt application" ON)
option(BUILD_SHARED_LIB "Build shared library" OFF)
option(USB_BACKEND_LIBUSB "Use libusb-1.0" OFF)
if (USB_BACKEND_LIBUSB)
message(WARNING "WARNING! You're using libusb, this is known to be broken -- large memory consumption, violating kernel memory limits and bugs. Continue at your own risk")
endif()
add_definitions(-Wall -pthread -std=c++11)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
if (CMAKE_BUILD_TYPE STREQUAL Debug)
add_definitions(-ggdb)
endif()
include_directories(. ${CMAKE_SOURCE_DIR})
set(SOURCES
mtp/log.cpp
mtp/ByteArray.cpp
mtp/ptp/Device.cpp
mtp/ptp/ObjectFormat.cpp
mtp/ptp/PipePacketer.cpp
mtp/ptp/Response.cpp
mtp/ptp/Session.cpp
mtp/usb/BulkPipe.cpp
mtp/usb/Request.cpp
)
if (USB_BACKEND_LIBUSB)
pkg_check_modules(LIBUSB libusb-1.0 REQUIRED)
include_directories(${LIBUSB_INCLUDE_DIRS})
include_directories(mtp/backend/libusb)
list(APPEND SOURCES
mtp/backend/libusb/usb/Context.cpp
mtp/backend/libusb/usb/Device.cpp
mtp/backend/libusb/usb/DeviceDescriptor.cpp
mtp/backend/libusb/usb/Exception.cpp
)
list(APPEND MTP_LIBRARIES ${LIBUSB_LIBRARIES})
elseif (USB_BACKEND_DARWIN)
find_library(CORE_LIBRARY CoreFoundation)
find_library(IOKIT_LIBRARY IOKit)
list(APPEND MTP_LIBRARIES ${IOKIT_LIBRARY} ${CORE_LIBRARY})
include_directories(mtp/backend/darwin)
list(APPEND SOURCES
mtp/backend/darwin/usb/Context.cpp
mtp/backend/darwin/usb/Device.cpp
mtp/backend/darwin/usb/DeviceDescriptor.cpp
mtp/backend/darwin/usb/Exception.cpp
mtp/backend/darwin/usb/Interface.cpp
)
else()
include_directories(mtp/backend/linux)
list(APPEND SOURCES
mtp/backend/linux/usb/Endpoint.cpp
mtp/backend/linux/usb/Exception.cpp
mtp/backend/linux/usb/Context.cpp
mtp/backend/linux/usb/Device.cpp
mtp/backend/linux/usb/Interface.cpp
mtp/backend/linux/usb/DeviceDescriptor.cpp
)
endif()
add_library(mtp-ng-static STATIC ${SOURCES})
if (BUILD_SHARED_LIB)
add_library(mtp-ng SHARED ${SOURCES})
target_link_libraries(mtp-ng ${CMAKE_THREAD_LIBS_INIT})
if (USB_BACKEND_LIBUSB)
target_link_libraries(mtp-ng ${LIBUSB_LIBRARIES})
endif()
endif (BUILD_SHARED_LIB)
add_definitions(-D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64)
add_subdirectory(cli)
if (FUSE_FOUND)
add_subdirectory(fuse)
endif()
if (BUILD_QT_UI)
add_subdirectory(qt)
endif()