diff options
author | Marvin W <git@larma.de> | 2017-08-31 23:53:40 +0200 |
---|---|---|
committer | Marvin W <git@larma.de> | 2017-09-01 01:00:59 +0200 |
commit | dc26841b9ea1e65dedbc916257f70e7f768f724b (patch) | |
tree | f526793a227576a09d48526bbbafa7eab8177b4f /CMakeLists.txt | |
parent | 2cd6e94cc567284a10c4545208f53ea8421ee8d1 (diff) | |
download | dino-dc26841b9ea1e65dedbc916257f70e7f768f724b.tar.gz dino-dc26841b9ea1e65dedbc916257f70e7f768f724b.zip |
cmake: set _FILE_OFFSET_BITS=64 if required for platform
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 22 |
1 files changed, 20 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}) |