Skip to content

Commit

Permalink
CMakeLists.txt: Enable CMAKE_MSVC_RUNTIME_LIBRARY support (open-telem…
Browse files Browse the repository at this point in the history
…etry#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 <[email protected]>
  • Loading branch information
t-b and ThomsonTan authored Jun 6, 2024
1 parent 1d8a7b5 commit 436a981
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 436a981

Please sign in to comment.