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] CMake.patch_config_paths, CMakeDeps and build_id broken #10816

Closed
jsallay opened this issue Mar 17, 2022 · 3 comments
Closed

[bug] CMake.patch_config_paths, CMakeDeps and build_id broken #10816

jsallay opened this issue Mar 17, 2022 · 3 comments

Comments

@jsallay
Copy link
Contributor

jsallay commented Mar 17, 2022

Environment Details (include every applicable attribute)

  • Operating System+version: Ubuntu 20 (Building in an Ubuntu docker image)
  • Compiler+version: gcc9
  • Conan version: 1.46.0
  • Python version: 3.8.10

Steps to reproduce (Include if Applicable)

I have a large package that I am building and would like to create two packages, one with everything and the other removing a few features. I have overloaded the build_id function in my conanfile.py. I have discovered that if patch_config_paths is called in the conanfile, then the conan create commands after the first will fail. Cmake fails to find project dependencies.

The CMake.patch_config_paths function replaces hardcoded paths in the build and package folder with ${CONAN_<project_name>_ROOT}. When the CMakeDeps generator produces the cmake config files in the build folder, it replaces instances of ${CONAN_<project_name>_ROOT} with a hardcoded path. When using build id, the generator is not rerun with every subsequent command.

As a concrete example, when I run the CMakeDeps generator, it produces a Boost-release-x86_64-data.cmake in my build_folder that contains the following line:

set(boost_PACKAGE_FOLDER_RELEASE "/root/.conan/data/boost/1.76.0/_/_/package/5ab3ce5b625d1dfb872abb741f6fb2d0f38a7710")

After my recipe executes CMake.patch_config_paths the file now contains:

set(boost_PACKAGE_FOLDER_RELEASE ${CONAN_BOOST_ROOT}

When I attempt to create the second package, CMake complains that it can't find Boost, which makes sense because CONAN_BOOST_ROOT isn't defined. It ends up looking in the wrong place.

I'm not sure why CMake.patch_config_paths replaces files in the build directory since those files are not a part of the final package. I'm guessing that this could be fixed by only replacing files in the package directory, but there may be something that I don't understand going on. If nothing else, I don't think that it should replace paths in the files produced by the CMakeDeps generator.

Logs (Executed commands with output) (Include/Attach if Applicable)

-- Conan: Target declared 'boost::boost'
CMake Error at /root/.conan/data/gnuradio/3.8.3.1/_/_/build/bfa6f102a7af0393db8c8868635ddbf91f756c5a/cmakedeps_macros.cmake:4 (message):
  Library 'boost_log_setup' not found in package.  If 'boost_log_setup' is a
  system library, declare it with 'cpp_info.system_libs' property
Call Stack (most recent call first):
  /root/.conan/data/gnuradio/3.8.3.1/_/_/build/bfa6f102a7af0393db8c8868635ddbf91f756c5a/cmakedeps_macros.cmake:50 (conan_message)
  /root/.conan/data/gnuradio/3.8.3.1/_/_/build/bfa6f102a7af0393db8c8868635ddbf91f756c5a/Boost-Target-release.cmake:21 (conan_package_library_targets)
  /root/.conan/data/gnuradio/3.8.3.1/_/_/build/bfa6f102a7af0393db8c8868635ddbf91f756c5a/BoostTargets.cmake:26 (include)
  /root/.conan/data/gnuradio/3.8.3.1/_/_/build/bfa6f102a7af0393db8c8868635ddbf91f756c5a/BoostConfig.cmake:11 (include)
  cmake/Modules/GrBoost.cmake:88 (find_package)
  CMakeLists.txt:363 (include)
@memsharded
Copy link
Member

The CMake.patch_config_paths belongs to the legacy CMake generator, not to the from conan.tools.cmake import CMake modern one.

You cannot mix the legacy tools with the new ones, like CMakeDeps. If you are going to use CMakeDeps, please use the matching from conan.tools.cmake import CMake helper.

Also, the CMake.patch_config_paths is not intended to modify the files created by the Conan generators, but instead to patch some of the current package cmake files generated by CMake, to make them location agnostic before packaging.

Note: the patch_config_paths is no longer implemented in the new integrations.

@jsallay
Copy link
Contributor Author

jsallay commented Mar 17, 2022

Thanks. It looks like I only partially upgraded to the new CMake stuff. I'll try out the new CMake and toolchain parts and see how that goes.

@jsallay jsallay closed this as completed Mar 17, 2022
@Da-LiFe
Copy link

Da-LiFe commented Oct 5, 2022

Note: the patch_config_paths is no longer implemented in the new integrations.

I noticed that fact while porting recipes to conan 2.0 just recently. What is the rational behind removing this feature and what would be the migration path?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants