Skip to content
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] find frameworks path is cached in cmake and not invalidated when dependency updates #17224

Open
technic opened this issue Oct 25, 2024 · 4 comments · Fixed by #16964
Open
Assignees
Milestone

Comments

@technic
Copy link

technic commented Oct 25, 2024

Describe the bug

this code from cmakedeps_macros.cmake has nasty bug

macro(conan_find_apple_frameworks FRAMEWORKS_FOUND FRAMEWORKS FRAMEWORKS_DIRS)
    if(APPLE)
        foreach(_FRAMEWORK ${FRAMEWORKS})
            # https://cmake.org/pipermail/cmake-developers/2017-August/030199.html
            find_library(CONAN_FRAMEWORK_${_FRAMEWORK}_FOUND NAMES ${_FRAMEWORK} PATHS ${FRAMEWORKS_DIRS} CMAKE_FIND_ROOT_PATH_BOTH)
            if(CONAN_FRAMEWORK_${_FRAMEWORK}_FOUND)
                list(APPEND ${FRAMEWORKS_FOUND} ${CONAN_FRAMEWORK_${_FRAMEWORK}_FOUND})
                message(VERBOSE "Framework found! ${FRAMEWORKS_FOUND}")
            else()
                message(FATAL_ERROR "Framework library ${_FRAMEWORK} not found in paths: ${FRAMEWORKS_DIRS}")
            endif()
        endforeach()
    endif()
endmacro()

It caches CONAN_FRAMEWORK_${_FRAMEWORK}_FOUND variable and after conanfile is updated with the new version cmake still uses old cached framework.

This is CMakeDeps generator, conan 1.64. I suppose conan v2 has similar issue, but I didn't check

How to reproduce it

No response

@memsharded memsharded self-assigned this Oct 25, 2024
@memsharded
Copy link
Member

Hi @technic

Thanks for your report.

In some situations it is true that the CMake caching will interfere with dependencies changes. In general, when changing things outside of the current project, like Conan dependencies, we would recommend to invalidate the CMake cache when possible to avoid potential caching issue.

In any case, we are moving to a different model, based on the CPS standardization effort (that we are participating in), and we are implementing a new CMakeDeps generator in #16964. This will not have the cmakedeps_macros.cmake file or the find_frameworks() at all, so that will solve the issue already.

@technic
Copy link
Author

technic commented Oct 25, 2024

I think this can be fixed, if I look at how conan_package_library_targets is implemented there is unset(CONAN_FOUND_LIBRARY CACHE) call which removes the location from the cache. And there is no per library variable for it. Why do we have ${_FRAMEWORK} part of the variable?

even better is to do such search in conan during generate() and provide full path to cmake instead of doing find_library calls. This will be faster when doing cmake reconfigure.
Also this will probably make creating CONAN_LIB:: targets not needed. I want to do install(IMPORTED_RUNTIME_ARTIFACTS) in cmake but I cant do it for normal target like zlib::zlib because it is a proxy target to CONANLIB::bla-bla target. This is inconvenient.

@memsharded
Copy link
Member

I think this can be fixed, if I look at how conan_package_library_targets is implemented there is unset(CONAN_FOUND_LIBRARY CACHE) call which removes the location from the cache. And there is no per library variable for it. Why do we have ${_FRAMEWORK} part of the variable?

I see. If you think it is worth to try to unset() or something like that to avoid the issue, please try to contribute a Pull Request.

even better is to do such search in conan during generate() and provide full path to cmake instead of doing find_library calls. This will be faster when doing cmake reconfigure.

This is basically what the new CMakeDeps is doing, together with an augmented new model in cpp_info that includes information like cpp_info.location.
Also the full generation of targets is different in the new CMakeDeps, no CONAN_LIB targets is generated. Please have a look to the PR #16964, it will also be made available in Conan 2.9 under a new conf to activate it (exclusively for testing, not for production).

@memsharded
Copy link
Member

I am re-opening this, this was not really solved yet by #16964

@memsharded memsharded reopened this Oct 29, 2024
@memsharded memsharded added this to the 2.10.0 milestone Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants