Fix CMake toolchain template env corruption and abseil build regression #15786
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request changes Conan 2's
CMakeToolchain
to end in a new line by setting Jinja'skeep_final_newline
flag. This resolves #15785, where invalid CMake code was emitted.Setting the flag as-is in the original code would however entirely break the CMake toolchain generation due to a silent corruption of Jinja environments caused by a usage error. The original code would make
cmake_value
available from blocks.py to toolchain.py by corrupting Jinja shared environments. The whole thing worked incidentally! Any Jinja improvement to make Jinja more robust against this usage error would have broken Conan. This refactors the code to fix the silent corruption and properly inheritcmake_value
from toolchain.py into blocks.py.It also adds a test to ensure that this does not regress again in future versions.
Changelog:
CMakeToolchain
.Docs: https://github.com/conan-io/docs/pull/XXXX
If the issue has missing info, explain the purpose/use case/pain/need that covers this Pull Request.develop
branch, documenting this one.