conan
                                
                                 conan copied to clipboard
                                
                                    conan copied to clipboard
                            
                            
                            
                        [bug] breaking change in 1.51: cannot call `find_package(dependency)` twice from different directory scopes
I have a project A that uses Conan for most dependencies, but depends on one package B (not found in conan-center) as a submodule and imports it in CMake with add_subdirectory(). Both A and B depend on OpenSSL and call find_package(OpenSSL). This used to work with Conan 1.50. Now it breaks with Conan 1.51 with this error:
 -- Conan: Including build module from '/home/runner/.conan/data/openssl/1.1.1m/_/_/package/6af9cc7cb931c5ad942174fd7838eb655717c709/lib/cmake/conan-official-openssl-variables.cmake'
  Cannot specify link libraries for target "openssl::openssl" which is not
  built by this project.
Call Stack (most recent call first):
  .build/OpenSSLTargets.cmake:26 (include)
  .build/OpenSSLConfig.cmake:10 (include)
  subdirectory/CMakeLists.txt:3 (find_package)
I have a minimal example (you can ignore the Makefile; it is only there to ease testing for humans) demonstrating the break in GitHub Actions.
At first, I thought this would be related to CMake policy CMP0079, but that says there is an exception made for setting the INTERFACE_LINK_LIBRARIES property, and the offending command looks like this, which I thought would fit the exception:
target_link_libraries(openssl::openssl INTERFACE OpenSSL::SSL)
Further, calling cmake_policy(SET CMP0079 NEW) does not fix the problem.
This may be related to #11743.
Hi! This is a duplicate of https://github.com/conan-io/conan/issues/11743 that has been merged to be released at 1.51.1 but we still have one more regression pending on CMakeDeps so we are working on it.