forked from hoxnox/yadisk-upload
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
189 lines (161 loc) · 6.66 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# Copyright 2017 hoxnox <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.3.0)
########################################################################
# options
option(WITH_TESTS "Build tests." OFF)
option(WITH_DOCS "Generate docs" OFF)
option(WITH_TOOLS "Build yadisk-upload executable" ON)
option(WITH_LIBS "Install libraries" OFF)
option(WITH_LOG "Logging replacement" "")
option(WITH_CONAN "Use conan for dependencies resolving" ON)
########################################################################
# general
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(StaticMSVC)
project(yadisk-upload)
set(CMAKE_CXX_STANDARD 14)
set(yadisk_upload_VERSION_MAJOR 0)
set(yadisk_upload_VERSION_MINOR 0)
set(yadisk_upload_VERSION_PATCH 7)
add_definitions("-DVERSION=\"${yadisk_upload_VERSION_MAJOR}.${yadisk_upload_VERSION_MINOR}.${yadisk_upload_VERSION_PATCH}\"")
include_directories("${PROJECT_SOURCE_DIR}/include")
set(STAGING_DIR "${CMAKE_BINARY_DIR}/staging")
if (WITH_CONAN)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
else()
if (NOT WIN32)
include(dependencies/zlib)
include(dependencies/openssl)
else()
include(dependencies/libressl)
endif()
include(dependencies/boost)
endif()
########################################################################
# threads
find_package(Threads REQUIRED)
########################################################################
# yandex api
add_library(yandex_api
src/yandex/disk.cpp
src/yandex/tls_transport.cpp
src/yandex/transport.cpp)
if (NOT WITH_CONAN)
if (WIN32)
add_definitions(-DWIN32_LEAN_AND_MEAN)
endif()
add_dependencies(yandex_api dependencies::boost
dependencies::boost::system
dependencies::boost::filesystem)
target_include_directories(yandex_api BEFORE PUBLIC
$<TARGET_PROPERTY:dependencies::boost,INTERFACE_INCLUDE_DIRECTORIES>)
if (NOT WITH_LOG)
include(dependencies/easyloggingpp)
add_dependencies(yandex_api dependencies::easyloggingpp)
target_include_directories(yandex_api PUBLIC
$<TARGET_PROPERTY:dependencies::easyloggingpp,INTERFACE_INCLUDE_DIRECTORIES>)
endif()
endif()
########################################################################
# pluggable logging
# replace logging.hpp
if (NOT WITH_LOG)
set(WITH_LOG "${PROJECT_BINARY_DIR}/log")
configure_file("${PROJECT_SOURCE_DIR}/src/Logging.hpp" "${PROJECT_BINARY_DIR}/log/logging.hpp" COPYONLY)
include_directories(BEFORE "${PROJECT_BINARY_DIR}/log")
else()
include_directories(BEFORE "${WITH_LOG}")
endif()
########################################################################
# yadisk-uplaod
if (WITH_TOOLS)
add_executable(yadisk-upload
src/yadisk-upload.cpp
src/Logging.cpp)
add_dependencies(yadisk-upload yandex_api)
if (NOT WITH_CONAN)
include(dependencies/docopt)
add_dependencies(yadisk-upload dependencies::docopt)
target_include_directories(yadisk-upload BEFORE PRIVATE
$<TARGET_PROPERTY:dependencies::docopt,INTERFACE_INCLUDE_DIRECTORIES>)
target_include_directories(yadisk-upload BEFORE PRIVATE
$<TARGET_PROPERTY:dependencies::boost,INTERFACE_INCLUDE_DIRECTORIES>)
target_link_libraries(yadisk-upload yandex_api
dependencies::boost::filesystem
dependencies::boost::system
$<TARGET_PROPERTY:dependencies::boost,INTERFACE_LINK_LIBRARIES>
dependencies::docopt)
else()
target_link_libraries(yadisk-upload yandex_api ${CONAN_LIBS} ${CMAKE_THREAD_LIBS_INIT})
endif()
endif()
########################################################################
# tests and docs
if(WITH_DOCS)
add_subdirectory(doc)
endif()
if(WITH_TESTS)
enable_testing()
add_subdirectory(test)
endif()
########################################################################
# remote build
set(REMOTE_SERVER $ENV{REMOTE_BUILD_SERVER})
set(REMOTE_SSHCONF $ENV{REMOTE_BUILD_SERVER_SSHCONF})
set(REMOTE_CMAKE_PARAMS "-DCMAKE_BUILD_TYPE=Release -DWITH_SYSTEM_OPENSSL=1 -DWITH_SYSTEM_BOOST=0 -DWITH_TOOLS=1 -DWITH_LIBS=0 -DWITH_CONAN=0")
set(REMOTE_VENDOR_FILES "docopt/docopt.cpp/docopt.cpp-0.6.2.tar.gz easylogging/easyloggingpp/easyloggingpp_v9.89.tar.gz boost.org/boost/boost_1_64_0.tar.gz")
add_custom_target(remote COMMAND
${CMAKE_CURRENT_SOURCE_DIR}/misc/build.remote ${REMOTE_SERVER}
${REMOTE_SSHCONF}
${REMOTE_CMAKE_PARAMS}
${REMOTE_VENDOR_FILES}
${PROJECT_SOURCE_DIR})
########################################################################
# installation
set(CPACK_SET_DESTDIR ON)
if (WITH_LIBS)
INSTALL(TARGETS yandex_api DESTINATION lib)
INSTALL(DIRECTORY include/yandex DESTINATION include)
endif()
if (WITH_TOOLS)
INSTALL(TARGETS yadisk-upload DESTINATION bin)
endif()
#INSTALL(DIRECTORY domedir DESTINATION share/${PROJECT_NAME})
SET(CPACK_PACKAGE_NAME yadisk-upload)
set(DELIM "")
if (WITH_SYSTEM_OPENSSL)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "openssl (>= 1.0.1)${DELIM}${CPACK_DEBIAN_PACKAGE_DEPENDS}")
set(DELIM ", ")
endif()
if (WITH_SYSTEM_BOOST)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libboost-dev (>= 1.47)${DELIM}${CPACK_DEBIAN_PACKAGE_DEPENDS}")
set(DELIM ", ")
endif()
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Yandex Disk files upload utility and library.")
SET(CPACK_PACKAGE_VENDOR "Merder Kim <[email protected]>")
SET(CPACK_PACKAGE_CONTACT "Merder Kim <[email protected]>")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/README.md")
SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
SET(CPACK_PACKAGE_VERSION_MAJOR ${yadisk_upload_VERSION_MAJOR})
SET(CPACK_PACKAGE_VERSION_MINOR ${yadisk_upload_VERSION_MINOR})
SET(CPACK_PACKAGE_VERSION_PATCH ${yadisk_upload_VERSION_PATCH})
SET(CPACK_DEBIAN_PACKAGE_SECTION "misc")
SET(CPACK_RPM_PACKAGE_GROUP "Applications/System")
SET(CPACK_RPM_PACKAGE_LICENSE "Apache-2.0")
SET(CPACK_STRIP_FILES TRUE)
INCLUDE(CPack)