Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMakeLists.txt: Enable CMAKE_MSVC_RUNTIME_LIBRARY support #2652

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

t-b
Copy link

@t-b t-b commented Apr 29, 2024

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.

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
@t-b t-b requested a review from a team as a code owner April 29, 2024 21:00
Copy link
Member

@lalitb lalitb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, removing the approval for the CI failure. Probably we should set the policy only if vcpkg is used (i.e, VCPKG_TOOLCHAIN is set)? cc @ThomsonTan

@lalitb lalitb self-requested a review April 30, 2024 02:50
@t-b
Copy link
Author

t-b commented Apr 30, 2024

Sorry, removing the approval for the CI failure. Probably we should set the policy only if vcpkg is used (i.e, VCPKG_TOOLCHAIN is set)? cc @ThomsonTan

My usecase is not related to vcpkg, I'm just compiling with MSVC.

Copy link
Member

@marcalff marcalff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR.

This change is probably not sufficient, as it triggers build failures in CI.

Please investigate and fix errors such as:

benchmark.lib(benchmark.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MTd_StaticDebug' in attributes_hashmap_benchmark.obj [D:\a\opentelemetry-cpp\opentelemetry-cpp\build\sdk\test\metrics\attributes_hashmap_benchmark.vcxproj]

@t-b
Copy link
Author

t-b commented May 6, 2024

Thanks for the PR.

This change is probably not sufficient, as it triggers build failures in CI.

Please investigate and fix errors such as:

benchmark.lib(benchmark.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MTd_StaticDebug' in attributes_hashmap_benchmark.obj [D:\a\opentelemetry-cpp\opentelemetry-cpp\build\sdk\test\metrics\attributes_hashmap_benchmark.vcxproj]

Thanks for the review, will do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants