From 3bf25fb916fef15765c547d08d85994043668485 Mon Sep 17 00:00:00 2001 From: Ben RUBSON <6764151+benrubson@users.noreply.github.com> Date: Tue, 3 Mar 2020 22:48:28 +0100 Subject: [PATCH] cmake FUSE & OpenSSL finding (#591) --- CMakeLists.txt | 10 +++++++++- INSTALL.md | 4 ++++ build.sh | 4 ---- cmake/FindFUSE.cmake | 36 +++++++++++++++++++++--------------- 4 files changed, 34 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 227bcfd..2f9d0f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,11 @@ option (BUILD_UNIT_TESTS "build EncFS unit tests" ON) option (USE_INTERNAL_TINYXML "use built-in TinyXML2" ON) option (USE_INTERNAL_EASYLOGGING "use built-in Easylogging++" ON) option (BUILD_SHARED_LIBS "build internal libraries as shared" OFF) -option (ENABLE_NLS "compile with Native Language Support (using gettext)" ON) +if (APPLE) + option (ENABLE_NLS "compile with Native Language Support (using gettext)" OFF) +else() + option (ENABLE_NLS "compile with Native Language Support (using gettext)" ON) +endif() option (INSTALL_LIBENCFS "install libencfs" OFF) option (LINT "enable lint output" OFF) @@ -104,6 +108,10 @@ if (CYGWIN) endif() # Check for OpenSSL. +if (APPLE AND NOT DEFINED OPENSSL_ROOT_DIR) + # Search both Brew and Macports + set(OPENSSL_ROOT_DIR "/usr/local/opt/openssl;/opt/local") +endif() find_package (OpenSSL REQUIRED) include_directories (${OPENSSL_INCLUDE_DIR}) diff --git a/INSTALL.md b/INSTALL.md index 7418f76..c633270 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -19,6 +19,10 @@ Or following are the detailed steps to build EncFS: cmake .. make +If CMake can't find FUSE or OpenSSL, you can use the following options: + + cmake .. -DFUSE_ROOT_DIR=/pathto/fuse -DOPENSSL_ROOT_DIR=/pathto/openssl + Optional, but strongly recommended, is running the unit and integration tests to verify that the generated binaries work as expected. Unit tests will run almost instantly: diff --git a/build.sh b/build.sh index b10107c..dedc6c0 100755 --- a/build.sh +++ b/build.sh @@ -11,10 +11,6 @@ if [[ "$CHECK" == "true" ]]; then CFG="-DLINT=ON $CFG" fi -if uname -s | grep -q Darwin; then - CFG="-DENABLE_NLS=OFF -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl $CFG" -fi - if [[ ! -d build ]] then mkdir build diff --git a/cmake/FindFUSE.cmake b/cmake/FindFUSE.cmake index bb8cb50..b86bbc0 100644 --- a/cmake/FindFUSE.cmake +++ b/cmake/FindFUSE.cmake @@ -1,33 +1,39 @@ # Find the FUSE includes and library # -# FUSE_INCLUDE_DIR - where to find fuse.h, etc. -# FUSE_LIBRARIES - List of libraries when using FUSE. -# FUSE_FOUND - True if FUSE lib is found. +# FUSE_INCLUDE_DIR - where to find fuse.h, etc. +# FUSE_LIBRARIES - List of libraries when using FUSE. +# FUSE_ROOT_DIR - Additional search path. +# FUSE_FOUND - True if FUSE lib is found. # check if already in cache, be silent -if (FUSE_INCLUDE_DIR) - SET (FUSE_FIND_QUIETLY TRUE) -endif (FUSE_INCLUDE_DIR) +if (FUSE_INCLUDE_DIR AND FUSE_LIBRARIES) + SET (FUSE_FIND_QUIETLY TRUE) +endif () if (APPLE) set (FUSE_NAMES libosxfuse.dylib fuse) set (FUSE_SUFFIXES osxfuse fuse) -else (APPLE) +else () set (FUSE_NAMES fuse refuse) set (FUSE_SUFFIXES fuse refuse) -endif (APPLE) +endif () -# find includes -find_path (FUSE_INCLUDE_DIR fuse.h - PATHS /opt /opt/local /usr/pkg - PATH_SUFFIXES ${FUSE_SUFFIXES}) +# find include +find_path ( + FUSE_INCLUDE_DIR fuse.h + PATHS /opt /opt/local /usr /usr/local /usr/pkg ${FUSE_ROOT_DIR} ENV FUSE_ROOT_DIR + PATH_SUFFIXES include ${FUSE_SUFFIXES}) # find lib -find_library (FUSE_LIBRARIES NAMES ${FUSE_NAMES}) +find_library ( + FUSE_LIBRARIES + NAMES ${FUSE_NAMES} + PATHS /opt /opt/local /usr /usr/local /usr/pkg ${FUSE_ROOT_DIR} ENV FUSE_ROOT_DIR + PATH_SUFFIXES lib) include ("FindPackageHandleStandardArgs") -find_package_handle_standard_args ("FUSE" DEFAULT_MSG +find_package_handle_standard_args ( + "FUSE" DEFAULT_MSG FUSE_INCLUDE_DIR FUSE_LIBRARIES) mark_as_advanced (FUSE_INCLUDE_DIR FUSE_LIBRARIES) -