-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
140 lines (117 loc) · 4.82 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
# Copyright 2008 28msec, Inc.
#
# 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.
#
PROJECT(libaws)
SET(LIBCRYPTO "crypto")
SET(LIBPTHREADS "pthread")
IF(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
INCLUDE(CMakeWindows.cmake)
SET(LIBCRYPTO "")
SET(LIBPTHREADS "${PTHREAD_LIB_PATHS}/pthreadVCE.lib")
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
# ctest support
ENABLE_TESTING()
INCLUDE(CTest)
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
IF(COMMAND cmake_policy)
CMAKE_POLICY(SET CMP0003 NEW)
ENDIF(COMMAND cmake_policy)
# prohibit in-source-builds
IF (${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
MESSAGE(STATUS "In-source-builds are not allowed")
MESSAGE(STATUS "Clean your source directory (e.g. delete the CMakeCache.txt file)")
MESSAGE(FATAL_ERROR "Please create a separate build directory and call CMake again")
ENDIF (${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
# set the default build type to debug
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Debug CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
ENDIF(NOT CMAKE_BUILD_TYPE)
# Look for required libraries
SET(requiredlibs)
FIND_PACKAGE(CURL)
IF(CURL_FOUND)
INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIR})
SET(requiredlibs ${requiredlibs} ${CURL_LIBRARIES} )
ELSE(CURL_FOUND)
MESSAGE(FATAL_ERROR "Could not find the CURL library and development files.")
ENDIF(CURL_FOUND)
FIND_PACKAGE(OpenSSL)
IF(OPENSSL_FOUND)
INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR})
SET(requiredlibs ${requiredlibs} ${OPENSSL_LIBRARIES} ${LIBCRYPTO}) # bugfix, because libcrypto is not found automatically
ELSE(OPENSSL_FOUND)
MESSAGE(FATAL_ERROR "Could not find the OpenSSL library and development files.")
ENDIF(OPENSSL_FOUND)
FIND_PACKAGE(LibXml2)
IF(LIBXML2_FOUND)
INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR})
SET(requiredlibs ${requiredlibs} ${LIBXML2_LIBRARIES})
SET(CXXFLAGS ${CXXFLAGS} ${LIBXML2_DEFINITONS}) # needed?
ELSE(LIBXML2_FOUND)
MESSAGE(FATAL_ERROR "Could not find the libxml2 library and development files.")
ENDIF(LIBXML2_FOUND)
INCLUDE (CheckIncludeFiles)
SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${PTHREADLIB})
CHECK_INCLUDE_FILES(pthread.h LIBAWS_HAVE_PTHREAD_H)
MESSAGE(STATUS "CMAKE REQUIRED INCLUDES:${CMAKE_REQUIRED_INCLUDES}")
IF(NOT LIBAWS_HAVE_PTHREAD_H)
MESSAGE(FATAL_ERROR "Could not find pthread development headers.")
ELSE(NOT LIBAWS_HAVE_PTHREAD_H)
SET(requiredlibs ${requiredlibs} ${LIBPTHREADS})
ENDIF(NOT LIBAWS_HAVE_PTHREAD_H)
SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules)
INCLUDE(CMakeConfiguration.txt)
INCLUDE(CMakeCompiler.txt)
SET(LIBAWS_MAJOR_VERSION "0")
SET(LIBAWS_MINOR_VERSION "9")
SET(LIBAWS_PATCH_VERSION "3")
# set the include path to the API headers
# note that there also some generated headers files in the build directory
INCLUDE_DIRECTORIES(AFTER ${CMAKE_CURRENT_SOURCE_DIR}/include)
INCLUDE_DIRECTORIES(AFTER ${CMAKE_CURRENT_BINARY_DIR}/include)
FIND_PACKAGE(Fuse)
IF(FUSE_FOUND)
MESSAGE(STATUS "Found Fuse. Building the s3fs module.")
ELSE(FUSE_FOUND)
MESSAGE(STATUS "Fuse not found. Can't build the s3fs module.")
ENDIF(FUSE_FOUND)
# Tell CMake to process the sub-directories
ADD_SUBDIRECTORY(include)
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(tests)
ADD_SUBDIRECTORY(bin)
IF(FUSE_FOUND)
ADD_SUBDIRECTORY(fuse)
ENDIF(FUSE_FOUND)
ADD_SUBDIRECTORY(doc)
# add the uninstall support
CONFIGURE_FILE(
"${CMAKE_CURRENT_SOURCE_DIR}/CMakeUninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/CMakeUninstall.cmake"
@ONLY)
MESSAGE(STATUS "configured ${CMAKE_CURRENT_SOURCE_DIR}/CMakeUninstall.cmake.in --> ${CMAKE_CURRENT_BINARY_DIR}/CMakeUninstall.cmake")
ADD_CUSTOM_TARGET(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/CMakeUninstall.cmake")
# configure the cmake script to create a source package
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/CPackSourceConfig.cmake.in
${CMAKE_BINARY_DIR}/CPackSourceConfig.cmake)
MESSAGE(STATUS "configured ${CMAKE_SOURCE_DIR}/CPackSourceConfig.cmake.in --> ${CMAKE_BINARY_DIR}/CPackSourceConfig.cmake")
# export stuff
INCLUDE(CMakeExportBuildSettings)
CMAKE_EXPORT_BUILD_SETTINGS(${CMAKE_BINARY_DIR}/LIBAWSBuildSettings.cmake)
EXPORT_LIBRARY_DEPENDENCIES(${CMAKE_BINARY_DIR}/LIBAWSDepends.cmake)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/LIBAWSConfig.cmake.in ${CMAKE_BINARY_DIR}/LIBAWSConfig.cmake)
INCLUDE(CMakeCPack.cmake)