-
Notifications
You must be signed in to change notification settings - Fork 446
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
Use standard BUILD_SHARED_LIBS instead of OPENTELEMETRY_BUILD_DLL with MSVC/Windows #2477
Comments
Good point. I think we can set the default value of |
@owent Yes, I think the default needs to be modified (when building on windows + If they (api, sdk (trace, metrics, common etc.), exporters ...) are built as dlls themselves, they can not be merged* into a common dll later (opentelemetry_cpp.dll). Please correct me if this is wrong (if I am, the modifications to make this work are even smaller). *not sure if this is the right term |
Good point. I think it's better to add new function (such as |
I'll start looking at drafting a PR when #2476 is completed :) |
This issue was marked as stale due to lack of activity. |
tl;dr Basically use BUILD_SHARED_LIBS to get the same result as OPENTELEMETRY_BUILD_DLL does today.
The OPENTELEMETRY_BUILD_DLL macro should perhaps still be supported for compability, the idea is to be able to utilize standard cmake functionality to increase discoverability.
To achieve this:
When BUILD_SHARED_LIBS is defined
Is set to STATIC when BUILD_SHARED_LIBS=OFF and SHARED when BUILD_SHARED_LIBS=ON, except when OPENTELEMETRY_BUILD_DLL=ON (i.e. msvc) it is set to STATIC. All targets in opentelemetry where linkage varies, must use this macro:
add_library(mytarget ${OPENTELEMETRY_LIBRARY_TYPE} <sources..>)
. https://discourse.cmake.org/t/using-generator-expression-with-add-library/156/2I think this technique would also surface more issues with the windows dll build: if e.g. common_*_foo_library did not use OPENTELEMETRY_LIBRARY_TYPE, they will be shared dll libraries in the build, thus build/run would test that using otel-cpp across dll-boundaries (.exe + dll-lib + opentelemetry_cpp.dll) works. We have already found bugs that I suspect would be found in CI with this approach.
That's it, really. What do you think?
The text was updated successfully, but these errors were encountered: