-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[fmt] conan v2 compatibility #10456
[fmt] conan v2 compatibility #10456
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO we should keep a working test_xxxxx/conanfile.py
using stable generators (cmake
+ cmake_find_package[_multi]
). Would you mind keeping that example too?
these generators aren't stable, they are marked as "experimental": https://docs.conan.io/en/latest/reference/generators/cmake_find_package_multi.html I would keep only examples using current best practices going forward (CMakeDeps/CMakeToolchain). UPD: last year I've tried to promote these generators conan-io/docs#2269, but seems like there was not enough interest to make them officially recommended. anyway, given now we have at least 7 different CMake generators available, it's easy for newcomers to get confused and completely lost. I think going forward, it only makes sense to promote CMakeDeps/CMakeToolchain as recommended, as others will just disappear soon. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I detected other pull requests that are modifying fmt/all recipe: This message is automatically generated by https://github.com/ericLemanissier/conan-center-conflicting-prs so don't hesitate to report issues/improvements there. |
@SSE4 , please, fix conflicts... let's see if this one works with v2 |
* add fmt for 2.0 * safe rm * remove names * add definition * fix * names back * remove export_sources * add exports_sources
Signed-off-by: SSE4 <[email protected]>
Signed-off-by: SSE4 <[email protected]>
Signed-off-by: SSE4 <[email protected]>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This reverts commit 56c874a.
This comment has been minimized.
This comment has been minimized.
@SSE4 the package_info I proposed was failing because the components in Conan 1.50 don't have default libdirs, includedirs, etc. and the hook 54 failed. It would be fixed with this updated package_info: def package_info(self):
self.cpp_info.names["cmake_find_package"] = "fmt"
self.cpp_info.names["cmake_find_package_multi"] = "fmt"
self.cpp_info.names["pkg_config"] = "fmt"
target = "fmt-header-only" if self.options.header_only else "fmt"
self.cpp_info.set_property("cmake_target_name", "fmt::{}".format(target))
# TODO: back to global scope in conan v2 once cmake_find_package* generators removed
self.cpp_info.components["_fmt"].includedirs.extend(["include"])
if self.options.header_only:
self.cpp_info.components["_fmt"].defines.append("FMT_HEADER_ONLY=1")
if self.options.with_fmt_alias:
self.cpp_info.components["_fmt"].defines.append("FMT_STRING_ALIAS=1")
else:
postfix = "d" if self.settings.build_type == "Debug" else ""
libname = "fmt" + postfix
self.cpp_info.components["_fmt"].libs = [libname]
# FIXME: remove when Conan 1.50 is used in c3i and update the Conan required version
# from that version components don't have empty libdirs by default
self.cpp_info.components["_fmt"].libdirs.extend(["lib"])
if self.options.with_fmt_alias:
self.cpp_info.components["_fmt"].defines.append("FMT_STRING_ALIAS=1")
if self.options.shared:
self.cpp_info.components["_fmt"].defines.append("FMT_SHARED")
# TODO: to remove in conan v2 once cmake_find_package* generators removed
self.cpp_info.components["_fmt"].names["cmake_find_package"] = target
self.cpp_info.components["_fmt"].names["cmake_find_package_multi"] = target
self.cpp_info.components["_fmt"].set_property("cmake_target_name", "fmt::{}".format(target)) This is more aligned with what we do in other recipes, but I would be ok with merging the current package_info as is but adding a FIXME or some comments saying that the reason of having a component there is just to create a new target name for header-only. |
This comment has been minimized.
This comment has been minimized.
@czoido seems like it still fails for Windows/shared configs. might it be due to missing default |
Yes, I think that could be the reason.... |
This comment has been minimized.
This comment has been minimized.
Hooks produced the following warnings for commit 48eecaffmt/5.3.0
fmt/9.0.0
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super excited seeing this working!!!
"FMT_LIB_DIR": "lib" | ||
} | ||
if self._has_with_os_api_option: | ||
cache_entries["FMT_OS"] = self.options.with_os_api |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am curious about the other variable mechanics https://docs.conan.io/en/latest/reference/conanfile/tools/cmake/cmaketoolchain.html#variables
If the toolchain sets the value before the options are declared then they do nothing according to https://cmake.org/cmake/help/latest/command/option.html
If this is set to use 1.49 then I think we could get away for using just tc.variables
however I agree the cache ones are better UX this seems to be working for my project
Signed-off-by: SSE4 <[email protected]>
Signed-off-by: SSE4 <[email protected]>
All green in build 30 (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 🎉
This is a good starting point for a working v2 recipe, some details can be polished later.
Specify library name and version: fmt/all
a port from czoido@5708ca4
/cc @czoido
2.0.0beta2
: Available folders in post_export hook conan#11643