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
[bug] conan_toolchain.cmake overwrites CMAKE_${lang}_FLAGS_INIT from user_toolchain #9575
Comments
I see. Lets try in #9576 to see if something breaks (we have had issues because of not CACHE FORCE some vars in the past). |
well, if you CACHE without FORCE, it won't recalculate on a re-run (keeping the previous cached value). but CACHE force is just about equivalent to not using CACHE at all (unless you're adding some further logic with But this won't recalculate anyway, because |
This was fixed in #9576, will be released soon in 1.40.1, thanks! |
Fixed indeed, but I did discover one other interesting wrinkle that might be worth a changelog mention (your call). In addition to the problem I had with it (didn't play nice with a user_toolchain), the old way using of CACHE here breaks in CMake 3.21 (specifically if CMP0126 set(CACHE) does not remove a normal variable of the same name is NEW). cmake_minimum_required(VERSION 3.20)
project(test LANGUAGES)
set(FOO 1)
set(FOO 2 CACHE STRING "" FORCE)
message(STATUS "FOO=${FOO}")
cmake_minimum_required(VERSION 3.21)
https://cmake.org/cmake/help/latest/manual/cmake-language.7.html#variables
|
The fix in #9576 should already address this too, but it means it might have more widespread impact than I had realized when I reported it as a bug for those doing fancy stuff in user_toolchain. |
Thanks for highlighting this issue. It sounds good that this fix helped with that CMake 3.21 issue too. Not sure if a late changelog change would help much, the change is already documented, and as long as the behavior is the expected one now, I'd say we are good. |
There are a couple design issues with how the cmake_flags_init currently seems to work.
CMAKE_LANG_FLAGS_INIT should not be a CACHE variable - it's only really consulted during cmake_initialize_per_config_variable, and setting it later won't change the resulting cached CMAKE__FLAGS. Changing it later and reconfiguring will not actually apply any changes, since this gets baked into CMakeFiles/3.20.0/CMakeCXXCompiler.cmake
Just flat-out overwriting it (with FORCE, even!) is pretty uncooperative, and will break if the user_toolchain that also had flags that neeed to be passed (e.g. we must pass winegcc
-Bprefix
and--target=
options so it picks the right underlying gcc, and conan won't know anything about that, and shouldn't need to).So I'd think at least
or maybe
Or maybe even rename these to
CONAN_*_FLAGS_INIT
in the toolchain file, to emphasize that they only do anything the first time around (when cmake is compiler probing)?Environment Details (include every applicable attribute)
The text was updated successfully, but these errors were encountered: