diff options
-rw-r--r-- | CMakeLists.txt | 22 | ||||
-rw-r--r-- | cmake/LargeFileOffsets.c | 11 |
2 files changed, 31 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 15a66f99..929834ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,10 +44,11 @@ set(TARGET_INSTALL LIBRARY DESTINATION ${LIB_INSTALL_DIR} RUNTIME DESTINATION ${ set(PLUGIN_INSTALL LIBRARY DESTINATION ${PLUGIN_INSTALL_DIR} RUNTIME DESTINATION ${PLUGIN_INSTALL_DIR}) include(CheckCCompilerFlag) +include(CheckCSourceCompiles) macro(AddCFlagIfSupported flag) string(REGEX REPLACE "[^a-z^A-Z^_^0-9]+" "_" flag_name ${flag}) - CHECK_C_COMPILER_FLAG(${flag} COMPILER_SUPPORTS${flag_name}) + check_c_compiler_flag(${flag} COMPILER_SUPPORTS${flag_name}) if(${COMPILER_SUPPORTS${flag_name}}) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}") endif() @@ -55,7 +56,7 @@ endmacro() macro(AddValaCFlagIfSupported flag) string(REGEX REPLACE "[^a-z^A-Z^_^0-9]+" "_" flag_name ${flag}) - CHECK_C_COMPILER_FLAG(${flag} COMPILER_SUPPORTS${flag_name}) + check_c_compiler_flag(${flag} COMPILER_SUPPORTS${flag_name}) if(${COMPILER_SUPPORTS${flag_name}}) set(VALA_CFLAGS "${VALA_CFLAGS} ${flag}") endif() @@ -78,6 +79,21 @@ AddValaCFlagIfSupported(-Wno-unused-variable) AddValaCFlagIfSupported(-Wno-unused-function) AddValaCFlagIfSupported(-Wno-unused-label) +try_compile(__WITHOUT_FILE_OFFSET_BITS_64 ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/cmake/LargeFileOffsets.c COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}) +if(NOT __WITHOUT_FILE_OFFSET_BITS_64) + try_compile(__WITH_FILE_OFFSET_BITS_64 ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/cmake/LargeFileOffsets.c COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -D_FILE_OFFSET_BITS=64) + + if(__WITH_FILE_OFFSET_BITS_64) + AddCFlagIfSupported(-D_FILE_OFFSET_BITS=64) + AddValaCFlagIfSupported(-D_FILE_OFFSET_BITS=64) + message(STATUS "Enabled large file support using _FILE_OFFSET_BITS=64") + else(__WITH_FILE_OFFSET_BITS_64) + message(STATUS "Large file support not available") + endif(__WITH_FILE_OFFSET_BITS_64) + unset(__WITH_FILE_OFFSET_BITS_64) +endif(NOT __WITHOUT_FILE_OFFSET_BITS_64) +unset(__WITHOUT_FILE_OFFSET_BITS_64) + if($ENV{USE_CCACHE}) # Configure CCache if available find_program(CCACHE_FOUND ccache) @@ -85,6 +101,8 @@ if($ENV{USE_CCACHE}) message(STATUS "Using ccache") set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) + else(CCACHE_FOUND) + message(STATUS "USE_CCACHE was set but ccache was not found") endif(CCACHE_FOUND) endif($ENV{USE_CCACHE}) diff --git a/cmake/LargeFileOffsets.c b/cmake/LargeFileOffsets.c new file mode 100644 index 00000000..cbc20f0d --- /dev/null +++ b/cmake/LargeFileOffsets.c @@ -0,0 +1,11 @@ +#include <sys/types.h> +#define _K ((off_t)1024) +#define _M ((off_t)1024 * _K) +#define _G ((off_t)1024 * _M) +#define _T ((off_t)1024 * _G) + +int test[(((64 * _G -1) % 671088649) == 268434537) && (((_T - (64 * _G -1) + 255) % 1792151290) == 305159546)? 1: -1]; + +int main() { + return 0; +}
\ No newline at end of file |