"Fossies" - the Fresh Open Source Software Archive 
Member "encfs-1.9.5/CMakeLists.txt" (27 Apr 2018, 12896 Bytes) of package /linux/misc/encfs-1.9.5.tar.gz:
As a special service "Fossies" has tried to format the requested text file into HTML format (style:
standard) with prefixed line numbers.
Alternatively you can here
view or
download the uninterpreted source code file.
See also the latest
Fossies "Diffs" side-by-side code changes report for "CMakeLists.txt":
1.9.4_vs_1.9.5.
1 set(CMAKE_LEGACY_CYGWIN_WIN32 0)
2
3 # 3.0.2 preferred, but we can often get by with 2.8.
4 cmake_minimum_required(VERSION 2.8)
5 if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} LESS 3.0.2)
6 message(WARNING "You should use cmake 3.0.2 or newer for configuration to run correctly.")
7 endif()
8
9 project(EncFS C CXX)
10
11 set (ENCFS_MAJOR 1)
12 set (ENCFS_MINOR 9)
13 set (ENCFS_PATCH 5)
14 set (ENCFS_VERSION "${ENCFS_MAJOR}.${ENCFS_MINOR}.${ENCFS_PATCH}")
15 set (ENCFS_SOVERSION "${ENCFS_MAJOR}.${ENCFS_MINOR}")
16 set (ENCFS_NAME "Encrypted Filesystem")
17
18 option(IWYU "Build with IWYU analysis." OFF)
19
20 set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
21 "${CMAKE_CURRENT_LIST_DIR}/cmake")
22
23 set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
24 "${CMAKE_CURRENT_LIST_DIR}/vendor/github.com/muflihun/easyloggingpp/cmake")
25
26 option (BUILD_UNIT_TESTS "build EncFS unit tests" ON)
27 option (USE_INTERNAL_TINYXML "use built-in TinyXML2" ON)
28 option (USE_INTERNAL_EASYLOGGING "use built-in Easylogging++" ON)
29 option (BUILD_SHARED_LIBS "build internal libraries as shared" OFF)
30 option (ENABLE_NLS "compile with Native Language Support (using gettext)" ON)
31 option (INSTALL_LIBENCFS "install libencfs" OFF)
32 option (LINT "enable lint output" OFF)
33
34 if (NOT DEFINED LIB_INSTALL_DIR)
35 set (LIB_INSTALL_DIR lib)
36 endif ()
37
38 if (CYGWIN)
39 if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
40 set (CMAKE_INSTALL_PREFIX /usr)
41 endif()
42 endif()
43
44 # We need C++ 11
45 if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.0)
46 # CMake 3.1 has built-in CXX standard checks.
47 set(CMAKE_CXX_STANDARD 11)
48 set(CMAKE_CXX_STANDARD_REQUIRED on)
49 else ()
50 if (CMAKE_COMPILER_IS_GNUCXX)
51 message ("** Assuming that GNU CXX uses -std=c++11 flag for C++11 compatibility.")
52 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
53 elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
54 message ("** Assuming that Clang uses -std=c++11 flag for C++11 compatibility.")
55 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
56 else()
57 message ("** No CMAKE C++11 check. If the build breaks, you're on your own.")
58 endif()
59 endif ()
60
61 # Let's enable some compilation warnings
62 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
63
64 # Let's enable some shared lib flags
65 if (BUILD_SHARED_LIBS)
66 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
67 endif ()
68
69 add_definitions( -DPACKAGE="encfs" )
70
71 # http://www.cmake.org/Wiki/CMake_RPATH_handling#Mac_OS_X_and_the_RPATH
72 if (APPLE)
73 set(CMAKE_MACOSX_RPATH ON)
74 set(CMAKE_SKIP_BUILD_RPATH FALSE)
75 set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
76 set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}")
77 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
78 list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}" isSystemDir)
79 if("${isSystemDir}" STREQUAL "-1")
80 set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}")
81 endif()
82 endif()
83
84 if (CYGWIN OR WIN32 OR APPLE)
85 set(DEFAULT_CASE_INSENSITIVE TRUE)
86 else()
87 set(DEFAULT_CASE_INSENSITIVE FALSE)
88 endif()
89
90 if (CYGWIN)
91 find_program(PKILL NAMES "pkill")
92 if(NOT PKILL)
93 message(FATAL_ERROR "pkill not found, please install procps-ng package.")
94 endif()
95 endif()
96
97 # Check for FUSE.
98 find_package (FUSE REQUIRED)
99 include_directories (SYSTEM ${FUSE_INCLUDE_DIR})
100 add_definitions (-D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=29)
101 if (CYGWIN)
102 # Cygwin build is intended to use WinFsp
103 add_definitions(-DCYGFUSE)
104 endif()
105
106 # Check for OpenSSL.
107 find_package (OpenSSL REQUIRED)
108 include_directories (SYSTEM ${OPENSSL_INCLUDE_DIR})
109
110 find_program (POD2MAN pod2man)
111
112 # Check for include files and stdlib properties.
113 include (CheckIncludeFileCXX)
114 if (NOT CYGWIN)
115 check_include_file_cxx (attr/xattr.h HAVE_ATTR_XATTR_H)
116 check_include_file_cxx (sys/xattr.h HAVE_SYS_XATTR_H)
117 endif()
118
119 include(CheckStructHasMember)
120 check_struct_has_member("struct dirent" d_type dirent.h HAVE_DIRENT_D_TYPE LANGUAGE CXX)
121
122 # Check if xattr functions take extra arguments, as they do on OSX.
123 include (CheckCXXSourceCompiles)
124 check_cxx_source_compiles ("#include <sys/types.h>
125 #include <sys/xattr.h>
126 int main() { getxattr(0,0,0,0,0,0); return 1; }
127 " XATTR_ADD_OPT)
128
129 # If awailable on current architecture (typically embedded 32-bit), link with it explicitly;
130 # GCC autodetection is faulty, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81358 and
131 # find_libray is no great help here since it is sometimes(!) not in standard paths.
132 set(CMAKE_REQUIRED_FLAGS "-latomic")
133 CHECK_CXX_SOURCE_COMPILES("int main() {return 0;}" COMPILER_NEEDS_LATOMIC)
134 if(COMPILER_NEEDS_LATOMIC)
135 set(ATOMIC_LIBRARY atomic)
136 endif()
137 # compensate the effect of extra linking of libatomic on platforms where intrinsics are used
138 set(CMAKE_REQUIRED_FLAGS "-Wl,--as-needed")
139 CHECK_CXX_SOURCE_COMPILES("int main() {return 0;}" LINKER_SUPPORTS_WLASNEEDED)
140 if(LINKER_SUPPORTS_WLASNEEDED)
141 SET(EXTRA_LINKER_FLAGS "-Wl,--as-needed")
142 endif()
143
144 set(CMAKE_REQUIRED_FLAGS)
145
146 # Check if we have some standard functions.
147 include (CheckFuncs)
148 check_function_exists_glibc (lchmod HAVE_LCHMOD)
149 check_function_exists_glibc (utimensat HAVE_UTIMENSAT)
150 if (APPLE)
151 message ("-- There is no usable FDATASYNC on Apple")
152 set(HAVE_FDATASYNC FALSE)
153 else()
154 check_function_exists_glibc (fdatasync HAVE_FDATASYNC)
155 endif (APPLE)
156
157 set (CMAKE_THREAD_PREFER_PTHREAD)
158 find_package (Threads REQUIRED)
159
160 # Logging.
161 add_definitions (-DELPP_THREAD_SAFE -DELPP_DISABLE_DEFAULT_CRASH_HANDLING)
162 add_definitions (-DELPP_NO_DEFAULT_LOG_FILE)
163 add_definitions (-DELPP_CUSTOM_COUT=std::cerr)
164 check_include_file_cxx (syslog.h HAVE_SYSLOG_H)
165 if (HAVE_SYSLOG_H)
166 message ("-- Enabled syslog logging support")
167 add_definitions(-DELPP_SYSLOG)
168 endif (HAVE_SYSLOG_H)
169
170 # Packaging config.
171 set (CPACK_PACKAGE_NAME "encfs")
172 set (CPACK_PACKAGE_VERSION_MAJOR ${ENCFS_MAJOR})
173 set (CPACK_PACKAGE_VERSION_MINOR ${ENCFS_MINOR})
174 set (CPACK_SOURCE_GENERATOR TGZ)
175 set (CPACK_SOURCE_IGNORE_FILES
176 "/build/")
177 include (CPack)
178
179 # Compile-time configuration.
180 configure_file (${CMAKE_CURRENT_LIST_DIR}/config.h.cmake
181 ${CMAKE_BINARY_DIR}/config.h)
182
183 include_directories (${CMAKE_BINARY_DIR})
184 include_directories (${CMAKE_CURRENT_LIST_DIR})
185
186 # Translations
187 if (ENABLE_NLS)
188 find_package (Intl)
189 if (Intl_FOUND)
190 include_directories (SYSTEM ${Intl_INCLUDE_DIRS})
191 endif()
192
193 add_subdirectory(po)
194
195 add_definitions(-DENABLE_NLS)
196 add_definitions(-DLOCALEDIR="${CMAKE_INSTALL_PREFIX}/share/locale")
197 endif (ENABLE_NLS)
198
199 if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.5) # Need 3.6 or above.
200 find_program(CLANG_TIDY_EXE NAMES "clang-tidy-4.0" "clang-tidy40" "clang-tidy" DOC "Path to clang-tidy executable")
201 if(NOT CLANG_TIDY_EXE)
202 message(STATUS "clang-tidy not found.")
203 else()
204 message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}")
205 string(CONCAT TIDY_OPTS "-checks=*"
206 ",-cert-err58-cpp"
207 ",-cppcoreguidelines-pro-*"
208 ",-google-build-using-namespace"
209 ",-google-readability-casting"
210 ",-google-readability-todo"
211 ",-google-runtime-int"
212 ",-google-runtime-references"
213 ",-modernize-loop-convert"
214 ",-performance-inefficient-string-concatenation"
215 ",-readability-inconsistent-declaration-parameter-name"
216 ",-readability-named-parameter"
217 )
218 set(DO_CLANG_TIDY "${CLANG_TIDY_EXE}" ${TIDY_OPTS})
219 #set(DO_CLANG_TIDY "${CLANG_TIDY_EXE}" "-fix" "-checks=-*,google-readability-redundant-smartptr-get")
220 endif()
221 else()
222 message(STATUS "clang-tidy check skipped, need newer cmake")
223 endif()
224
225 if (USE_INTERNAL_TINYXML)
226 message("-- Using vendored TinyXML2")
227 set(TINYXML_DIR vendor/github.com/leethomason/tinyxml2)
228 if (BUILD_SHARED_LIBS)
229 set(BUILD_STATIC_LIBS OFF CACHE BOOL "build static libs")
230 set(BUILD_SHARED_LIBS ON CACHE BOOL "build shared libs")
231 set(TINYXML_LIBRARIES tinyxml2)
232 else ()
233 set(BUILD_STATIC_LIBS ON CACHE BOOL "build static libs")
234 set(BUILD_SHARED_LIBS OFF CACHE BOOL "build shared libs")
235 set(TINYXML_LIBRARIES tinyxml2_static)
236 endif ()
237 set(BUILD_TESTS OFF CACHE BOOL "build tests")
238 add_subdirectory(${TINYXML_DIR} EXCLUDE_FROM_ALL)
239 include_directories(SYSTEM ${CMAKE_CURRENT_LIST_DIR}/${TINYXML_DIR})
240 link_directories(${CMAKE_BINARY_DIR}/${TINYXML_DIR})
241 else ()
242 find_package (TinyXML REQUIRED)
243 include_directories (SYSTEM ${TINYXML_INCLUDE_DIR})
244 endif ()
245
246 if (USE_INTERNAL_EASYLOGGING)
247 message("-- Using vendored Easylogging++")
248 set(EASYLOGGING_DIR vendor/github.com/muflihun/easyloggingpp)
249 set(build_static_lib ON CACHE BOOL "build static libs")
250 add_subdirectory(${EASYLOGGING_DIR} EXCLUDE_FROM_ALL)
251 include_directories(SYSTEM ${CMAKE_CURRENT_LIST_DIR}/${EASYLOGGING_DIR}/src)
252 link_directories(${CMAKE_BINARY_DIR}/${EASYLOGGING_DIR})
253 set(EASYLOGGINGPP_LIBRARY easyloggingpp)
254 else ()
255 set(EASYLOGGINGPP_USE_SHARED_LIBS ON CACHE BOOL "look for shared lib")
256 find_package (EASYLOGGINGPP REQUIRED)
257 include_directories (SYSTEM ${EASYLOGGINGPP_INCLUDE_DIR})
258 endif ()
259
260 set(SOURCE_FILES
261 encfs/autosprintf.cpp
262 encfs/base64.cpp
263 encfs/BlockFileIO.cpp
264 encfs/BlockNameIO.cpp
265 encfs/Cipher.cpp
266 encfs/CipherFileIO.cpp
267 encfs/CipherKey.cpp
268 encfs/ConfigReader.cpp
269 encfs/ConfigVar.cpp
270 encfs/Context.cpp
271 encfs/DirNode.cpp
272 encfs/encfs.cpp
273 encfs/Error.cpp
274 encfs/FileIO.cpp
275 encfs/FileNode.cpp
276 encfs/FileUtils.cpp
277 encfs/Interface.cpp
278 encfs/MACFileIO.cpp
279 encfs/MemoryPool.cpp
280 encfs/NameIO.cpp
281 encfs/NullCipher.cpp
282 encfs/NullNameIO.cpp
283 encfs/openssl.cpp
284 encfs/RawFileIO.cpp
285 encfs/readpassphrase.cpp
286 encfs/SSL_Cipher.cpp
287 encfs/StreamNameIO.cpp
288 encfs/XmlReader.cpp
289 )
290 add_library(encfs ${SOURCE_FILES})
291 set_target_properties(encfs PROPERTIES
292 VERSION ${ENCFS_VERSION}
293 SOVERSION ${ENCFS_SOVERSION})
294 target_link_libraries(encfs
295 ${EXTRA_LINKER_FLAGS}
296 ${FUSE_LIBRARIES}
297 ${OPENSSL_LIBRARIES}
298 ${TINYXML_LIBRARIES}
299 ${EASYLOGGINGPP_LIBRARY}
300 ${CMAKE_THREAD_LIBS_INIT}
301 ${Intl_LIBRARIES}
302 ${ATOMIC_LIBRARY}
303 )
304 if (INSTALL_LIBENCFS)
305 install (TARGETS encfs DESTINATION ${LIB_INSTALL_DIR})
306 endif (INSTALL_LIBENCFS)
307
308 if (IWYU)
309 if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.2)
310 find_program(iwyu_path NAMES include-what-you-use iwyu)
311 if (iwyu_path)
312 message ("-- Enabled IWYU")
313 set_property(TARGET encfs PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${iwyu_path})
314 endif()
315 endif()
316 endif()
317
318 # Set RPATH to library install path.
319 set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}")
320
321 add_executable (encfs-bin encfs/main.cpp)
322 target_link_libraries (encfs-bin encfs)
323 set_target_properties (encfs-bin PROPERTIES OUTPUT_NAME "encfs")
324 install (TARGETS encfs-bin DESTINATION bin)
325
326 if(LINT AND CLANG_TIDY_EXE)
327 set_target_properties(encfs PROPERTIES CXX_CLANG_TIDY "${DO_CLANG_TIDY}")
328 set_target_properties(encfs-bin PROPERTIES CXX_CLANG_TIDY "${DO_CLANG_TIDY}")
329 endif()
330
331 add_executable (encfsctl encfs/encfsctl.cpp)
332 target_link_libraries (encfsctl encfs)
333 install (TARGETS encfsctl DESTINATION bin)
334
335 add_executable (makekey encfs/makeKey.cpp)
336 target_link_libraries (makekey encfs)
337
338 add_executable (checkops encfs/test.cpp)
339 target_link_libraries (checkops encfs)
340
341 install (PROGRAMS encfs/encfssh DESTINATION bin)
342
343 # Reference all headers, to make certain IDEs happy.
344 file (GLOB_RECURSE all_headers ${CMAKE_CURRENT_LIST_DIR}/*.h)
345 add_custom_target (all_placeholder SOURCES ${all_headers})
346
347 if (POD2MAN)
348 set (MAN_DESTINATION "share/man/man1")
349 if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
350 set (MAN_DESTINATION "man/man1")
351 endif()
352
353 add_custom_target (encfs-man ALL
354 COMMAND ${POD2MAN} -u --section=1 --release=${ENCFS_VERSION} --center=${ENCFS_NAME}
355 ${CMAKE_CURRENT_LIST_DIR}/encfs/encfs.pod encfs.1)
356
357 add_custom_target (encfsctl-man ALL
358 COMMAND ${POD2MAN} -u --section=1 --release=${ENCFS_VERSION} --center=${ENCFS_NAME}
359 ${CMAKE_CURRENT_LIST_DIR}/encfs/encfsctl.pod encfsctl.1)
360
361 add_custom_target (encfssh-man ALL
362 COMMAND ${POD2MAN} -u --section=1 --release=${ENCFS_VERSION} --center=${ENCFS_NAME}
363 ${CMAKE_CURRENT_LIST_DIR}/encfs/encfssh.pod encfssh.1)
364
365 install (FILES ${CMAKE_BINARY_DIR}/encfs.1 ${CMAKE_BINARY_DIR}/encfsctl.1 ${CMAKE_BINARY_DIR}/encfssh.1
366 DESTINATION ${MAN_DESTINATION})
367 endif (POD2MAN)
368
369 if (BUILD_UNIT_TESTS)
370 enable_testing()
371
372 set(GOOGLETEST_DIR vendor/github.com/google/googletest)
373 add_subdirectory(${GOOGLETEST_DIR} EXCLUDE_FROM_ALL)
374 link_directories(${CMAKE_BINARY_DIR}/${GOOGLETEST_DIR}/googletest)
375
376 set(GOOGLEBENCH_DIR vendor/github.com/google/benchmark)
377 set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "benchmark tests")
378 add_subdirectory(${GOOGLEBENCH_DIR} EXCLUDE_FROM_ALL)
379 link_directories(${CMAKE_BINARY_DIR}/${GOOGLEBENCH_DIR})
380
381 # Unit tests.
382 add_subdirectory(test EXCLUDE_FROM_ALL)
383
384 # Integration test target - runs against built encfs.
385 add_custom_target(integration COMMAND ${CMAKE_CURRENT_LIST_DIR}/integration.sh)
386 endif ()