This repository has been archived by the owner on Jan 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
/
CMakeLists.txt
295 lines (258 loc) · 9.81 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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
message(STATUS "CMake version: ${CMAKE_VERSION}")
# must go before the `project()` command
set(CMAKE_CONFIGURATION_TYPES "Release;Debug" CACHE STRING "Configs" FORCE)
project(umf)
set(UMF_3PTY_DIR ${CMAKE_SOURCE_DIR}/3rdparty)
set(XMP_DIR ${UMF_3PTY_DIR}/xmp)
set(MODULES_DIR ${CMAKE_SOURCE_DIR}/modules)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
if(NOT IOS)
option(BUILD_SHARED_LIBS "Whether or not to build UMF as shared library" ON)
option(BUILD_SAMPLES "Whether or not to build the samples" ON)
option(BUILD_TESTS "Whether or not to build the tests" ON)
# Java
find_package(Java 1.7 QUIET)
find_package(JNI QUIET)
if(JAVA_FOUND AND JNI_FOUND)
option(BUILD_JAVA_API "Whether or not to build Java wrappers" ON)
endif()
else()
set(BUILD_SHARED_LIBS OFF)
set(BUILD_SAMPLES OFF)
set(BUILD_QT_SAMPLES OFF)
set(BUILD_TESTS OFF)
endif()
if(NOT BUILD_SHARED_LIBS AND BUILD_JAVA_API)
# JAR depends on dynamic UMF lib
set(BUILD_JAVA_API OFF)
message(WARNING "Java API building is disabled since it requires UMF lib to be dynamic")
endif()
if(WIN32)
set(BUILD_INSTALLER ON)
endif()
if(CMAKE_COMPILER_IS_GNUCXX)
option(CODE_COVERAGE "Whether or not to build with code coverage info (disables samples)" OFF)
else()
set(CODE_COVERAGE OFF)
endif()
if(CMAKE_GENERATOR MATCHES "Makefiles|Ninja" AND NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
if(DEFINED CMAKE_BUILD_TYPE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${CMAKE_CONFIGURATION_TYPES})
endif()
if(CMAKE_COMPILER_IS_GNUCXX AND CODE_COVERAGE)
set(BUILD_SAMPLES OFF)
set(BUILD_QT_SAMPLES OFF)
endif()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# The version number.
set(UMF_VERSION_MAJOR "3")
set(UMF_VERSION_MINOR "0")
set(UMF_VERSION_TYPE "RC1") # dev, alpha, beta
# adding git info to the version if possible
if(NOT COMMAND find_host_package)
macro(find_host_package)
find_package(${ARGN})
endmacro()
endif()
find_host_package(Git QUIET)
if(GIT_FOUND)
execute_process(COMMAND "${GIT_EXECUTABLE}" describe --tags --always --dirty
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE UMF_VERSION_VCS
RESULT_VARIABLE GIT_RESULT
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT GIT_RESULT EQUAL 0)
set(UMF_VERSION_VCS "unknown")
endif()
else()
set(UMF_VERSION_VCS "unknown")
endif()
# reporting build settings
function(umf_status msg)
message(STATUS "${msg}")
file(APPEND "${umf_build_info_FILE}" "${msg}\n")
endfunction()
set(umf_build_info_FILE "${CMAKE_BINARY_DIR}/build-info.tmp")
file(REMOVE "${umf_build_info_FILE}")
file(APPEND "${umf_build_info_FILE}" "const char* umf_build_info = R\"umf_build_info(\n")
message(STATUS "*** UMF build configuration ***")
# UMF
umf_status(" UMF version: ${UMF_VERSION_MAJOR}.${UMF_VERSION_MINOR}.${UMF_VERSION_TYPE} (GIT: ${UMF_VERSION_VCS})")
# OS, HW
umf_status(" Platform:")
umf_status(" Host: ${CMAKE_HOST_SYSTEM} ${CMAKE_HOST_SYSTEM_PROCESSOR}")
if(CMAKE_CROSSCOMPILING)
umf_status(" Target: ${CMAKE_SYSTEM} ${CMAKE_SYSTEM_PROCESSOR}")
endif()
if(ANDROID)
umf_status(" Android native API level: android-${ANDROID_NATIVE_API_LEVEL} (${ANDROID_ABI})")
umf_status(" NDK Toolchain: ${ANDROID_TOOLCHAIN_NAME} (NDK ${ANDROID_NDK_RELEASE}, ${ANDROID_NDK})")
endif()
# tools
umf_status(" CMake generator: ${CMAKE_GENERATOR}")
set(UMF_COMPILER_STR "(${CMAKE_CXX_COMPILER_ID}")
if(CMAKE_CXX_COMPILER_VERSION)
set(UMF_COMPILER_STR "${UMF_COMPILER_STR} ${CMAKE_CXX_COMPILER_VERSION}")
elseif(CMAKE_COMPILER_IS_CLANGCXX)
set(UMF_COMPILER_STR "${UMF_COMPILER_STR} ${CMAKE_CLANG_REGEX_VERSION}")
elseif(CMAKE_COMPILER_IS_GNUCXX)
set(UMF_COMPILER_STR "${UMF_COMPILER_STR} ${CMAKE_GCC_REGEX_VERSION}")
endif()
set(UMF_COMPILER_STR "${UMF_COMPILER_STR}) ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}")
string(STRIP "${UMF_COMPILER_STR}" UMF_COMPILER_STR)
umf_status(" CMake C++ compiler: ${UMF_COMPILER_STR}")
umf_status(" CMake Linker: ${CMAKE_LINKER}")
umf_status(" CMake build tool: ${CMAKE_BUILD_TOOL}")
if(Java_JAVAC_EXECUTABLE)
umf_status(" CMake Java compiler: ${Java_JAVAC_EXECUTABLE} (ver ${Java_VERSION})")
endif()
if(NOT CMAKE_GENERATOR MATCHES "Xcode|Visual Studio")
message(STATUS " CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
else()
message(STATUS " CMAKE_CONFIGURATION_TYPES: ${CMAKE_CONFIGURATION_TYPES}")
endif()
# build options
umf_status(" BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}")
message(STATUS " BUILD_SAMPLES: ${BUILD_SAMPLES}")
message(STATUS " BUILD_QT_SAMPLES: ${BUILD_QT_SAMPLES}")
message(STATUS " BUILD_TESTS: ${BUILD_TESTS}")
if(BUILD_JAVA_API OR ANDROID)
message(STATUS " BUILD_JAVA_API: ON")
else()
message(STATUS " BUILD_JAVA_API: OFF")
endif()
if(CMAKE_COMPILER_IS_GNUCXX)
umf_status(" CODE_COVERAGE: ${CODE_COVERAGE}")
endif()
#if(WIN32)
SET(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE INTERNAL "Install path prefix" FORCE)
#endif()
set(CMAKE_DEBUG_POSTFIX "d")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
set(LIBRARY_OUTPUT_PATH "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
if (UNIX)
add_definitions(-D_FILE_OFFSET_BITS=64)
endif()
if(WIN32)
add_definitions(-D_VARIADIC_MAX=10)
else()
if(ANDROID)
set(BUILD_SAMPLES OFF)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm*")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -z muldefs")
endif()
elseif(APPLE)
if(NOT IOS)
if (NOT DEFINED CMAKE_MACOSX_RPATH)
set(CMAKE_MACOSX_RPATH 0)
endif()
endif()
else()
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
endif()
file(APPEND "${umf_build_info_FILE}" " CMake version = ${CMAKE_VERSION}\n")
file(APPEND "${umf_build_info_FILE}" ")umf_build_info\";\n")
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${umf_build_info_FILE}" "${CMAKE_BINARY_DIR}/build-info.inc" OUTPUT_QUIET)
message(STATUS "*** *** ***")
#enable_testing(true)
if(BUILD_TESTS)
add_subdirectory(${UMF_3PTY_DIR}/gtest)
endif()
add_subdirectory(${UMF_3PTY_DIR}/xmp)
add_subdirectory(${UMF_3PTY_DIR}/libxml2)
add_subdirectory(${UMF_3PTY_DIR}/libjson)
add_subdirectory(${UMF_3PTY_DIR}/cryptopp)
add_subdirectory(modules)
if(BUILD_SAMPLES)
set(CMAKE_DISABLE_FIND_PACKAGE_VMF TRUE)
set(UMF_LIB_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
set(UMF_LIBS umf)
set(UMF_INCLUDE_DIR "${MODULES_DIR}/umfcore/include" "${CMAKE_BINARY_DIR}")
set(UMF_DATA_DIR "${CMAKE_SOURCE_DIR}/data")
if(BUILD_JAVA_API)
set(UMF_JAR_PATH "${CMAKE_BINARY_DIR}/bin/umf_java.jar")
endif()
add_subdirectory(samples)
endif()
if(NOT ANDROID)
find_package(Doxygen)
if(DOXYGEN_FOUND)
configure_file(Doxyfile.in ${CMAKE_BINARY_DIR}/Doxyfile @ONLY)
add_custom_target(doc ALL
${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM
)
endif()
endif()
if (BUILD_INSTALLER)
set(CPACK_PACKAGE_NAME "Intel UMF SDK")
set(CPACK_PACKAGE_VENDOR "Intel")
set(CPACK_PACKAGE_VERSION "${UMF_VERSION_MAJOR}.${UMF_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_MAJOR ${UMF_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${UMF_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH "0")
set(CPACK_PACKAGE_FILE_NAME "Intel-UMF-SDK-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
if(UMF_VERSION_TYPE)
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-${UMF_VERSION_TYPE}")
endif()
set(CPACK_PACKAGE_INSTALL_DIRECTORY "Intel-UMF-SDK-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
set(CPACK_GENERATOR "WIX")
set(CPACK_WIX_PRODUCT_GUID "F05416DA-303D-4952-BEF4-D576AE4F4A3A")
set(CPACK_WIX_UPGRADE_GUID "4CF37946-64F6-4841-8E8C-6E7BBE2F7654")
#set(CPACK_WIX_PRODUCT_ICON "")
#set(CPACK_WIX_UI_BANNER "") 493x58
#set(CPACK_WIX_UI_DIALOG "") 493x312
#set(CPACK_WIX_TEMPLATE "") main.wxs
# android libs
add_custom_target(ANDROID_LIBS
build_android_libs.py
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Compiling libraries for android" VERBATIM
)
if(EXISTS "${CMAKE_SOURCE_DIR}/android_libs")
install(DIRECTORY "android_libs" DESTINATION ".")
endif()
# libs built by current project
# installed in modules/CMakeLists.txt
# For other platforms
if(EXISTS "${CMAKE_SOURCE_DIR}/to_be_installed")
file(GLOB TO_BE_INSTALLED "to_be_installed/*")
foreach(SUBDIR ${TO_BE_INSTALLED})
install(DIRECTORY ${SUBDIR} DESTINATION ".")
endforeach()
endif()
# CMake files
install(FILES "cmake/FindVMF.cmake" DESTINATION "cmake")
# samples stuff
install(DIRECTORY "samples" DESTINATION ".")
install(DIRECTORY "data" DESTINATION ".")
install(FILES "cmake/FindVMF.cmake" DESTINATION "samples")
if (BUILD_JAVA_API)
install(FILES "${CMAKE_BINARY_DIR}/bin/umf_java.jar" DESTINATION "java")
endif()
# documentation
install(FILES "docs/VMF_Release_Notes.pdf" DESTINATION "docs")
install(FILES "docs/VMF_User_guide.pdf" DESTINATION "docs")
install(FILES "docs/VMF_Specification.pdf" DESTINATION "docs")
install(FILES "LICENSE" DESTINATION ".")
if(DOXYGEN_FOUND)
install(DIRECTORY "${CMAKE_BINARY_DIR}/doc/html/" DESTINATION "docs/API-Spec")
endif()
include(CPack)
endif()
if(IOS)
configure_file("${CMAKE_SOURCE_DIR}/platforms/ios/Info.plist.in"
"${CMAKE_BINARY_DIR}/ios/Info.plist")
endif()