Changeset: e8038a5f9368 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e8038a5f9368 Removed Files: cmake/TestLargeFiles.c.cmake.in Modified Files: CMakeLists.txt cmake/TestFileOffsetBits.c cmake/TestLargeFiles.cmake gdk/gdk_logger.c monetdb5/extras/rapi/CMakeLists.txt monetdb_config.h.in sql/backends/monet5/UDF/pyapi3/CMakeLists.txt Branch: cmake-fun Log Message:
Further cleanup: - Set _GNU_SOURCE macro on GCC. - Removed tests for _LARGEFILE_SOURCE and _DARWIN_USE_64_BIT_INODE macros. _LARGE_FILES is required for AIX which we no longer support. - Make sure _FILE_OFFSET_BITS is set before any header file. - We really never used libintl.h on Windows because we don't translate any help message on MonetDB anyway. - Set R include directory and libraries and numpy include directory into the cmake cache. diffs (truncated from 406 to 300 lines): diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -164,10 +164,6 @@ function(MT_addCompilerFlag REGEX_EXPRES endif() endfunction() -if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND NOT ${CMAKE_C_COMPILER_ID} STREQUAL "Intel") - add_definitions(-D_GNU_SOURCE -D_XOPEN_SOURCE) # required for GNU extensions - set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_GNU_SOURCE -D_XOPEN_SOURCE") # required for tests -endif() if(${CMAKE_C_COMPILER_ID} STREQUAL "Intel") if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") MT_addCompilerFlag("-no-gcc-include-dir" "-no-gcc-include-dir" "${CMAKE_C_FLAGS}" "all" CMAKE_C_FLAGS) @@ -180,17 +176,17 @@ if(${CMAKE_C_COMPILER_ID} STREQUAL "Inte endif() endif() set(NAN_CANNOT_BE_USED_AS_INITIALIZER ON CACHE INTERNAL "NaN cannot be used as an initializer") # This hack is only required by the Intel compiler +elseif(${CMAKE_C_COMPILER_ID} STREQUAL "GNU") # Make sure this if branch comes after the Intel one + add_definitions(-D_GNU_SOURCE -D_XOPEN_SOURCE) # The former is required for GNU extensions and the latter for strptime function + set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_GNU_SOURCE") # required for tests elseif(MSVC) set(restrict "__restrict") # C99 feature not present in MSVC set(inline "__inline") # C99 feature only available on C++ compiler in MSVC https://docs.microsoft.com/en-us/cpp/cpp/inline-functions-cpp?view=vs-2015 add_definitions(/D_CRT_SECURE_NO_WARNINGS) # TODO it would be nice to remove this, but it requires lots of rewriting endif() -# Tests for large files support -opj_test_large_files(_LARGE_FILES) -opj_test_large_files(_LARGEFILE_SOURCE) -opj_test_large_files(_FILE_OFFSET_BITS) -opj_test_large_files(_DARWIN_USE_64_BIT_INODE) +# Tests for large files support (define _FILE_OFFSET_BITS conditionaly) +opj_test_large_files() #Test if struct tm has tm_zone field check_struct_has_member("struct tm" tm_zone "time.h" HAVE_STRUCT_TM_TM_ZONE LANGUAGE C) #Test CPU endianness @@ -335,6 +331,7 @@ endif() set(THREADS_PREFER_PTHREAD_FLAG ON) # We do prefer pthreads find_package(Threads) set(THREAD_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}") +check_include_file("pthread.h" HAVE_PTHREAD_H) # Distinguish between posix thread and win32 thread libraries # Password hash algorithm set(PASSWORD_BACKEND "SHA512" CACHE STRING "Password hash algorithm, one of MD5, SHA1, RIPEMD160, SHA224, SHA256, SHA384, SHA512, defaults to SHA512") @@ -471,15 +468,11 @@ if(WIN32) # Both these libraries and res endif() include(FindExtraLibraries) -# Header files -check_include_file("libintl.h" HAVE_LIBINTL_H) # We use it on Windows, and there are ports of this library there -check_include_file("pthread.h" HAVE_PTHREAD_H) # Distinguish between posix thread and win32 thread libraries - # C types existence cmake_push_check_state() set(CMAKE_EXTRA_INCLUDE_FILES "${CMAKE_EXTRA_INCLUDE_FILES};sys/types.h") -check_type_size(size_t SIZEOF_SIZE_T LANGUAGE C) #On C99, but we have to calculate the size -check_type_size(ssize_t SIZEOF_SSIZE_T LANGUAGE C) +check_type_size(size_t SIZEOF_SIZE_T LANGUAGE C) # On C99, but we have to calculate the size +check_type_size(ssize_t SIZEOF_SSIZE_T LANGUAGE C) # POSIX type not available on Windows and maybe other platforms if(NOT HAVE_SIZEOF_SSIZE_T) # Set a default value if(CMAKE_SIZEOF_VOID_P EQUAL 8) set(ssize_t "int64_t") diff --git a/cmake/TestFileOffsetBits.c b/cmake/TestFileOffsetBits.c --- a/cmake/TestFileOffsetBits.c +++ b/cmake/TestFileOffsetBits.c @@ -7,5 +7,6 @@ int off_t_is_large[ (LARGE_OFF_T % 21474 int main(int argc, char **argv) { + (void) argc; (void) argv; return 0; } diff --git a/cmake/TestLargeFiles.c.cmake.in b/cmake/TestLargeFiles.c.cmake.in deleted file mode 100644 --- a/cmake/TestLargeFiles.c.cmake.in +++ /dev/null @@ -1,24 +0,0 @@ -// From https://github.com/Framstag/libosmscout/pull/251/files#diff-40f8e3cdfc36152528d5235258332447 -#cmakedefine _LARGEFILE_SOURCE -#cmakedefine _LARGE_FILES -#cmakedefine _FILE_OFFSET_BITS @_FILE_OFFSET_BITS@ -#cmakedefine _DARWIN_USE_64_BIT_INODE - -#include <sys/types.h> -#include <stdio.h> -#include <stdlib.h> - -int main(int argc, char **argv) -{ - /* Cause a compile-time error if off_t is smaller than 64 bits, - * and make sure we have ftello / fseeko. - */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) - int off_t_is_large[ (LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1 ]; - FILE *fp = fopen(argv[0],"r"); - off_t offset = ftello( fp ); - - fseeko( fp, offset, SEEK_CUR ); - fclose(fp); - return 0; -} diff --git a/cmake/TestLargeFiles.cmake b/cmake/TestLargeFiles.cmake --- a/cmake/TestLargeFiles.cmake +++ b/cmake/TestLargeFiles.cmake @@ -1,133 +1,28 @@ -# From https://github.com/Framstag/libosmscout/pull/251/files#diff-40f8e3cdfc36152528d5235258332447 -# - Define macro to check large file support -# -# OPJ_TEST_LARGE_FILES(VARIABLE) +# Adapted from https://github.com/Framstag/libosmscout/pull/251/files#diff-40f8e3cdfc36152528d5235258332447 +# Define macro to check large file support # -# VARIABLE will be set to true if off_t is 64 bits, and fseeko/ftello present. -# This macro will also defines the necessary variable enable large file support, for instance -# _LARGE_FILES -# _LARGEFILE_SOURCE -# _FILE_OFFSET_BITS 64 -# _DARWIN_USE_64_BIT_INODE -# OPJ_HAVE_FSEEKO -# -# However, it is YOUR job to make sure these defines are set in a #cmakedefine so they -# end up in a config.h file that is included in your source if necessary! +# This cmake macro defines the C macro _FILE_OFFSET_BITS to 64, if it is the case. # -# Adapted from Gromacs project (http://www.gromacs.org/) -# by Julien Malik adn Pedro Ferreira - -macro(OPJ_TEST_LARGE_FILES VARIABLE) - if(NOT DEFINED ${VARIABLE}) +# Adapted from Gromacs project (http://www.gromacs.org/) by Julien Malik and Pedro Ferreira - # On most platforms it is probably overkill to first test the flags for 64-bit off_t, - # and then separately fseeko. However, in the future we might have 128-bit filesystems - # (ZFS), so it might be dangerous to indiscriminately set e.g. _FILE_OFFSET_BITS=64. - +macro(OPJ_TEST_LARGE_FILES) + if(NOT FILE64_OK) message(STATUS "Checking for 64-bit off_t") - # First check without any special flags - try_compile(FILE64_OK "${PROJECT_BINARY_DIR}" - "${PROJECT_SOURCE_DIR}/cmake/TestFileOffsetBits.c") + try_compile(FILE64_OK "${PROJECT_BINARY_DIR}" "${CMAKE_MODULE_PATH}/TestFileOffsetBits.c") if(FILE64_OK) message(STATUS "Checking for 64-bit off_t - present") - endif() - - if(NOT FILE64_OK) - # Test with _FILE_OFFSET_BITS=64 - try_compile(FILE64_OK "${PROJECT_BINARY_DIR}" - "${PROJECT_SOURCE_DIR}/cmake/TestFileOffsetBits.c" - COMPILE_DEFINITIONS "-D_FILE_OFFSET_BITS=64" ) + else() + # Test with _FILE_OFFSET_BITS=64. In the future we might have 128-bit filesystems (ZFS), so it might be + # dangerous to indiscriminately set _FILE_OFFSET_BITS=64. + try_compile(FILE64_OK "${PROJECT_BINARY_DIR}" "${CMAKE_MODULE_PATH}/TestFileOffsetBits.c" + COMPILE_DEFINITIONS "-D_FILE_OFFSET_BITS=64") if(FILE64_OK) + set(_FILE_OFFSET_BITS 64 CACHE INTERNAL "Result of test for needed _FILE_OFFSET_BITS=64") message(STATUS "Checking for 64-bit off_t - present with _FILE_OFFSET_BITS=64") - set(_FILE_OFFSET_BITS 64) - endif() - endif() - - if(NOT FILE64_OK) - # Test with _LARGE_FILES - try_compile(FILE64_OK "${PROJECT_BINARY_DIR}" - "${PROJECT_SOURCE_DIR}/cmake/TestFileOffsetBits.c" - COMPILE_DEFINITIONS "-D_LARGE_FILES" ) - if(FILE64_OK) - message(STATUS "Checking for 64-bit off_t - present with _LARGE_FILES") - set(_LARGE_FILES 1) - endif() - endif() - - if(NOT FILE64_OK) - # Test with _LARGEFILE_SOURCE - try_compile(FILE64_OK "${PROJECT_BINARY_DIR}" - "${PROJECT_SOURCE_DIR}/cmake/TestFileOffsetBits.c" - COMPILE_DEFINITIONS "-D_LARGEFILE_SOURCE" ) - if(FILE64_OK) - message(STATUS "Checking for 64-bit off_t - present with _LARGEFILE_SOURCE") - set(_LARGEFILE_SOURCE 1) + else() + message(STATUS "Checking for 64-bit off_t - not present") endif() endif() - - if(NOT FILE64_OK AND APPLE) - # Test with _DARWIN_USE_64_BIT_INODE - try_compile(FILE64_OK "${PROJECT_BINARY_DIR}" - "${PROJECT_SOURCE_DIR}/cmake/TestFileOffsetBits.c" - COMPILE_DEFINITIONS "-D_DARWIN_USE_64_BIT_INODE" ) - if(FILE64_OK) - message(STATUS "Checking for 64-bit off_t - present with _DARWIN_USE_64_BIT_INODE") - set(_DARWIN_USE_64_BIT_INODE 1) - endif() - endif() - - if(NOT FILE64_OK) - message(STATUS "Checking for 64-bit off_t - not present") - endif() - - set(_FILE_OFFSET_BITS ${_FILE_OFFSET_BITS} CACHE INTERNAL "Result of test for needed _FILE_OFFSET_BITS=64") - set(_LARGE_FILES ${_LARGE_FILES} CACHE INTERNAL "Result of test for needed _LARGE_FILES") - set(_LARGEFILE_SOURCE ${_LARGEFILE_SOURCE} CACHE INTERNAL "Result of test for needed _LARGEFILE_SOURCE") - set(_DARWIN_USE_64_BIT_INODE ${_DARWIN_USE_64_BIT_INODE} CACHE INTERNAL "Result of test for needed _DARWIN_USE_64_BIT_INODE") - - # Set the flags we might have determined to be required above - configure_file("${PROJECT_SOURCE_DIR}/cmake/TestLargeFiles.c.cmake.in" - "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c") - - message(STATUS "Checking for fseeko/ftello") - - # Test if ftello/fseeko are available - try_compile(FSEEKO_COMPILE_OK - "${PROJECT_BINARY_DIR}" - "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c") - - if(FSEEKO_COMPILE_OK) - message(STATUS "Checking for fseeko/ftello - present") - endif() - - if(NOT FSEEKO_COMPILE_OK) - # glibc 2.2 needs _LARGEFILE_SOURCE for fseeko (but not for 64-bit off_t...) - try_compile(FSEEKO_COMPILE_OK - "${PROJECT_BINARY_DIR}" - "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c" - COMPILE_DEFINITIONS "-D_LARGEFILE_SOURCE" ) - - if(FSEEKO_COMPILE_OK) - message(STATUS "Checking for fseeko/ftello - present with _LARGEFILE_SOURCE") - set(_LARGEFILE_SOURCE ${_LARGEFILE_SOURCE} CACHE INTERNAL "Result of test for needed _LARGEFILE_SOURCE") - endif() - endif() - - if(FSEEKO_COMPILE_OK) - set(HAVE_FSEEKO ON CACHE INTERNAL "Result of test for fseeko/ftello") - else() - message(STATUS "Checking for fseeko/ftello - not found") - set(HAVE_FSEEKO OFF CACHE INTERNAL "Result of test for fseeko/ftello") - endif() - - if(FILE64_OK AND FSEEKO_COMPILE_OK) - message(STATUS "Large File support - found") - set(${VARIABLE} ON CACHE INTERNAL "Result of test for large file support") - else() - message(STATUS "Large File support - not found") - set(${VARIABLE} OFF CACHE INTERNAL "Result of test for large file support") - endif() - endif() endmacro() diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c --- a/gdk/gdk_logger.c +++ b/gdk/gdk_logger.c @@ -90,13 +90,11 @@ #ifdef NATIVE_WIN32 #define getfilepos _ftelli64 -#else -#ifdef HAVE_FSEEKO +#elif (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64) || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) #define getfilepos ftello #else #define getfilepos ftell #endif -#endif #define NAME(name,tpe,id) (name?name:"tpe id") diff --git a/monetdb5/extras/rapi/CMakeLists.txt b/monetdb5/extras/rapi/CMakeLists.txt --- a/monetdb5/extras/rapi/CMakeLists.txt +++ b/monetdb5/extras/rapi/CMakeLists.txt @@ -6,18 +6,17 @@ # Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V. #]] -if(NOT ${ENABLE_RINTEGRATION} STREQUAL "NO") +if(NOT ${ENABLE_RINTEGRATION} STREQUAL "NO" AND NOT HAVE_LIBR) message(STATUS "Checking for R interpreter instalation") if(WIN32) - find_path(R_INCLUDE R.h) - find_library(R_LIBRARY R) - if(R_INCLUDE AND R_LIBRARY) - set(R_INCLUDE_DIR "${R_INCLUDE}") - set(R_LIBRARIES "${R_LIBRARY}") - elseif(${ENABLE_RINTEGRATION} STREQUAL "YES") - message(FATAL_ERROR "R include files and libraries are required for R integration support") - else() - message(STATUS "R include files and libraries are required for R integration support") + find_path(R_INCLUDE_DIR R.h) + find_library(R_LIBRARIES R) + if(NOT R_INCLUDE OR NOT R_LIBRARY) + if(${ENABLE_RINTEGRATION} STREQUAL "YES") + message(FATAL_ERROR "R include files and libraries are required for R integration support") + else() + message(STATUS "R include files and libraries are required for R integration support") + endif() _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list