diff --git a/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake b/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake index 0265349fbfd..c4be65cecae 100644 --- a/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake +++ b/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake @@ -1,6 +1,15 @@ include(CheckCXXCompilerFlag) include(CheckCCompilerFlag) -include(CheckLinkerFlag) +# VERSION_GREATER_EQUAL requires CMake 3.7 or later. +# https://cmake.org/cmake/help/latest/command/if.html#version-greater-equal +if (CMAKE_VERSION VERSION_LESS 3.18) + set(ZSTD_HAVE_CHECK_LINKER_FLAG false) +else () + set(ZSTD_HAVE_CHECK_LINKER_FLAG true) +endif () +if (ZSTD_HAVE_CHECK_LINKER_FLAG) + include(CheckLinkerFlag) +endif() function(EnableCompilerFlag _flag _C _CXX _LD) string(REGEX REPLACE "\\+" "PLUS" varname "${_flag}") @@ -20,7 +29,11 @@ function(EnableCompilerFlag _flag _C _CXX _LD) endif () endif () if (_LD) - CHECK_LINKER_FLAG(C ${_flag} LD_FLAG_${varname}) + if (ZSTD_HAVE_CHECK_LINKER_FLAG) + CHECK_LINKER_FLAG(C ${_flag} LD_FLAG_${varname}) + else () + set(LD_FLAG_${varname} false) + endif () if (LD_FLAG_${varname}) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${_flag}" PARENT_SCOPE) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${_flag}" PARENT_SCOPE)