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

[BUILD] CMakeLists.txt: Enable CMAKE_MSVC_RUNTIME_LIBRARY support #2652

Merged
merged 4 commits into from
Jun 6, 2024

Conversation

t-b
Copy link
Contributor

@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 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
Contributor 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
Contributor 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.

Copy link

codecov bot commented Jun 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.68%. Comparing base (497eaf4) to head (3ff8b97).
Report is 76 commits behind head on main.

Current head 3ff8b97 differs from pull request most recent head 2566fa7

Please upload reports for the commit 2566fa7 to get more accurate results.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2652      +/-   ##
==========================================
+ Coverage   87.12%   87.68%   +0.56%     
==========================================
  Files         200      190      -10     
  Lines        6109     5851     -258     
==========================================
- Hits         5322     5130     -192     
+ Misses        787      721      -66     

see 74 files with indirect coverage changes

@ThomsonTan
Copy link
Contributor

The CI should have been fixed by #2696.

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.

LGTM, thanks for the fix.

@marcalff marcalff changed the title CMakeLists.txt: Enable CMAKE_MSVC_RUNTIME_LIBRARY support [BUILD] CMakeLists.txt: Enable CMAKE_MSVC_RUNTIME_LIBRARY support Jun 6, 2024
@marcalff marcalff merged commit 436a981 into open-telemetry:main Jun 6, 2024
49 checks passed
malkia added a commit to malkia/opentelemetry-cpp that referenced this pull request Jun 6, 2024
CMakeLists.txt: Enable CMAKE_MSVC_RUNTIME_LIBRARY support (open-telemetry#2652)
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.

4 participants