conan: [bug] Conan 1.37.2 CMakeDeps generator does not bootstrap package's own CMake config file

Environment Details (include every applicable attribute)

  • Operating System+version: macOS Catalina
  • Compiler+version: n/a
  • Conan version: 1.37.2
  • Python version: 3.9.5

Problem

The new CMakeDeps generator behaviour generates generic CMake *Config.cmake etc files from the Conan recipes for the external libraries that are specified as dependencies. What if a library provide its own *Config.cmake file(s)? It seems that the CMakeDeps generator does not defer to that. I would expect the generator to generate the typical files for Conan, but then also still defer/include/execute the package’s original *Config.cmake file(s).

Also, if there is any bootstrapping that needs to occur for said external library and this logic is embedded and shipped with the external library’s package, how should that be accessed /executed using the CMakeDeps generator. For past generators like find_package, it generates a Find<packagename>.cmake file, but this still had the functionality to include the build module if specified via self.cpp_info.build_modules[] in the recipe method package_info() for the library. Adding self.cpp_info.build_modules["CMakeDeps"].append(...) does not seem to make any difference for the CMakeDeps generator.

Steps to reproduce

Step 1

Clone this repo to get a Conan package (in a sub-folder of this repo) that only contains CMake files that you will install into your local cache. https://github.com/SeanSnyders/TestExamples.git

Step 2

Then use the gist below that is a recipe that depends on the package above that you installed. This recipe uses the Conan helloworld example as source code, and patches it to suit this test. https://gist.github.com/SeanSnyders/30f73a76736864977bd88c0212f55fd7

Try to build this package for this gist and it’ll fail because it cannot find a CMake utility file that it wants to include that is part of the first package above.

It fails because to illustrate the problem, this dependent library sets a variable CMAKE_PURECMAKEPACKAGE_PACKAGE_PATH which is defined in the library’s own CMake config file. Conan does not seem to include this, thus this variable is not defined, and thus the 2nd package could not be built.

Logs (Executed commands with output)

Step 1

mkdir temp && cd temp
git clone https://github.com/SeanSnyders/TestExamples.git
cd TestExamples/PureCMakePackage
conan export . ssnyder/testing

image

Step 2

Download gist specified above into new folder, then

conan export . ssnyder/testing

image

Then build and install this package into the local cache

conan install ConanCMakeDepsGenerator/0.1.0@ssnyder/testing --build=ConanCMakeDepsGenerator -s build_type=Debug  --build missing

image

Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Debug
compiler=apple-clang
compiler.libcxx=libc++
compiler.version=12.0
os=Macos
os_build=Macos
[options]
[build_requires]
[env]

ConanCMakeDepsGenerator/0.1.0@ssnyder/testing: Forced build from source
ConanCMakeDepsGenerator/0.1.0@ssnyder/testing: Generators in TestRecipe.build_requirements(): ('CMakeDeps', 'cmake_paths', 'virtualenv')
ConanCMakeDepsGenerator/0.1.0@ssnyder/testing: self.build_requires=<class 'conans.client.graph.graph_manager._RecipeBuildRequires'>
ConanCMakeDepsGenerator/0.1.0@ssnyder/testing: self.build_requires=cmake/3.19.4 (host), gtest/1.10.0 (host), PureCMakePackage/0.1.0@ssnyder/testing (host)
Installing package: ConanCMakeDepsGenerator/0.1.0@ssnyder/testing
Requirements
    ConanCMakeDepsGenerator/0.1.0@ssnyder/testing from local cache - Cache
Packages
    ConanCMakeDepsGenerator/0.1.0@ssnyder/testing:0458ed5e3c5080307ca8a3bae7bab3c04f2768cc - Build
Build requirements
    PureCMakePackage/0.1.0@ssnyder/testing from local cache - Cache
    cmake/3.19.4 from 'conan-center' - Cache
    gtest/1.10.0 from 'conan-center' - Cache
    openssl/1.1.1i from 'conan-center' - Cache
