diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ddc192b..269b225c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,12 @@ endif() cmake_policy(PUSH) cmake_policy(VERSION ${CMAKE_MINIMUM_REQUIRED_VERSION}) +if(NOT CMAKE_VERSION VERSION_LESS 3.21) + cmake_policy(SET CMP0126 NEW) +endif() +if(NOT CMAKE_VERSION VERSION_LESS 3.17) + cmake_policy(SET CMP0102 NEW) +endif() if(NOT CMAKE_VERSION VERSION_LESS 3.15) cmake_policy(SET CMP0091 NEW) endif() @@ -52,6 +58,7 @@ if(NOT CMAKE_VERSION VERSION_LESS 3.12) cmake_policy(SET CMP0075 NEW) endif() if(NOT CMAKE_VERSION VERSION_LESS 3.9) + cmake_policy(SET CMP0068 NEW) cmake_policy(SET CMP0069 NEW) include(CheckIPOSupported) check_ipo_supported(RESULT CMAKE_INTERPROCEDURAL_OPTIMIZATION_AVAILABLE) @@ -184,8 +191,9 @@ if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND MSVC_VERSION LESS 1900) " At least 'Microsoft Visual Studio 2015' is required.") endif() -set(CMAKE_THREAD_PREFER_PTHREAD TRUE) -set(THREADS_PREFER_PTHREAD_FLAG TRUE) +if(NOT DEFINED THREADS_PREFER_PTHREAD_FLAG) + set(THREADS_PREFER_PTHREAD_FLAG TRUE) +endif() find_package(Threads REQUIRED) include(cmake/utils.cmake) diff --git a/cmake/compiler.cmake b/cmake/compiler.cmake index 58639a0e..ff9eb0dd 100644 --- a/cmake/compiler.cmake +++ b/cmake/compiler.cmake @@ -21,6 +21,25 @@ endif() cmake_policy(PUSH) cmake_policy(VERSION ${CMAKE_MINIMUM_REQUIRED_VERSION}) +if(NOT CMAKE_VERSION VERSION_LESS 3.21) + cmake_policy(SET CMP0126 NEW) +endif() +if(NOT CMAKE_VERSION VERSION_LESS 3.17) + cmake_policy(SET CMP0102 NEW) +endif() +if(NOT CMAKE_VERSION VERSION_LESS 3.15) + cmake_policy(SET CMP0091 NEW) +endif() +if(NOT CMAKE_VERSION VERSION_LESS 3.13) + cmake_policy(SET CMP0077 NEW) +endif() +if(NOT CMAKE_VERSION VERSION_LESS 3.12) + cmake_policy(SET CMP0075 NEW) +endif() +if(NOT CMAKE_VERSION VERSION_LESS 3.9) + cmake_policy(SET CMP0068 NEW) + cmake_policy(SET CMP0069 NEW) +endif() if(CMAKE_VERSION MATCHES ".*MSVC.*" AND CMAKE_VERSION VERSION_LESS 3.16) message(FATAL_ERROR "CMake from MSVC kit is unfit! "