conan-io / conan-package-tools

Conan Package Tools. Helps with massive package creation and CI integration (Travis CI, Appveyor...)
MIT License
165 stars 70 forks source link

Build requirements not included in conan_paths.cmake #593

Open lbakman opened 2 years ago

lbakman commented 2 years ago

Description of Problem, Request, or Question

I am seing some different behaviour in conan_package_tools version 0.37.0 concerning build profile (CPT_PROFILE_BUILD) compared to version 0.36.0.

The CPT_PROFILE_BUILD is always specified when building a configuration. This seems to affect the cmake_paths generator.

When the CPT_PROFILE_BUILD environment is specified, the paths from my "build_requires" dependencies in the conanfile.py are no longer written to my conan_paths.cmake file.

In my case, this results in GTest no longer being found.

I have created two test projects to illustrate this:

My custom gtest recipe: https://github.com/lbakman/gtest_conan I have modified the gtest recipe from conan-center-index, because I want the cmake directory to stay in the output directory. For this test, build with "conan create . cci.20210126@lau/stable".

My consuming project: https://github.com/lbakman/hello_conan You can see the difference by executing the following docker commands. I have tried to find the minimal command line that can reproduce the problem on a local machine.

The following represents the docker command line I get from 0.36.0: docker run --rm -v "$HOME/.conan/data:/home/conan/.conan/data" -v "$(pwd):/home/conan/project" -e CONAN_USERNAME="lau" -e CONAN_CHANNEL="testing" -e CONAN_REFERENCE="world/1.0.0@lau/testing" -e CPT_PROFILE="@@include(default)@@@@[settings]@@arch=x86_64@@build_type=Release@@compiler=gcc@@compiler.libcxx=libstdc++11@@[options]@@@@[env]@@@@[build_requires]@@@@" -e CPT_BUILD_POLICY="missing" -e CPT_CONANFILE="conanfile.py" conanio/gcc8:latest /bin/sh -c "cd project; run_create_in_docker"

The following represents the docker command line I get from 0.37.0: docker run --rm -v "$HOME/.conan/data:/home/conan/.conan/data" -v "$(pwd):/home/conan/project" -e CONAN_USERNAME="lau" -e CONAN_CHANNEL="testing" -e CONAN_REFERENCE="world/1.0.0@lau/testing" -e CPT_PROFILE="@@include(default)@@@@[settings]@@arch=x86_64@@build_type=Release@@compiler=gcc@@compiler.libcxx=libstdc++11@@[options]@@@@[env]@@@@[build_requires]@@@@" -e CPT_PROFILE_BUILD="@@include(default)@@@@[settings]@@@@[options]@@@@[env]@@@@[build_requires]@@@@" -e CPT_BUILD_POLICY="missing" -e CPT_CONANFILE="conanfile.py" conanio/gcc8:latest /bin/sh -c "cd project; run_create_in_docker"

If you take a look at the generated conan_paths.cmake files from each build, you can see that in the first command line, GTEST is referenced in the file and in the second command line, it is not.

I can fix it by adding my build_requires to the build.py file in addition to my conanfile.py, but that seems counter intuitive to me.

Environment Details