From 436a981d81c1094c66b7e647b5380f23c099efed Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Thu, 6 Jun 2024 19:34:47 +0200 Subject: [PATCH] CMakeLists.txt: Enable CMAKE_MSVC_RUNTIME_LIBRARY support (#2652) The documentation for CMAKE_MSVC_RUNTIME_LIBRARY states [1]: > This variable has effect only when policy CMP0091 is set to NEW prior to > the first project() or enable_language() command that enables a language > using a compiler targeting the MSVC ABI. so the current usage of CMAKE_MSVC_RUNTIME_LIBRARY for vcpkg does not work at all. Let's fix that by setting policy 91 to new if present. [1]: https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html Co-authored-by: Tom Tan --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0304beec50..2e61faed35 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,11 @@ if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.12") cmake_policy(SET CMP0074 NEW) endif() +# Prefer CMAKE_MSVC_RUNTIME_LIBRARY if possible +if(POLICY CMP0091) + cmake_policy(SET CMP0091 NEW) +endif() + project(opentelemetry-cpp) # Mark variables as used so cmake doesn't complain about them