Merge pull request #1693 from relapids/cmake_msvc_runtime
Fix MSVC runtime library handling in CMakeLists. (#1692)
This commit is contained in:
commit
bc74ea2fe8
|
@ -3,16 +3,18 @@
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.1)
|
cmake_minimum_required(VERSION 3.1)
|
||||||
|
|
||||||
if(MSVC)
|
# Only required for MSVC, but we can't know the compiler at this point because we haven't
|
||||||
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.15")
|
# called enable_language() or project(), and if we did that it would lock in the old
|
||||||
# set all policies to max supported by actual running cmake version
|
# policy. Setting these policies is harmless for non-MSVC though, so just enable them
|
||||||
# mainly want the following:
|
# always.
|
||||||
# CMP0091: prevent msvcrt flags being added to default CMAKE_<LANG>_FLAGS_<CONFIG>
|
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.15")
|
||||||
# CMP0092: prevent warning flags being added to default CMAKE_<LANG>_FLAGS
|
# Set explicitly the policies we want rather than raising the base to the current
|
||||||
cmake_policy(VERSION ${CMAKE_VERSION})
|
# version. This prevents unintended behavior changes as CMake evolves and provides a
|
||||||
else()
|
# consistent experience across different CMake versions.
|
||||||
message(FATAL_ERROR "please update cmake")
|
# CMP0091: prevent msvcrt flags being added to default CMAKE_<LANG>_FLAGS_<CONFIG>
|
||||||
endif()
|
cmake_policy(SET CMP0091 NEW)
|
||||||
|
# CMP0092: prevent warning flags being added to default CMAKE_<LANG>_FLAGS for MSVC
|
||||||
|
cmake_policy(SET CMP0092 NEW)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Workaround to fix wrong compiler on macos.
|
# Workaround to fix wrong compiler on macos.
|
||||||
|
@ -31,6 +33,13 @@ endif()
|
||||||
|
|
||||||
project(unicorn C)
|
project(unicorn C)
|
||||||
|
|
||||||
|
# We depend on the availability of the CMAKE_MSVC_RUNTIME_LIBRARY, which is only
|
||||||
|
# available in CMake 3.15 and above (see also the comments above in regards to policy
|
||||||
|
# CMP0091).
|
||||||
|
if(MSVC AND CMAKE_VERSION VERSION_LESS "3.15")
|
||||||
|
message(FATAL_ERROR "Please update CMake to 3.15 or greater.")
|
||||||
|
endif()
|
||||||
|
|
||||||
# mainline qemu mostly just uses compiler default
|
# mainline qemu mostly just uses compiler default
|
||||||
set(CMAKE_C_STANDARD 11)
|
set(CMAKE_C_STANDARD 11)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue