1include(DownloadExternal)
2
3# Download GoogleTest
4if(ENABLE_TESTS)
5  download_external(GTEST "googletest-release-1.7.0"
6                    "https://github.com/google/googletest/archive/release-1.7.0.zip"
7                    "ef5e700c8a0f3ee123e2e0209b8b4961")
8endif()
9
10# Find standard libraries
11find_package(Socket REQUIRED)
12find_package(Threads REQUIRED)
13
14if(NOT MINGW)
15  find_package(FUSE REQUIRED)
16endif()
17
18find_library(RT_LIBRARY rt)
19message(STATUS "RT_LIBRARY: ${RT_LIBRARY}")
20if(ENABLE_TCMALLOC)
21  find_library(TCMALLOC_LIBRARY NAMES tcmalloc_minimal)
22  message(STATUS "TCMALLOC_LIBRARY: ${TCMALLOC_LIBRARY}")
23endif()
24
25
26# Find extra binaries
27find_program(A2X_BINARY a2x)
28message(STATUS "a2x: ${A2X_BINARY}")
29
30# Find Zlib
31find_package(ZLIB)
32if(ZLIB_FOUND)
33  message(STATUS "Found Zlib ${ZLIB_VERSION_STRING}")
34  set(LIZARDFS_HAVE_ZLIB_H 1)
35else()
36  message(STATUS "Could not find Zlib")
37  message(STATUS "   This dependency is optional.")
38  message(STATUS "   If it's installed in a non-standard path, set ZLIB_ROOT variable")
39  message(STATUS "   to point this path (cmake -DZLIB_ROOT=...)")
40endif()
41
42# Find Systemd
43INCLUDE(FindPkgConfig)
44pkg_check_modules(SYSTEMD libsystemd)
45if(SYSTEMD_FOUND)
46  check_include_files(systemd/sd-daemon.h LIZARDFS_HAVE_SYSTEMD_SD_DAEMON_H)
47  message(STATUS "Found Systemd ${SYSTEMD_VERSION_STRING}")
48else()
49  message(STATUS "Could not find Systemd (but it is not required)")
50endif()
51
52# Find Boost
53set(BOOST_MIN_VERSION "1.48.0")
54find_package(Boost ${BOOST_MIN_VERSION} COMPONENTS filesystem iostreams program_options system)
55
56# Find Thrift
57find_package(Thrift COMPONENTS library)
58if(THRIFT_FOUND)
59  message(STATUS "Found Thrift")
60else()
61  message(STATUS "Could NOT find Thrift (but it's not required)")
62  message(STATUS "   If it's installed in a non-standard path, set THRIFT_ROOT variable")
63  message(STATUS "   to point this path (cmake -DTHRIFT_ROOT=...)")
64endif()
65
66# Find Polonaise
67set(POLONAISE_REQUIRED_VERSION 0.3.1)
68find_package(Polonaise ${POLONAISE_REQUIRED_VERSION} EXACT QUIET NO_MODULE NO_CMAKE_BUILDS_PATH)
69if(POLONAISE_FOUND)
70  message(STATUS "Found Polonaise")
71else()
72  message(STATUS "Could NOT find Polonaise v${POLONAISE_REQUIRED_VERSION} (but it's not required)")
73  if(Polonaise_CONSIDERED_VERSIONS)
74    message(STATUS "   Incompatible versions ${Polonaise_CONSIDERED_VERSIONS} "
75        "found in ${Polonaise_CONSIDERED_CONFIGS}")
76  endif()
77  message(STATUS "   If it's installed in a non-standard path, set Polonaise_DIR variable")
78  message(STATUS "   to point this path (cmake -DPolonaise_DIR=...)")
79endif()
80
81# Find crcutil
82if(NOT BIG_ENDIAN)
83  INCLUDE(FindPkgConfig)
84  pkg_check_modules(CRCUTIL libcrcutil)
85  if(CRCUTIL_FOUND)
86    message(STATUS "Found libcrcutil")
87    set(HAVE_CRCUTIL 1)
88  else()
89    message(STATUS "Could NOT find system libcrcutil (but it's not required)")
90    set(CRCUTIL_VERSION crcutil-1.0)
91    message(STATUS "Using bundled ${CRCUTIL_VERSION}")
92    set(HAVE_CRCUTIL 1)
93    set(CRCUTIL_LIBRARIES "crcutil")
94    set(CRCUTIL_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/external/${CRCUTIL_VERSION}/code)
95    set(CRCUTIL_SOURCE_DIR ${CMAKE_SOURCE_DIR}/external/${CRCUTIL_VERSION}/code)
96
97    if(CXX_HAS_MCRC32)
98      set(CRCUTIL_CXX_FLAGS "-mcrc32")
99    else()
100      set(CRCUTIL_CXX_FLAGS "")
101    endif()
102
103  endif()
104endif()
105
106# Find GoogleTest
107if(ENABLE_TESTS)
108  set(GTEST_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/external/${GTEST_DIR_NAME}/include)
109  set(TEST_LIBRARIES "" CACHE INTERNAL "" FORCE)
110endif()
111
112# Find Judy
113find_package(Judy)
114if(JUDY_FOUND)
115  set(LIZARDFS_HAVE_JUDY YES)
116  set(LIZARDFS_HAVE_WORKING_JUDY1 ${JUDY_HAVE_WORKING_JUDY1})
117endif()
118
119# Find PAM libraries
120find_package(PAM)
121if(PAM_FOUND)
122  set(LIZARDFS_HAVE_PAM YES)
123endif()
124
125# Find BerkeleyDB
126find_package(DB 11.2.5.2)
127
128# Find Intel Storage Acceleration library
129find_library(ISAL_LIBRARY isal)
130if(APPLE)
131  find_library(ISAL_PIC_LIBRARY libisal.dylib)
132else()
133  find_library(ISAL_PIC_LIBRARY libisal.so)
134endif()
135if(NOT ISAL_PIC_LIBRARY)
136  find_library(ISAL_PIC_LIBRARY isal_pic)
137endif()
138if (NOT ISAL_PIC_LIBRARY)
139  message(WARNING "Some systems may require position-independent ISA-L library.")
140endif()
141message(STATUS "ISAL(Intel Storage Acceleration) LIBRARY: ${ISAL_LIBRARY}")
142message(STATUS "ISAL PIC LIBRARY: ${ISAL_PIC_LIBRARY}")
143
144# Download nfs-ganesha
145if(ENABLE_NFS_GANESHA)
146  download_external(NFS_GANESHA "nfs-ganesha-2.5-stable"
147                    "https://github.com/nfs-ganesha/nfs-ganesha/archive/V2.5-stable.zip")
148  download_external(NTIRPC "ntirpc-1.5"
149                    "https://github.com/nfs-ganesha/ntirpc/archive/v1.5.zip")
150endif()
151
152