Commit 880a180d authored by Alberto Miranda's avatar Alberto Miranda ♨️
Browse files

Merge branch '134-c-17-support' into 'master'

Resolve "C++17 support"

This MR moves GekkoFS to C++17 with the following replacements:

- CMake modifications
- Replacing `boost::filesystem` and `boost::optional` with `std::filesystem` and `std::optional`, respectively
- Using nested namespaces
- Using `if constexpr`

Closes #134

See merge request !74
parents dc80fa4d a189335d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ set(LZ4_LIBRARIES ${LZ4_LIBRARY} )
set(LZ4_INCLUDE_DIRS ${LZ4_INCLUDE_DIR} )

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(lz4 DEFAULT_MSG LZ4_LIBRARY LZ4_INCLUDE_DIR)
find_package_handle_standard_args(LZ4 DEFAULT_MSG LZ4_LIBRARY LZ4_INCLUDE_DIR)

mark_as_advanced(
    LZ4_LIBRARY
+1 −1
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@ set(Snappy_INCLUDE_DIRS ${Snappy_INCLUDE_DIR})


include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(snappy DEFAULT_MSG Snappy_LIBRARY Snappy_INCLUDE_DIR)
find_package_handle_standard_args(Snappy DEFAULT_MSG Snappy_LIBRARY Snappy_INCLUDE_DIR)

mark_as_advanced(
        Snappy_LIBRARY
+16 −16
Original line number Diff line number Diff line
#
# - Try to find Facebook zstd library
# This will define
# ZSTD_FOUND
# ZSTD_INCLUDE_DIR
# ZSTD_LIBRARIES
# ZStd_FOUND
# ZStd_INCLUDE_DIR
# ZStd_LIBRARIES
#

find_path(ZSTD_INCLUDE_DIR
find_path(ZStd_INCLUDE_DIR
    NAMES zstd.h
    )

find_library(ZSTD_LIBRARY
find_library(ZStd_LIBRARY
    NAMES zstd
    )

set(ZSTD_LIBRARIES ${ZSTD_LIBRARY})
set(ZSTD_INCLUDE_DIRS ${ZSTD_INCLUDE_DIR})
set(ZStd_LIBRARIES ${ZStd_LIBRARY})
set(ZStd_INCLUDE_DIRS ${ZStd_INCLUDE_DIR})

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(ZSTD
    DEFAULT_MSG  ZSTD_LIBRARY ZSTD_INCLUDE_DIR
find_package_handle_standard_args(ZStd
    DEFAULT_MSG ZStd_LIBRARY ZStd_INCLUDE_DIR
    )

mark_as_advanced(
    ZSTD_LIBRARY
    ZSTD_INCLUDE_DIR
    ZStd_LIBRARY
    ZStd_INCLUDE_DIR
)
 No newline at end of file
+61 −59
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@ if(NOT CMAKE_COMPILER_IS_GNUCXX)
    message(FATAL_ERROR "The choosen C++ compiler is not g++ and is not supported")
endif ()

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
@@ -90,10 +90,9 @@ find_package(Abt REQUIRED)
find_package(Margo REQUIRED)
find_package(Syscall_intercept REQUIRED)

# boost dependencies, system is required for filesystem
# boost dependencies
find_package(Boost 1.53 REQUIRED
    COMPONENTS
    filesystem
    program_options
    )

@@ -152,7 +151,7 @@ target_link_libraries(RocksDB
    ${Snappy_LIBRARIES}
    ${ZLIB_LIBRARIES}
    ${BZIP2_LIBRARIES}
    ${ZSTD_LIBRARIES}
    ${ZStd_LIBRARIES}
    ${LZ4_LIBRARIES}
    )

@@ -197,18 +196,6 @@ include_directories(
)

include(GNUInstallDirs)
include(CheckSymbolExists)

check_cxx_source_compiles("
    #include <fcntl.h>
    #include <sys/stat.h>

    int main() {
        struct statx buf;
        statx(AT_FDCWD, \"/foo\", AT_EMPTY_PATH, STATX_BASIC_STATS, &buf);
        return 0;
    }
" GLIBC_HAS_STATX)

# Global components
add_subdirectory(src/global)
@@ -223,6 +210,21 @@ include(CMakeDependentOption)
cmake_dependent_option(GKFS_INSTALL_TESTS "Install GekkoFS self tests" OFF "GKFS_BUILD_TESTS" OFF)

if (GKFS_BUILD_TESTS)
    # check symbols exists doesn't work for statx. This is a workaround
    check_cxx_source_compiles("
        #include <fcntl.h>
        #include <sys/stat.h>

        int main() {
            struct statx buf;
            statx(AT_FDCWD, \"/foo\", AT_EMPTY_PATH, STATX_BASIC_STATS, &buf);
            return 0;
        }
        " GLIBC_HAS_STATX)
    # STATX_TYPE must be set for c++17 for statx() to be found for tests
    if (GLIBC_HAS_STATX)
        add_definitions(-DSTATX_TYPE=1)
    endif ()
    message(STATUS "[gekkofs] Preparing tests...")
    set(GKFS_TESTS_INTERFACE "lo" CACHE STRING "Network interface to use when running tests (default: lo)")
    message(STATUS "[gekkofs] Network interface for tests: ${GKFS_TESTS_INTERFACE}")
+2 −4
Original line number Diff line number Diff line
@@ -19,8 +19,7 @@
#define ADD_PREFIX(str) CLIENT_ENV_PREFIX str

/* Environment variables for the GekkoFS client */
namespace gkfs {
namespace env {
namespace gkfs::env {

static constexpr auto LOG = ADD_PREFIX("LOG");

@@ -37,8 +36,7 @@ static constexpr auto HOSTS_FILE = ADD_PREFIX("HOSTS_FILE");
static constexpr auto FORWARDING_MAP_FILE = ADD_PREFIX("FORWARDING_MAP_FILE");
#endif

} // namespace env
} // namespace gkfs
} // namespace gkfs::env

#undef ADD_PREFIX

Loading