conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
8.28k stars 981 forks source link

[bug] CMakeDeps: files in `cmake_build_modules` of build requirements listed in `build_context_activated` are not included in generated config files #14758

Open SpaceIm opened 1 year ago

SpaceIm commented 1 year ago

Environment details

Steps to reproduce

Logs

======== Testing the package: Building ========
btyacc/3.0 (test package): Calling build()
btyacc/3.0 (test package): Running CMake.configure()
btyacc/3.0 (test package): RUN: cmake -G "Ninja" -DCMAKE_TOOLCHAIN_FILE="/Users/spaceim/github-projects/conan-center-index/recipes/btyacc/all/test_package/build/macos-x86_64-apple-clang-14/Release/generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="/Users/spaceim/github-projects/conan-center-index/recipes/btyacc/all/test_package" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Release" "/Users/spaceim/github-projects/conan-center-index/recipes/btyacc/all/test_package"
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- Using Conan toolchain: /Users/spaceim/github-projects/conan-center-index/recipes/btyacc/all/test_package/build/macos-x86_64-apple-clang-14/Release/generators/conan_toolchain.cmake
-- Conan toolchain: C++ Standard 20 with extensions OFF
-- The C compiler identification is AppleClang 14.0.3.14030022
-- 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
-- Conan: Target declared 'btyacc::btyacc'
CMake Error at CMakeLists.txt:8 (message):
  BTYACC_EXECUTABLE is not defined

But in this generated config file, I can't see any include of the file defined in cmake_build_modules, leading to this error (CMakeLists of test package checks whether this variable is defined after find_package(btyacc REQUIRED CONFIG): https://github.com/conan-io/conan-center-index/blob/fd03d6808dda34c7488399e36b31e1b5d0306caf/recipes/btyacc/all/test_package/CMakeLists.txt#L6-L9)

SpaceIm commented 1 year ago

hum, I've missed https://docs.conan.io/1/reference/conanfile/tools/cmake/cmakedeps.html#build-context-build-modules.

But... why is it not automatic? Why consumers should have to know such internal details of their build requirements?

Indeed, files in cmake_build_modules are totally part of CMake config file logic, they are not optional stuff when you want to properly emulate upstream config file, it's not something consumers should opt-in, they shouldn't be even aware of that because it's just a trick of recipes to emulate custom config file logic.

franramirez688 commented 1 year ago

But... why is it not automatic? Why consumers should have to know such internal details of their build requirements?

Given that, I think that we could close this issue, and open another one to talk about whether we should include those build_context_build_modules automatically or not. Only to avoid users messing with different topics.