diff --git a/CMakeLists.txt b/CMakeLists.txt index 36d6cbd..57a0c74 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,8 +30,13 @@ check_library_exists(crc32c crc32c_value "" HAVE_CRC32C) check_library_exists(snappy snappy_compress "" HAVE_SNAPPY) check_library_exists(tcmalloc malloc "" HAVE_TCMALLOC) -include(CheckSymbolExists) -check_symbol_exists(fdatasync "unistd.h" HAVE_FDATASYNC) +include(CheckCXXSymbolExists) +# Using check_cxx_symbol_exists() instead of check_c_symbol_exists() because +# we're including the header from C++, and feature detection should use the same +# compiler language that the project will use later. Principles aside, some +# versions of do not expose fdatasync() in in standard C mode +# (-std=c11), but do expose the function in standard C++ mode (-std=c++11). +check_cxx_symbol_exists(fdatasync "unistd.h" HAVE_FDATASYNC) include(CheckCXXSourceCompiles) diff --git a/port/port_config.h.in b/port/port_config.h.in index 1934055..645c78c 100644 --- a/port/port_config.h.in +++ b/port/port_config.h.in @@ -6,9 +6,9 @@ #define STORAGE_LEVELDB_PORT_PORT_CONFIG_H_ // Define to 1 if you have a definition for fdatasync() in . -#if !defined(HAVE_FUNC_FDATASYNC) -#cmakedefine01 HAVE_FUNC_FDATASYNC -#endif // !defined(HAVE_FUNC_FDATASYNC) +#if !defined(HAVE_FDATASYNC) +#cmakedefine01 HAVE_FDATASYNC +#endif // !defined(HAVE_FDATASYNC) // Define to 1 if you have Google CRC32C. #if !defined(HAVE_CRC32C)