Build requirements packages
    PureCMakePackage/0.1.0@ssnyder/testing:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 - Build
    cmake/3.19.4:8780864092a6c58a5f5d385d2da47db0f418446d - Cache
    gtest/1.10.0:8ea16b5437d767794f13beec66099d7352875d19 - Cache
    openssl/1.1.1i:d98fae1010d1fb9e7f79a1e8a72bbf129d8660a2 - Cache

Installing (downloading, building) binaries...
PureCMakePackage/0.1.0@ssnyder/testing: Configuring sources in /Users/ssnyder/.conan/data/PureCMakePackage/0.1.0/ssnyder/testing/source
PureCMakePackage/0.1.0@ssnyder/testing: Copying sources to build folder
PureCMakePackage/0.1.0@ssnyder/testing: Building your package in /Users/ssnyder/.conan/data/PureCMakePackage/0.1.0/ssnyder/testing/build/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9
PureCMakePackage/0.1.0@ssnyder/testing: Generator txt created conanbuildinfo.txt
PureCMakePackage/0.1.0@ssnyder/testing: Calling build()
PureCMakePackage/0.1.0@ssnyder/testing: Running build in ConanRecipe...
PureCMakePackage/0.1.0@ssnyder/testing: Package '5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9' built
PureCMakePackage/0.1.0@ssnyder/testing: Build folder /Users/ssnyder/.conan/data/PureCMakePackage/0.1.0/ssnyder/testing/build/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9
PureCMakePackage/0.1.0@ssnyder/testing: Generated conaninfo.txt
PureCMakePackage/0.1.0@ssnyder/testing: Generated conanbuildinfo.txt
PureCMakePackage/0.1.0@ssnyder/testing: Generating the package
PureCMakePackage/0.1.0@ssnyder/testing: Package folder /Users/ssnyder/.conan/data/PureCMakePackage/0.1.0/ssnyder/testing/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9
PureCMakePackage/0.1.0@ssnyder/testing: Calling package()
PureCMakePackage/0.1.0@ssnyder/testing: Running package in ConanRecipe...
PureCMakePackage/0.1.0@ssnyder/testing package(): Packaged 2 '.cmake' files: PureCMakePackageConfig.cmake, Utils.cmake
PureCMakePackage/0.1.0@ssnyder/testing: Package '5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9' created
PureCMakePackage/0.1.0@ssnyder/testing: Created package revision b6387e11d78d612393aa2871ebe6c586
PureCMakePackage/0.1.0@ssnyder/testing: Running package_info in ConanRecipe...
gtest/1.10.0: Already installed!
openssl/1.1.1i: Already installed!
cmake/3.19.4: Already installed!
cmake/3.19.4: Appending PATH environment variable: /Users/ssnyder/.conan/data/cmake/3.19.4/_/_/package/8780864092a6c58a5f5d385d2da47db0f418446d/bin
ConanCMakeDepsGenerator/0.1.0@ssnyder/testing: Applying build-requirement: cmake/3.19.4
ConanCMakeDepsGenerator/0.1.0@ssnyder/testing: Applying build-requirement: gtest/1.10.0
ConanCMakeDepsGenerator/0.1.0@ssnyder/testing: Applying build-requirement: PureCMakePackage/0.1.0@ssnyder/testing
ConanCMakeDepsGenerator/0.1.0@ssnyder/testing: Applying build-requirement: openssl/1.1.1i
ConanCMakeDepsGenerator/0.1.0@ssnyder/testing: Configuring sources in /Users/ssnyder/.conan/data/ConanCMakeDepsGenerator/0.1.0/ssnyder/testing/source
ConanCMakeDepsGenerator/0.1.0@ssnyder/testing: Getting source in TestRecipe.source()....
ConanCMakeDepsGenerator/0.1.0@ssnyder/testing: Copying sources to build folder
ConanCMakeDepsGenerator/0.1.0@ssnyder/testing: Building your package in /Users/ssnyder/.conan/data/ConanCMakeDepsGenerator/0.1.0/ssnyder/testing/build/0458ed5e3c5080307ca8a3bae7bab3c04f2768cc
ConanCMakeDepsGenerator/0.1.0@ssnyder/testing: Generator virtualenv created activate.ps1
ConanCMakeDepsGenerator/0.1.0@ssnyder/testing: Generator virtualenv created deactivate.ps1
ConanCMakeDepsGenerator/0.1.0@ssnyder/testing: Generator virtualenv created environment.ps1.env
ConanCMakeDepsGenerator/0.1.0@ssnyder/testing: Generator virtualenv created activate.sh
ConanCMakeDepsGenerator/0.1.0@ssnyder/testing: Generator virtualenv created deactivate.sh
ConanCMakeDepsGenerator/0.1.0@ssnyder/testing: Generator virtualenv created environment.sh.env
ConanCMakeDepsGenerator/0.1.0@ssnyder/testing: Generator cmake_paths created conan_paths.cmake
ConanCMakeDepsGenerator/0.1.0@ssnyder/testing: Generator 'CMakeDeps' calling 'generate()'
ConanCMakeDepsGenerator/0.1.0@ssnyder/testing: Calling generate()
ConanCMakeDepsGenerator/0.1.0@ssnyder/testing: Running generate in TestRecipe...
ConanCMakeDepsGenerator/0.1.0@ssnyder/testing: Calling build()
ConanCMakeDepsGenerator/0.1.0@ssnyder/testing: cmake.defs: OrderedDict([('CMAKE_BUILD_TYPE', 'Debug'), ('CMAKE_OSX_ARCHITECTURES', 'x86_64'), ('CMAKE_OSX_SYSROOT', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk'), ('CONAN_IN_LOCAL_CACHE', 'ON'), ('CONAN_COMPILER', 'apple-clang'), ('CONAN_COMPILER_VERSION', '12.0'), ('CONAN_CXX_FLAGS', '-m64'), ('CONAN_SHARED_LINKER_FLAGS', '-m64'), ('CONAN_C_FLAGS', '-m64'), ('CONAN_LIBCXX', 'libc++'), ('CMAKE_INSTALL_PREFIX', '/Users/ssnyder/.conan/data/ConanCMakeDepsGenerator/0.1.0/ssnyder/testing/package/0458ed5e3c5080307ca8a3bae7bab3c04f2768cc'), ('CMAKE_INSTALL_BINDIR', 'bin'), ('CMAKE_INSTALL_SBINDIR', 'bin'), ('CMAKE_INSTALL_LIBEXECDIR', 'bin'), ('CMAKE_INSTALL_LIBDIR', 'lib'), ('CMAKE_INSTALL_INCLUDEDIR', 'include'), ('CMAKE_INSTALL_OLDINCLUDEDIR', 'include'), ('CMAKE_INSTALL_DATAROOTDIR', 'share'), ('CMAKE_PREFIX_PATH', '/Users/ssnyder/.conan/data/ConanCMakeDepsGenerator/0.1.0/ssnyder/testing/build/0458ed5e3c5080307ca8a3bae7bab3c04f2768cc'), ('CMAKE_MODULE_PATH', '/Users/ssnyder/.conan/data/ConanCMakeDepsGenerator/0.1.0/ssnyder/testing/build/0458ed5e3c5080307ca8a3bae7bab3c04f2768cc'), ('CMAKE_EXPORT_NO_PACKAGE_REGISTRY', 'ON'), ('CONAN_EXPORTED', '1'), ('CMAKE_VERBOSE_MAKEFILE', 'ON')])
-- The C compiler identification is AppleClang 12.0.0.12000032
-- The CXX compiler identification is AppleClang 12.0.0.12000032
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Conan: Component target declared 'GTest::gtest'
-- Conan: Component target declared 'GTest::gtest_main'
-- Conan: Component target declared 'GTest::gmock'
-- Conan: Component target declared 'GTest::gmock_main'
-- Conan: Target declared 'GTest::GTest'
-- Conan: Target declared 'PureCMakePackage::PureCMakePackage'
-- PureCMakePackage PureCMakePackage_PACKAGE_FOLDER_RELEASE=
-- PureCMakePackage PureCMakePackage_PACKAGE_FOLDER_DEBUG=/Users/ssnyder/.conan/data/PureCMakePackage/0.1.0/ssnyder/testing/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9
-- PureCMakePackage CMAKE_PURECMAKEPACKAGE_PACKAGE_PATH=
CMake Error at CMakeLists.txt:9 (include):
  include could not find load file:

    /utils/Utils.cmake


-- Configuring incomplete, errors occurred!
See also "/Users/ssnyder/.conan/data/ConanCMakeDepsGenerator/0.1.0/ssnyder/testing/build/0458ed5e3c5080307ca8a3bae7bab3c04f2768cc/CMakeFiles/CMakeOutput.log".
ConanCMakeDepsGenerator/0.1.0@ssnyder/testing: 
ConanCMakeDepsGenerator/0.1.0@ssnyder/testing: ERROR: Package '0458ed5e3c5080307ca8a3bae7bab3c04f2768cc' build failed
ConanCMakeDepsGenerator/0.1.0@ssnyder/testing: WARN: Build folder /Users/ssnyder/.conan/data/ConanCMakeDepsGenerator/0.1.0/ssnyder/testing/build/0458ed5e3c5080307ca8a3bae7bab3c04f2768cc
ERROR: ConanCMakeDepsGenerator/0.1.0@ssnyder/testing: Error in build() method, line 52
	cmake = self._configure_cmake()
while calling '_configure_cmake', line 48
	self._cmake.configure(source_folder="./hello")
	ConanException: Error 1 while executing cd '/Users/ssnyder/.conan/data/ConanCMakeDepsGenerator/0.1.0/ssnyder/testing/build/0458ed5e3c5080307ca8a3bae7bab3c04f2768cc' && cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE="Debug" -DCMAKE_OSX_ARCHITECTURES="x86_64" -DCMAKE_OSX_SYSROOT="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk" -DCONAN_IN_LOCAL_CACHE="ON" -DCONAN_COMPILER="apple-clang" -DCONAN_COMPILER_VERSION="12.0" -DCONAN_CXX_FLAGS="-m64" -DCONAN_SHARED_LINKER_FLAGS="-m64" -DCONAN_C_FLAGS="-m64" -DCONAN_LIBCXX="libc++" -DCMAKE_INSTALL_PREFIX="/Users/ssnyder/.conan/data/ConanCMakeDepsGenerator/0.1.0/ssnyder/testing/package/0458ed5e3c5080307ca8a3bae7bab3c04f2768cc" -DCMAKE_INSTALL_BINDIR="bin" -DCMAKE_INSTALL_SBINDIR="bin" -DCMAKE_INSTALL_LIBEXECDIR="bin" -DCMAKE_INSTALL_LIBDIR="lib" -DCMAKE_INSTALL_INCLUDEDIR="include" -DCMAKE_INSTALL_OLDINCLUDEDIR="include" -DCMAKE_INSTALL_DATAROOTDIR="share" -DCMAKE_PREFIX_PATH="/Users/ssnyder/.conan/data/ConanCMakeDepsGenerator/0.1.0/ssnyder/testing/build/0458ed5e3c5080307ca8a3bae7bab3c04f2768cc" -DCMAKE_MODULE_PATH="/Users/ssnyder/.conan/data/ConanCMakeDepsGenerator/0.1.0/ssnyder/testing/build/0458ed5e3c5080307ca8a3bae7bab3c04f2768cc" -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" -DCMAKE_VERBOSE_MAKEFILE="ON" -Wno-dev '/Users/ssnyder/.conan/data/ConanCMakeDepsGenerator/0.1.0/ssnyder/testing/build/0458ed5e3c5080307ca8a3bae7bab3c04f2768cc/./hello'
ssnyder-nz-la1:ConanCMakeDepsGenerator ssnyder$ 

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 15 (6 by maintainers)

Most upvoted comments

@cboos we are going to move the check later and also will check that the actual complete target exists, not based on the internal XXX_COMPONENT_NAMES variable so probably it will work smoothly for you, if the Qt build module declares the target, it would be fine. It will be released at 1.39

@cboos your issue is totally different. We are evaluating the best way to keep your use case working. I’ll report back.