2017-05-28 16:20:21 +02:00
|
|
|
# 3.0.2 preferred, but we can often get by with 2.8.
|
2015-08-20 05:11:40 +02:00
|
|
|
cmake_minimum_required(VERSION 2.8)
|
2017-05-28 16:20:21 +02:00
|
|
|
if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} LESS 3.0.2)
|
|
|
|
message(WARNING "You should use cmake 3.0.2 or newer for configuration to run correctly.")
|
|
|
|
endif()
|
|
|
|
|
2015-06-14 07:08:13 +02:00
|
|
|
project(EncFS C CXX)
|
|
|
|
|
|
|
|
set (ENCFS_MAJOR 1)
|
|
|
|
set (ENCFS_MINOR 9)
|
2017-07-25 20:26:05 +02:00
|
|
|
set (ENCFS_PATCH 2)
|
2015-06-18 08:19:15 +02:00
|
|
|
set (ENCFS_VERSION "${ENCFS_MAJOR}.${ENCFS_MINOR}.${ENCFS_PATCH}")
|
2016-09-16 02:14:26 +02:00
|
|
|
set (ENCFS_SOVERSION "${ENCFS_MAJOR}.${ENCFS_MINOR}")
|
2015-06-14 07:08:13 +02:00
|
|
|
set (ENCFS_NAME "Encrypted Filesystem")
|
|
|
|
|
2017-03-25 13:50:56 +01:00
|
|
|
option(IWYU "Build with IWYU analysis." OFF)
|
2015-06-18 05:33:57 +02:00
|
|
|
|
2015-06-14 07:08:13 +02:00
|
|
|
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
|
2016-10-03 14:08:17 +02:00
|
|
|
"${CMAKE_CURRENT_LIST_DIR}/cmake")
|
2015-06-14 07:08:13 +02:00
|
|
|
|
2016-04-25 06:33:15 +02:00
|
|
|
option (BUILD_SHARED_LIBS "build shared libraries" OFF)
|
2016-09-05 21:09:30 +02:00
|
|
|
option (USE_INTERNAL_TINYXML "use built-in TinyXML2" ON)
|
2016-09-05 23:13:21 +02:00
|
|
|
option (ENABLE_NLS "compile with Native Language Support (using gettext)" ON)
|
|
|
|
option (INSTALL_LIBENCFS "install libencfs" OFF)
|
2017-08-04 06:22:40 +02:00
|
|
|
option (LINT "enable lint output" OFF)
|
2016-04-25 06:33:15 +02:00
|
|
|
|
2016-09-16 01:34:03 +02:00
|
|
|
if (NOT DEFINED LIB_INSTALL_DIR)
|
|
|
|
set (LIB_INSTALL_DIR lib)
|
|
|
|
endif ()
|
|
|
|
|
2015-06-14 07:08:13 +02:00
|
|
|
# We need C++ 11
|
2015-08-20 05:11:40 +02:00
|
|
|
if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.0)
|
|
|
|
# CMake 3.1 has built-in CXX standard checks.
|
|
|
|
set(CMAKE_CXX_STANDARD 11)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED on)
|
|
|
|
else ()
|
|
|
|
if (CMAKE_COMPILER_IS_GNUCXX)
|
2016-04-26 06:10:41 +02:00
|
|
|
message ("** Assuming that GNU CXX uses -std=c++11 flag for C++11 compatibility.")
|
2016-09-19 21:41:27 +02:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
2016-09-08 21:50:12 +02:00
|
|
|
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|
|
|
message ("** Assuming that Clang uses -std=c++11 flag for C++11 compatibility.")
|
2016-09-19 21:41:27 +02:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
2015-08-20 05:11:40 +02:00
|
|
|
else()
|
2016-04-26 06:10:41 +02:00
|
|
|
message ("** No CMAKE C++11 check. If the build breaks, you're on your own.")
|
2015-08-20 05:11:40 +02:00
|
|
|
endif()
|
|
|
|
endif ()
|
|
|
|
|
2016-09-05 21:09:30 +02:00
|
|
|
add_definitions( -DPACKAGE="encfs" )
|
|
|
|
|
2015-08-20 05:11:40 +02:00
|
|
|
# http://www.cmake.org/Wiki/CMake_RPATH_handling#Mac_OS_X_and_the_RPATH
|
|
|
|
if (APPLE)
|
|
|
|
set(CMAKE_MACOSX_RPATH ON)
|
|
|
|
set(CMAKE_SKIP_BUILD_RPATH FALSE)
|
|
|
|
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
|
2016-09-16 01:34:03 +02:00
|
|
|
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}")
|
2015-08-20 05:11:40 +02:00
|
|
|
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
2016-09-16 01:34:03 +02:00
|
|
|
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}" isSystemDir)
|
2015-08-20 05:11:40 +02:00
|
|
|
if("${isSystemDir}" STREQUAL "-1")
|
2016-09-16 01:34:03 +02:00
|
|
|
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}")
|
2015-08-20 05:11:40 +02:00
|
|
|
endif()
|
|
|
|
endif()
|
2015-06-14 07:08:13 +02:00
|
|
|
|
|
|
|
# Check for FUSE.
|
|
|
|
find_package (FUSE REQUIRED)
|
|
|
|
include_directories (${FUSE_INCLUDE_DIR})
|
|
|
|
add_definitions (-D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=26)
|
|
|
|
|
|
|
|
# Check for OpenSSL.
|
|
|
|
find_package (OpenSSL REQUIRED)
|
|
|
|
include_directories (${OPENSSL_INCLUDE_DIR})
|
|
|
|
|
2016-04-25 06:33:15 +02:00
|
|
|
if (USE_INTERNAL_TINYXML)
|
|
|
|
message("-- Using local TinyXML2 copy")
|
2016-04-25 07:50:30 +02:00
|
|
|
add_subdirectory(internal/tinyxml2-3.0.0)
|
2016-10-03 14:08:17 +02:00
|
|
|
include_directories(${CMAKE_CURRENT_LIST_DIR}/internal/tinyxml2-3.0.0)
|
2016-04-25 07:50:30 +02:00
|
|
|
link_directories(${CMAKE_BINARY_DIR}/internal/tinyxml2-3.0.0)
|
2016-04-25 06:33:15 +02:00
|
|
|
set(TINYXML_LIBRARIES tinyxml2)
|
|
|
|
else ()
|
|
|
|
find_package (TinyXML REQUIRED)
|
|
|
|
include_directories (${TINYXML_INCLUDE_DIR})
|
|
|
|
endif ()
|
2015-06-14 07:08:13 +02:00
|
|
|
|
|
|
|
find_program (POD2MAN pod2man)
|
|
|
|
|
|
|
|
# Check for include files and stdlib properties.
|
|
|
|
include (CheckIncludeFileCXX)
|
|
|
|
check_include_file_cxx (attr/xattr.h HAVE_ATTR_XATTR_H)
|
|
|
|
check_include_file_cxx (sys/xattr.h HAVE_SYS_XATTR_H)
|
|
|
|
|
|
|
|
# Check if xattr functions take extra arguments, as they do on OSX.
|
|
|
|
include (CheckCXXSourceCompiles)
|
|
|
|
check_cxx_source_compiles ("#include <sys/types.h>
|
|
|
|
#include <sys/xattr.h>
|
|
|
|
int main() { getxattr(0,0,0,0,0,0); return 1; }
|
|
|
|
" XATTR_ADD_OPT)
|
2017-04-01 19:58:05 +02:00
|
|
|
|
2016-05-13 22:33:23 +02:00
|
|
|
# Check if we have some standard functions.
|
2015-06-14 07:08:13 +02:00
|
|
|
include (CheckFuncs)
|
|
|
|
check_function_exists_glibc (lchmod HAVE_LCHMOD)
|
2016-05-13 22:33:23 +02:00
|
|
|
check_function_exists_glibc (utimensat HAVE_UTIMENSAT)
|
2015-06-14 07:08:13 +02:00
|
|
|
|
|
|
|
set (CMAKE_THREAD_PREFER_PTHREAD)
|
|
|
|
find_package (Threads REQUIRED)
|
|
|
|
|
2015-06-18 05:33:57 +02:00
|
|
|
# Logging.
|
|
|
|
add_definitions (-DELPP_THREAD_SAFE -DELPP_DISABLE_DEFAULT_CRASH_HANDLING)
|
2016-09-16 01:38:40 +02:00
|
|
|
add_definitions (-DELPP_NO_DEFAULT_LOG_FILE)
|
2015-06-18 05:33:57 +02:00
|
|
|
check_include_file_cxx (syslog.h HAVE_SYSLOG_H)
|
|
|
|
if (HAVE_SYSLOG_H)
|
|
|
|
message ("-- Enabled syslog logging support")
|
|
|
|
add_definitions(-DELPP_SYSLOG)
|
|
|
|
endif (HAVE_SYSLOG_H)
|
|
|
|
|
2015-06-14 07:08:13 +02:00
|
|
|
# Packaging config.
|
|
|
|
set (CPACK_PACKAGE_NAME "encfs")
|
|
|
|
set (CPACK_PACKAGE_VERSION_MAJOR ${ENCFS_MAJOR})
|
|
|
|
set (CPACK_PACKAGE_VERSION_MINOR ${ENCFS_MINOR})
|
|
|
|
set (CPACK_SOURCE_GENERATOR TGZ)
|
|
|
|
set (CPACK_SOURCE_IGNORE_FILES
|
|
|
|
"/build/")
|
|
|
|
include (CPack)
|
|
|
|
|
2015-06-18 07:28:22 +02:00
|
|
|
# Compile-time configuration.
|
2016-10-03 14:08:17 +02:00
|
|
|
configure_file (${CMAKE_CURRENT_LIST_DIR}/config.h.cmake
|
2015-06-14 07:08:13 +02:00
|
|
|
${CMAKE_BINARY_DIR}/config.h)
|
|
|
|
|
|
|
|
include_directories (${CMAKE_BINARY_DIR})
|
2016-10-03 14:08:17 +02:00
|
|
|
include_directories (${CMAKE_CURRENT_LIST_DIR})
|
2015-06-14 07:08:13 +02:00
|
|
|
|
2016-09-05 21:09:30 +02:00
|
|
|
# Translations
|
|
|
|
if (ENABLE_NLS)
|
2016-09-13 22:09:13 +02:00
|
|
|
find_package (Intl)
|
|
|
|
if (Intl_FOUND)
|
|
|
|
include_directories (${Intl_INCLUDE_DIRS})
|
|
|
|
endif()
|
|
|
|
|
2016-09-05 21:09:30 +02:00
|
|
|
add_subdirectory(po)
|
|
|
|
|
|
|
|
add_definitions(-DENABLE_NLS)
|
|
|
|
add_definitions(-DLOCALEDIR="${CMAKE_INSTALL_PREFIX}/share/locale")
|
|
|
|
endif (ENABLE_NLS)
|
|
|
|
|
2017-08-04 06:22:40 +02:00
|
|
|
if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.5) # Need 3.6 or above.
|
|
|
|
find_program(CLANG_TIDY_EXE NAMES "clang-tidy" DOC "Path to clang-tidy executable")
|
|
|
|
if(NOT CLANG_TIDY_EXE)
|
|
|
|
message(STATUS "clang-tidy not found.")
|
|
|
|
else()
|
|
|
|
message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}")
|
2017-08-04 08:26:32 +02:00
|
|
|
set(DO_CLANG_TIDY "${CLANG_TIDY_EXE}" "-checks=*,-modernize-loop-convert,-cppcoreguidelines-pro-*,-readability-inconsistent-declaration-parameter-name,-google-readability-casting,-cert-err58-cpp,-google-runtime-int,-readability-named-parameter,-google-build-using-namespace,-misc-unused-parameters,-google-runtime-references")
|
|
|
|
#set(DO_CLANG_TIDY "${CLANG_TIDY_EXE}" "-fix" "-checks=-*,google-readability-redundant-smartptr-get")
|
2017-08-04 06:22:40 +02:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2015-06-14 07:08:13 +02:00
|
|
|
set(SOURCE_FILES
|
2017-03-09 16:35:55 +01:00
|
|
|
internal/easylogging++.cc
|
2015-06-14 07:08:13 +02:00
|
|
|
encfs/autosprintf.cpp
|
|
|
|
encfs/base64.cpp
|
|
|
|
encfs/BlockFileIO.cpp
|
|
|
|
encfs/BlockNameIO.cpp
|
|
|
|
encfs/Cipher.cpp
|
|
|
|
encfs/CipherFileIO.cpp
|
|
|
|
encfs/CipherKey.cpp
|
|
|
|
encfs/ConfigReader.cpp
|
|
|
|
encfs/ConfigVar.cpp
|
|
|
|
encfs/Context.cpp
|
|
|
|
encfs/DirNode.cpp
|
|
|
|
encfs/encfs.cpp
|
2015-06-18 05:33:57 +02:00
|
|
|
encfs/Error.cpp
|
2015-06-14 07:08:13 +02:00
|
|
|
encfs/FileIO.cpp
|
|
|
|
encfs/FileNode.cpp
|
|
|
|
encfs/FileUtils.cpp
|
|
|
|
encfs/Interface.cpp
|
|
|
|
encfs/MACFileIO.cpp
|
|
|
|
encfs/MemoryPool.cpp
|
|
|
|
encfs/NameIO.cpp
|
|
|
|
encfs/NullCipher.cpp
|
|
|
|
encfs/NullNameIO.cpp
|
|
|
|
encfs/openssl.cpp
|
|
|
|
encfs/RawFileIO.cpp
|
|
|
|
encfs/readpassphrase.cpp
|
|
|
|
encfs/SSL_Cipher.cpp
|
|
|
|
encfs/StreamNameIO.cpp
|
2016-04-15 08:11:45 +02:00
|
|
|
encfs/XmlReader.cpp
|
2015-06-14 07:08:13 +02:00
|
|
|
)
|
2016-04-25 06:33:15 +02:00
|
|
|
add_library(encfs ${SOURCE_FILES})
|
|
|
|
set_target_properties(encfs PROPERTIES
|
|
|
|
VERSION ${ENCFS_VERSION}
|
|
|
|
SOVERSION ${ENCFS_SOVERSION})
|
2015-06-16 06:10:48 +02:00
|
|
|
target_link_libraries(encfs
|
2015-06-14 07:08:13 +02:00
|
|
|
${FUSE_LIBRARIES}
|
|
|
|
${OPENSSL_LIBRARIES}
|
2016-04-15 08:11:45 +02:00
|
|
|
${TINYXML_LIBRARIES}
|
2015-06-14 07:08:13 +02:00
|
|
|
${CMAKE_THREAD_LIBS_INIT}
|
2016-09-13 22:09:13 +02:00
|
|
|
${Intl_LIBRARIES}
|
2015-06-14 07:08:13 +02:00
|
|
|
)
|
2016-09-05 23:13:21 +02:00
|
|
|
if (INSTALL_LIBENCFS)
|
2016-09-16 01:34:03 +02:00
|
|
|
install (TARGETS encfs DESTINATION ${LIB_INSTALL_DIR})
|
2016-09-05 23:13:21 +02:00
|
|
|
endif (INSTALL_LIBENCFS)
|
2015-06-14 07:08:13 +02:00
|
|
|
|
2015-06-18 05:33:57 +02:00
|
|
|
if (IWYU)
|
|
|
|
if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.2)
|
|
|
|
find_program(iwyu_path NAMES include-what-you-use iwyu)
|
|
|
|
if (iwyu_path)
|
|
|
|
message ("-- Enabled IWYU")
|
|
|
|
set_property(TARGET encfs PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${iwyu_path})
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
2015-06-18 07:28:22 +02:00
|
|
|
# Set RPATH to library install path.
|
2016-09-16 01:34:03 +02:00
|
|
|
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}")
|
2015-06-18 07:28:22 +02:00
|
|
|
|
2015-06-16 06:10:48 +02:00
|
|
|
add_executable (encfs-bin encfs/main.cpp)
|
|
|
|
target_link_libraries (encfs-bin encfs)
|
|
|
|
set_target_properties (encfs-bin PROPERTIES OUTPUT_NAME "encfs")
|
2015-06-16 19:18:10 +02:00
|
|
|
install (TARGETS encfs-bin DESTINATION bin)
|
2015-06-14 07:08:13 +02:00
|
|
|
|
2017-08-04 06:22:40 +02:00
|
|
|
if(LINT AND CLANG_TIDY_EXE)
|
|
|
|
set_target_properties(encfs PROPERTIES CXX_CLANG_TIDY "${DO_CLANG_TIDY}")
|
|
|
|
set_target_properties(encfs-bin PROPERTIES CXX_CLANG_TIDY "${DO_CLANG_TIDY}")
|
|
|
|
endif()
|
|
|
|
|
2015-06-14 07:08:13 +02:00
|
|
|
add_executable (encfsctl encfs/encfsctl.cpp)
|
2015-06-16 06:10:48 +02:00
|
|
|
target_link_libraries (encfsctl encfs)
|
2015-06-16 06:16:00 +02:00
|
|
|
install (TARGETS encfsctl DESTINATION bin)
|
2015-06-14 07:08:13 +02:00
|
|
|
|
|
|
|
add_executable (makekey encfs/makeKey.cpp)
|
2015-06-16 06:10:48 +02:00
|
|
|
target_link_libraries (makekey encfs)
|
2015-06-14 07:08:13 +02:00
|
|
|
|
|
|
|
add_executable (checkops encfs/test.cpp)
|
2015-06-16 06:10:48 +02:00
|
|
|
target_link_libraries (checkops encfs)
|
2015-06-14 07:08:13 +02:00
|
|
|
|
2017-07-27 18:00:53 +02:00
|
|
|
install (PROGRAMS encfs/encfssh DESTINATION bin)
|
2015-06-16 06:16:00 +02:00
|
|
|
|
2015-06-14 07:08:13 +02:00
|
|
|
# Reference all headers, to make certain IDEs happy.
|
2016-10-03 14:08:17 +02:00
|
|
|
file (GLOB_RECURSE all_headers ${CMAKE_CURRENT_LIST_DIR}/*.h)
|
2015-06-14 07:08:13 +02:00
|
|
|
add_custom_target (all_placeholder SOURCES ${all_headers})
|
|
|
|
|
|
|
|
if (POD2MAN)
|
2017-08-06 11:26:09 +02:00
|
|
|
set (MAN_DESTINATION "share/man/man1")
|
|
|
|
if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
|
|
|
|
set (MAN_DESTINATION "man/man1")
|
|
|
|
endif()
|
|
|
|
|
2015-06-14 07:08:13 +02:00
|
|
|
add_custom_target (encfs-man ALL
|
|
|
|
COMMAND ${POD2MAN} -u --section=1 --release=${ENCFS_VERSION} --center=${ENCFS_NAME}
|
2016-10-03 14:08:17 +02:00
|
|
|
${CMAKE_CURRENT_LIST_DIR}/encfs/encfs.pod encfs.1)
|
2015-06-14 07:08:13 +02:00
|
|
|
|
|
|
|
add_custom_target (encfsctl-man ALL
|
|
|
|
COMMAND ${POD2MAN} -u --section=1 --release=${ENCFS_VERSION} --center=${ENCFS_NAME}
|
2016-10-03 14:08:17 +02:00
|
|
|
${CMAKE_CURRENT_LIST_DIR}/encfs/encfsctl.pod encfsctl.1)
|
2015-06-14 07:08:13 +02:00
|
|
|
|
|
|
|
install (FILES ${CMAKE_BINARY_DIR}/encfs.1 ${CMAKE_BINARY_DIR}/encfsctl.1
|
2017-08-06 11:26:09 +02:00
|
|
|
DESTINATION ${MAN_DESTINATION})
|
2015-06-14 07:08:13 +02:00
|
|
|
endif (POD2MAN)
|
|
|
|
|
2017-08-04 06:22:40 +02:00
|
|
|
add_custom_target(tests COMMAND ${CMAKE_CURRENT_LIST_DIR}/test.sh)
|
2017-05-28 16:20:21 +02:00
|
|
|
|