-
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
catch2 (2.x.x): support conan v2 #13794
Conversation
This comment has been minimized.
This comment has been minimized.
recipes/catch2/2.x.x/conanfile.py
Outdated
tc.variables["BUILD_TESTING"] = False | ||
tc.cache_variables["CATCH_INSTALL_DOCS"] = False | ||
tc.cache_variables["CATCH_INSTALL_HELPERS"] = "ON" | ||
tc.cache_variables["CATCH_BUILD_STATIC_LIBRARY"] = self.options.with_main # FIXME cache_variables or just variables? |
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.
In case of doubt: conan-io/conan#11937 (comment)
Plus:
- https://docs.conan.io/en/latest/reference/conanfile/tools/cmake/cmaketoolchain.html#cache-variables
- https://docs.conan.io/en/latest/reference/conanfile/tools/cmake/cmaketoolchain.html#variables
There are two main cases to use cache_variables
:
- When a definition is configured before
project()
- When an option uses
CACHE
. Need to check project's CMakeLists.txt
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.
The docs currently focus on the difference that CACHE is for "single config" compare to "multiple config",
and says for the majority of cases cache_variables is what you probably want to use
... so this seems to be a complex topic...
I see almost all recipes use variables, but it seems like if you really want the variable to be set, you should use cache_variables and there is less room for surprises?
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.
In CMake, cache variables are how CMake and projects expose options to be set by consumers. Cache variables are meant to be able to be preemptible by consumers. If a consumer sets it before a project does, the project won't change the value. I think you're right, @paulharris, that we should prefer setting cache variables instead when possible, as this is how projects should expose the options we are often setting.
There are of course, tons of CMake projects that don't respect cache variables and set normal variables with the same name which causes all sorts of problems.... ugh. And the issue with setting most variables before the first project command is quite problematic.
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.
Hopefully improvements for this are coming with a future CMake?
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.
#13971 not the best but it's a start
Co-authored-by: Uilian Ries <uilianries@gmail.com>
This comment has been minimized.
This comment has been minimized.
Can someone please help me understand why this line is in the 3.x.x recipe:
tc.variables["CATCH_CONFIG_PREFIX_ALL"] = self.options.with_prefix As far as I can tell, this is not a CMake variable... I see it here:
But that is defining a test name(?) not a variable... |
@@ -46,7 +46,7 @@ def _compilers_minimum_version(self): | |||
|
|||
@property | |||
def _default_reporter_str(self): | |||
return '"{}"'.format(str(self.options.default_reporter).strip('"')) | |||
return str(self.options.default_reporter).strip('"') |
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.
@SpaceIm as noted in main comment - please check this too
I've fixed up the prefix behaviour, looks like there was some errors in the 3.x.x recipe. @SpaceIm can you please check the highlighted lines especially, as I'm not sure why the magic was required for the quotes. conan/cmake is quoting those values, so they end up double-quoted in conan_toolchain.cmake if the quotes are added here. |
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 catch2/3.x.x recipe: This message is automatically generated by https://github.com/ericLemanissier/conan-center-conflicting-prsso don't hesitate to report issues/improvements there. |
# note: this is required as self.dependencies is not available in test() | ||
self._tests_todo.append("test_package") | ||
if catch_opts.with_main: | ||
self._tests_todo.append("standalone") | ||
if not catch_opts.with_prefix and catch_opts.with_main and catch_opts.with_benchmark: | ||
self._tests_todo.append("benchmark") |
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.
# note: this is required as self.dependencies is not available in test() | |
self._tests_todo.append("test_package") | |
if catch_opts.with_main: | |
self._tests_todo.append("standalone") | |
if not catch_opts.with_prefix and catch_opts.with_main and catch_opts.with_benchmark: | |
self._tests_todo.append("benchmark") | |
# note: this is required as self.dependencies is not available in test() | |
self._tests_todo.append("test_package") | |
if catch_opts.with_main: | |
self._tests_todo.append("standalone") | |
if not catch_opts.with_prefix and catch_opts.with_main and catch_opts.with_benchmark: | |
self._tests_todo.append("benchmark") |
It does not work. Conan parse twice the recipe folder and _tests_todo will be empty as soon as test() is called.
You can create a temporary file and and those values. More information: conan-io/conan#12411
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 did this in 332eb40
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 cherry-picked your commit and fixed it up slightly
This comment has been minimized.
This comment has been minimized.
This reverts commit 332eb40.
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Chris Mc <prince.chrismc@gmail.com>
Thanks @prince-chrismc, I included your work and fixed it up slightly |
Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com>
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
Conan v1 pipelineAll green in build 19 (
|
catch2 (2.x.x): support conan v2, based on work by SpaceIm that was done for 3.x.x
ie #13184
It currently doesn't build the test_package with
with_prefix=True
It seems that the package_info() self.cpp_info.defines are not being seen by the test_package. I'm not sure what I'm doing wrong.