forked from zbackup/zbackup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
75 lines (58 loc) · 2.46 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
# Copyright (c) 2012-2014 Konstantin Isakov <[email protected]> and ZBackup contributors, see CONTRIBUTORS
# Part of ZBackup. Licensed under GNU GPLv2 or later + OpenSSL, see LICENSE
cmake_minimum_required( VERSION 2.8.3 )
project( zbackup )
list( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" )
if( NOT CMAKE_BUILD_TYPE )
set( CMAKE_BUILD_TYPE Release )
endif( NOT CMAKE_BUILD_TYPE )
find_package( ZLIB REQUIRED )
include_directories( ${ZLIB_INCLUDE_DIRS} )
find_package( OpenSSL REQUIRED )
include_directories( ${OPENSSL_INCLUDE_DIR} )
find_package( Protobuf REQUIRED )
include_directories( ${PROTOBUF_INCLUDE_DIRS} )
include_directories( ${CMAKE_CURRENT_BINARY_DIR} )
find_program( PROTOBUF_PROTOC_CHECK NAMES protoc DOC "Protobuf compiler binary" )
IF( ${PROTOBUF_PROTOC_CHECK} STREQUAL "PROTOBUF_PROTOC_CHECK-NOTFOUND" )
MESSAGE( FATAL_ERROR "Could not find protobuf compiler. Make sure protobuf-compiler package is installed." )
ENDIF( ${PROTOBUF_PROTOC_CHECK} STREQUAL "PROTOBUF_PROTOC_CHECK-NOTFOUND" )
PROTOBUF_GENERATE_CPP( protoSrcs protoHdrs zbackup.proto )
find_package( Threads REQUIRED )
find_package( LibLZMA REQUIRED )
include_directories( ${LIBLZMA_INCLUDE_DIRS} )
find_package( LibLZO COMPONENTS LIBLZO_HAS_LZO1X_DECOMPRESS_SAFE LIBLZO_HAS_LZO1X_1_COMPRESS )
if ( LIBLZO_FOUND )
ADD_DEFINITIONS( -DHAVE_LIBLZO )
include_directories( ${LIBLZO_INCLUDE_DIRS} )
else ( LIBLZO_FOUND )
set( LIBLZO_LIBRARIES )
endif( LIBLZO_FOUND )
find_package( LibUnwind COMPONENTS LIBUNWIND_HAS_UNW_GETCONTEXT LIBUNWIND_HAS_INIT_LOCAL )
if ( LIBUNWIND_FOUND )
ADD_DEFINITIONS( -DHAVE_LIBUNWIND )
include_directories( ${LIBUNWIND_INCLUDE_DIRS} )
else ( LIBUNWIND_FOUND )
set( LIBUNWIND_LIBRARIES )
endif( LIBUNWIND_FOUND )
add_custom_target( invalidate_files ALL
COMMAND ${CMAKE_COMMAND} -E touch "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt" )
execute_process( OUTPUT_VARIABLE ZBACKUP_VERSION
COMMAND git describe --tags --always
OUTPUT_STRIP_TRAILING_WHITESPACE )
if ( ZBACKUP_VERSION )
ADD_DEFINITIONS( -DZBACKUP_VERSION="${ZBACKUP_VERSION}" )
MESSAGE("ZBackup version ${ZBACKUP_VERSION}")
endif( ZBACKUP_VERSION )
file( GLOB sourceFiles "*.cc" "*.c" )
add_executable( zbackup ${sourceFiles} ${protoSrcs} ${protoHdrs} )
target_link_libraries( zbackup
${PROTOBUF_LIBRARIES}
${OPENSSL_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
${ZLIB_LIBRARIES}
${LIBLZMA_LIBRARIES}
${LIBLZO_LIBRARIES}
${LIBUNWIND_LIBRARIES}
)
install( TARGETS zbackup DESTINATION bin )