Verified Commit 832c236d authored by Marc Vef's avatar Marc Vef
Browse files

c++17: CMake fix for statx() tests

parent 4e41571e
Loading
Loading
Loading
Loading
+19 −16
Original line number Diff line number Diff line
@@ -196,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)
@@ -222,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}")