cmake: set _FILE_OFFSET_BITS=64 if required for platform
This commit is contained in:
parent
2cd6e94cc5
commit
dc26841b9e
|
@ -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})
|
set(PLUGIN_INSTALL LIBRARY DESTINATION ${PLUGIN_INSTALL_DIR} RUNTIME DESTINATION ${PLUGIN_INSTALL_DIR})
|
||||||
|
|
||||||
include(CheckCCompilerFlag)
|
include(CheckCCompilerFlag)
|
||||||
|
include(CheckCSourceCompiles)
|
||||||
|
|
||||||
macro(AddCFlagIfSupported flag)
|
macro(AddCFlagIfSupported flag)
|
||||||
string(REGEX REPLACE "[^a-z^A-Z^_^0-9]+" "_" flag_name ${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}})
|
if(${COMPILER_SUPPORTS${flag_name}})
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}")
|
||||||
endif()
|
endif()
|
||||||
|
@ -55,7 +56,7 @@ endmacro()
|
||||||
|
|
||||||
macro(AddValaCFlagIfSupported flag)
|
macro(AddValaCFlagIfSupported flag)
|
||||||
string(REGEX REPLACE "[^a-z^A-Z^_^0-9]+" "_" flag_name ${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}})
|
if(${COMPILER_SUPPORTS${flag_name}})
|
||||||
set(VALA_CFLAGS "${VALA_CFLAGS} ${flag}")
|
set(VALA_CFLAGS "${VALA_CFLAGS} ${flag}")
|
||||||
endif()
|
endif()
|
||||||
|
@ -78,6 +79,21 @@ AddValaCFlagIfSupported(-Wno-unused-variable)
|
||||||
AddValaCFlagIfSupported(-Wno-unused-function)
|
AddValaCFlagIfSupported(-Wno-unused-function)
|
||||||
AddValaCFlagIfSupported(-Wno-unused-label)
|
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})
|
if($ENV{USE_CCACHE})
|
||||||
# Configure CCache if available
|
# Configure CCache if available
|
||||||
find_program(CCACHE_FOUND ccache)
|
find_program(CCACHE_FOUND ccache)
|
||||||
|
@ -85,6 +101,8 @@ if($ENV{USE_CCACHE})
|
||||||
message(STATUS "Using ccache")
|
message(STATUS "Using ccache")
|
||||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
|
||||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK 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(CCACHE_FOUND)
|
||||||
endif($ENV{USE_CCACHE})
|
endif($ENV{USE_CCACHE})
|
||||||
|
|
||||||
|
|
11
cmake/LargeFileOffsets.c
Normal file
11
cmake/LargeFileOffsets.c
Normal file
|
@ -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;
|
||||||
|
}
|
Loading…
Reference in a new issue