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
[feature] Add is_cl_like()
or improve is_msvc()
method to perfectly mimic behavior of MSVC
variable in CMake
#12336
Comments
The thing is that I'd say that this needs to be fixed at the |
MSVC value doesn't depend on generator, only compiler. It's deterministic at
In conan-center we honor lib file names of upstream. And moreover we can't patch upstream CMakeLists forever, libs maintainers won't accept a patch like that in their source code which would introduce a breaking change to lib name (due to a conan limitation). |
No, it is not. The |
You mean that the same compiler can work with Visual Studio generatorI, and it would set MSVC to TRUE? It's a complete mess, looks like a CMake bug. |
Yes, if using Visual Studio generator, it uses the internal bundled ClangCL, but it is the same compiler as external LLVM/Clang, and they are binary compatible, so for Conan |
I see. Well that's a big problem, because such complexity to properly handle libraries having |
I think that a Or why not |
conan build should be deterministic and predictable, it means:
|
Should we ban In any case
I don't care about divergence from the upstream if things are broken. The priority should be things should work, then match to upstream, not the opposite. If people are consuming Conan packages, it is also not expected that they will have |
Not ban, but avoid as much as possible. We use collect_libs either for historical reasons, or because original recipe author was too lazy to find true lib name, or because it's not predictable based on settings/options (generator dependent for example, which is ugly I agree).
You don't take into account that downstream users are not always conan users, but also recipes based on build systems which are not aware of conan paradigm. We have to avoid patches as much as possible, because it's a maintenance burden. |
I personally never liked and recommended this one since its inception, I wish it could be banned - it's completely non-transparent what does it capture (it may capture different things for different users) and causes issues (like, it may capture more libraries than needed - some libraries are not needed to be linked by default; or libraries with same name in different directories, or whatever). realistically speaking, bad might be too sound, but it might be flagged as a general warning and slowly deleted in new PRs.
IMO patch should always be a last measure - all these patches need to be maintained (=rebased for new releases), and they make behavior of conan build diverge from the upstream (which is a source of confusion by itself)
you may rename, but it might be too fragile (especially, for things like
about
I don't like wording
yes, working builds, but different from upstream, are better than no builds at all, or non-working builds. but here it's not the situation of non-working build, it's just a sophisticated upstream logic to select a library name.
they already used it even before conan, and will continue to use. conan might be used by some projects, but they still have a requirement to be able to be built without conan, with old-fashioned methods (like, with dependencies installed from apt-get or whatever).
IMO, it's not our business to decide. upstream chooses to produce library names for their own logic and their own use-cases, and we should follow. for instance, in some build systems (e.g. b2) you can build x86 and x64 together in one shot, and ask b2 to encode architecture into the library name as a tag, so libraries for the same architecture may perfectly co-live in the same folder. in case of zlib, underlying compiler might not be the only important thing between these two builds, what if they activate different compiler flags or preprocessor definitions in these two builds? they might not be 100% compatible. |
In the same vein, a helper |
I read https://blog.conan.io/2022/10/13/Different-flavors-Clang-compiler-Windows.html, and from my understanding current settings in conan are not sufficient to disambiguate each clang flavor in a recipe. Different clang flavors share the same settings, so recipes can't know from settings if compiler is clang-cl or llvm-clang. Helpers I would advice:
Improve msvc_runtime_flags & is_msvc_static_runtime to support compiler with a runtime attribute. |
@memsharded there are really too many issues in conan-center related to compilation with different windows clang flavors. It's really important that conan profiles can explicitly express which flavor a user is using, so that recipes can rely on this information to go into correct recipe branch when it's relevant.
|
CMake has been supporting this with What do you recommend end users do about this problem at the moment? |
Currently conan provides
is_msvc()
method which returns True ifcompiler=Visual Studio
orcompiler=msvc
in settings. In conan-center recipes, this method is widely used for different logics, and one of them is for some branching in package() and package_info() depending onMSVC
variable in upstream CMakeLists (conditional lib name, renaming of files, injection of definitions etc).But
MSVC
variable in CMake is not only True for Visual Studio, but also for any cl like compiler like clang-cl: https://cmake.org/cmake/help/latest/variable/MSVC.htmlThe problem is that depending on clang flavor on Windows, it may or may not be a cl like compiler for CMake. It leads to wrong assumption in several recipes, for example zlib where
cpp_info.libs
may be wrong depending on clang flavor: conan-io/conan-center-index#13474For example a CMakeLists may have this:
so that in conan recipe we usually write:
It's very common, and it's broken for clang-cl.
So some folks using clang-cl were disappointed and began to put this kind of snippet in CCI recipes (and this time it's broken for non cl-like clang flavors on windows, so other folks complain that their clang flavor on windows doesn't work anymore):
So it would be nice if conan could provide a method to perfectly mimic https://cmake.org/cmake/help/latest/variable/MSVC.html logic. It may be another method than
is_msvc
, or an additional argument tois_msvc
in order to switch to CMakeMSVC
behavior.The text was updated successfully, but these errors were encountered: