Open maichmueller opened 2 days ago
Hi @maichmueller
Thanks for your feedback.
I am not sure what could be happening, but there are some things that I don't understand:
My cmake setup of the lib functions as expected, here is the install log:
There shouldn't be a install log at all. When packages are used in editable
mode, they are not installed, but used from the "build" tree directly, so the package()
method or cmake --install
shouldn't be called at all.
conan test . "mimir/[*]"
Not sure why doing this. When the package is in editable mode, it can be enough to do a conan create .
cmake -S . -B build ...
This is confusing too, it seems to be using the cmake-conan
over the test_package
? The test_package
is not intended to be used as a regular Conan conanfile.py, because it contains a self.requires(self.tested_reference_str)
that evaluates to None
if not managed by Conan.
The best to understand what could be missing is to have a fully reproducible case, with the exact commands to reproduce. Either with code in a github repo, or using a conan new cmake_lib
template, which contains the equivalent to self.cpp_info.libs = ["mimir"]
. Thanks for your feedback.
Hi @memsharded ,
I only did the manual cmake --install ...
and cmake -S ....
configuration commands to contrast it with the conan steps. These steps are NOT done by conan but by myself, to show that the cmake configuration of my project is working as intended!
To clarify this part, this is the dependency graph of the testpkg:
test_package
--> mimir
--> boost,range-v3,cista,...
I am trying to exclude a faulty cmake config on my side and show that I CAN use my project's (mimir) configuration as a cmake dependency for another consuming cmake package (without relying on its conanfile yet!). So to have the dependencies of mimir available in cmake (boost, range-v3 etc) I merely prefix the path of the conan generated deps for conan install mimir
. If I didn't do this, then the call find_package(mimir)
in test_package
would fail to find boost and so on.
Overall, my cmake configuration (mimirConfig.cmake
, mimirTargets.cmake
, etc...) appears to be correct and working as can be seen in the logs of cmake -S ...
. How my lib is installed is also shown in the log of cmake --install ...
, it is a default cmake installation. This leads me to believe that the error must lie with conan/my conanfile setup/my conan testing procedure.
Not sure why doing this. When the package is in editable mode, it can be enough to do a conan create .
Not sure what the confusing part is, I am following the conan docs on how to test: conan test test_package hello/1.0
(only replace test_package with .
since i am in inside the directory and hello/1.0
with mimir/*
).
Am I misunderstanding how conan editable packages work? My understanding was:
1) I declare mimir
as editable conan editable add .
Now conan is aware of changes in mimir.
2) NOT DONE BEFORE: Build the package conan create .
(I haven't done this step before. But I just tested with calling this first, before conan test
, and it doesn't change the outcome).
3) Build mimir: conan build .
(inside mimir).
3) I want to see if mimir can be consumed so I use the docs' test_package conanfile and run conan test . mimir/[*]
. This should proceed and work (it doesn't). Any changes made in mimir should be reflected here.
I am trying to exclude a faulty cmake config on my side and show that I CAN use my project's (mimir) configuration as a cmake dependency for another consuming cmake package (without relying on its conanfile yet!).
That is what was confusing to me. For the conan editable
flow, the CMake install
functionality is not involved at all.
Lets try to do things with something that I can reproduce from my side (with COnan 2.9):
conan new cmake_lib
# this uses cmake_layout()
and cpp_info.libs = ["mypkg"]
conan editable add .
conan build .
cd test_package
conan test . mypkg/0.1
This works on my side, can you please check?
Note that what you need to pass to conan test
is not the version range but the actual version to test.
That is what was confusing to me. For the conan editable flow, the CMake install functionality is not involved at all.
I did not know this. I expected that conan would do an 'on-the-fly' install into a local build to provide the dependency to test_package. (not needing a working cmake install is actually a great feature btw)
I just tried your steps and they work for me:
conan new cmake_lib -d name=mypkg -d version=0.0.1
File saved: CMakeLists.txt
File saved: conanfile.py
File saved: include/mypkg.h
File saved: src/mypkg.cpp
File saved: test_package/CMakeLists.txt
File saved: test_package/conanfile.py
File saved: test_package/src/example.cpp
/tmp conan editable add .
Reference 'mypkg/0.0.1' in editable mode
/tmp conan build .
/tmp/test_package conan test . mypkg/0.0.1
Note that what you need to pass to conan test is not the version range but the actual version to test.
It seems that this is not correct (or maybe it works as long as there is only 1 version available?)
/tmp/test_package conan test . 'mypkg/[*]'
I did not know this. I expected that conan would do an 'on-the-fly' install into a local build to provide the dependency to test_package. (not needing a working cmake install is actually a great feature btw)
yes, exactly, the way cmake_layout()
(and other layout() implementations) is that it defines the self.cpp.source
and self.cpp.build
information to represent the "build-tree" information, without needing to install the artifacts.
It seems that this is not correct (or maybe it works as long as there is only 1 version available?)
yes, maybe that is the case, the recommendation would be to give it the version to test
So, if the basic cmake_lib
flow works, then we would need to check what could be different. Could you please try to come up with a similar flow with your conanfile.py
that reproduce your case? If it is open source, feel free to share a link so we can check.
Describe the bug
Hi,
I have set my package into editable mode and tried to test the package with the sample test_package from the docs (https://docs.conan.io/2/tutorial/creating_packages/test_conan_packages.html) My package (not the test-one) conanfile reads:
My cmake setup of the lib functions as expected, here is the install log:
but it fails to test out with conan:
conan test . "mimir/[*]"
``` conan test . "mimir/[*]" ======== Input profiles ======== Profile host: [settings] arch=x86_64 build_type=Release compiler=gcc compiler.cppstd=gnu20 compiler.libcxx=libstdc++11 compiler.version=12 os=Linux Profile build: [settings] arch=x86_64 build_type=Release compiler=gcc compiler.cppstd=gnu20 compiler.libcxx=libstdc++11 compiler.version=12 os=Linux ======== Launching test_package ======== ======== Computing dependency graph ======== Graph root mimir/[*] (test package): /work/rleap1/michael.aichmueller/github/mimir/tests/integration/conanfile.py Requirements benchmark/1.9.0#ad992fd28f453d1f895d32b2ba576892 - Cache boost/1.86.0#cd839a2082585255010f9e82eea94c7f - Cache bzip2/1.0.8#457c272f7da34cb9c67456dd217d36c4 - Cache cista/2024.10.22#eda1c95cbe7794af648edcf809619f82 - Cache fmt/11.0.2#5c7438ef4d5d69ab106a41e460ce11f3 - Cache gtest/1.15.0#9eb07f548819215e766e41399858454f - Cache loki/0.0.6#c4a43b9e86b06a86b060ed7d90f34a7a - Cache mimir/0.1.0.dev - Editable nauty/2.8.8#f28e1ededef9f279fbf1d9a59fa21892 - Cache pybind11/2.13.6#7d301b76bc1a308a51b506dd2de145b0 - Cache range-v3/0.12.0#4c05d91d7b40e6b91b44b5345ac64408 - Cache zlib/1.3.1#f52e03ae3d251dec704634230cd806a2 - Cache Build requirements b2/5.2.1#91bc73931a0acb655947a81569ed8b80 - Cache cmake/3.30.5#540068cc37f1d21b42b729c82d6bcb29 - Cache Resolved version ranges b2/[>=5.2 <6]: b2/5.2.1 boost/[>=1.74.0]: boost/1.86.0 cmake/[>=3.16.3 <4]: cmake/3.30.5 mimir/[*]: mimir/0.1.0.dev zlib/[>=1.2.11 <2]: zlib/1.3.1 ======== Computing necessary packages ======== fmt/11.0.2: Main binary package 'd40b5c725566ec903e3c928e9c4e6f17b04f1d30' missing fmt/11.0.2: Checking 9 compatible configurations fmt/11.0.2: Found compatible package '9a065abcb87fdca997b519cd3122b64a0d435483': compiler.cppstd=20 benchmark/1.9.0: Main binary package '359eb291b2c32efebe094b078732203ee7afa54d' missing benchmark/1.9.0: Checking 7 compatible configurations benchmark/1.9.0: Found compatible package '854ea57089d9f4ae566b7fd9f4f1573d16ecf782': compiler.cppstd=20 Requirements benchmark/1.9.0#ad992fd28f453d1f895d32b2ba576892:854ea57089d9f4ae566b7fd9f4f1573d16ecf782#6d175435a79cc018c2f27bc9b121a612 - Cache boost/1.86.0#cd839a2082585255010f9e82eea94c7f:50c9f7b2d8a1603abca068b33e2c0f78778a4b9e#8179ca9f5f8ad6d65a8dc5245433743d - Cache bzip2/1.0.8#457c272f7da34cb9c67456dd217d36c4:4530633a3406a354d9c70a71124250144067de22#9a9214178cf9d49820bac01bd07c7253 - Cache cista/2024.10.22#eda1c95cbe7794af648edcf809619f82:a1832936ceafdd5da6f5e7d9aa90cd2270ac0b76#0effc2ed056dffdc58162188b1b2c370 - Cache fmt/11.0.2#5c7438ef4d5d69ab106a41e460ce11f3:9a065abcb87fdca997b519cd3122b64a0d435483#7dd291302c7365c837104baa3a3a3206 - Cache gtest/1.15.0#9eb07f548819215e766e41399858454f:f7ae24f4eedc110c20ab741b949bc222fd459f2a#2af99b049fc858d9f4db5947c14d9ece - Cache loki/0.0.6#c4a43b9e86b06a86b060ed7d90f34a7a:08b724bd1ccff70287b8351da8544982c4d6d0a3#e4594e0ed7cd6f358ea8094bf7529573 - Cache mimir/0.1.0.dev:db571c7cedf5bd170883b805ba81fa1313e51e11 - Editable nauty/2.8.8#f28e1ededef9f279fbf1d9a59fa21892:bfac7a3a9a2e30209faf49d0b9f927f51f9103fc#620f60c8cf8b28ded596a525c90b48c5 - Cache pybind11/2.13.6#7d301b76bc1a308a51b506dd2de145b0:da39a3ee5e6b4b0d3255bfef95601890afd80709#9d289186dc0b30c7d92df3b5a8f27a74 - Cache range-v3/0.12.0#4c05d91d7b40e6b91b44b5345ac64408:da39a3ee5e6b4b0d3255bfef95601890afd80709#ecc6172c3cd6694c36d1cd98a702deb0 - Cache zlib/1.3.1#f52e03ae3d251dec704634230cd806a2:5bc851010eb7b707e5cb2e24cb8ccf0f27989fa9#1f2bf5ee2729436fb0efb04e98b58860 - Cache Build requirements Skipped binaries b2/5.2.1, cmake/3.30.5 ======== Installing packages ======== bzip2/1.0.8: Already installed! (1 of 12) fmt/11.0.2: Already installed! (2 of 12) gtest/1.15.0: Already installed! (3 of 12) nauty/2.8.8: Already installed! (4 of 12) pybind11/2.13.6: Already installed! (5 of 12) range-v3/0.12.0: Already installed! (6 of 12) zlib/1.3.1: Already installed! (7 of 12) benchmark/1.9.0: Already installed! (8 of 12) boost/1.86.0: Already installed! (9 of 12) cista/2024.10.22: Already installed! (10 of 12) loki/0.0.6: Already installed! (11 of 12) mimir/0.1.0.dev: Rewriting files of editable package 'mimir' at '/work/rleap1/michael.aichmueller/github/mimir/build/Release/generators' mimir/0.1.0.dev: Writing generators to /work/rleap1/michael.aichmueller/github/mimir/build/Release/generators mimir/0.1.0.dev: Generator 'CMakeDeps' calling 'generate()' mimir/0.1.0.dev: CMakeDeps necessary find_package() and targets for your CMakeLists.txt find_package(range-v3) find_package(GTest) find_package(pybind11) find_package(benchmark) find_package(cista) find_package(fmt) find_package(nauty) find_package(loki) find_package(Boost) target_link_libraries(... range-v3::range-v3 gtest::gtest pybind11_all_do_not_use benchmark::benchmark_main cista::cista fmt::fmt nauty::nauty loki::loki boost::boost) mimir/0.1.0.dev: Calling generate() mimir/0.1.0.dev: Generators folder: /work/rleap1/michael.aichmueller/github/mimir/build/Release/generators mimir/0.1.0.dev: CMakeToolchain generated: conan_toolchain.cmake mimir/0.1.0.dev: CMakeToolchain generated: /work/rleap1/michael.aichmueller/github/mimir/build/Release/generators/CMakePresets.json mimir/0.1.0.dev: Generating aggregated env files mimir/0.1.0.dev: Generated aggregated env files: ['conanbuild.sh', 'conanrun.sh'] WARN: deprecated: Usage of deprecated Conan 1.X features that will be removed in Conan 2.X: WARN: deprecated: 'cpp_info.names' used in: fmt/11.0.2, range-v3/0.12.0, zlib/1.3.1, boost/1.86.0, bzip2/1.0.8, pybind11/2.13.6, gtest/1.15.0 WARN: deprecated: 'cpp_info.build_modules' used in: pybind11/2.13.6, bzip2/1.0.8 WARN: deprecated: 'env_info' used in: bzip2/1.0.8, boost/1.86.0 WARN: deprecated: 'cpp_info.filenames' used in: boost/1.86.0 WARN: deprecated: 'user_info' used in: boost/1.86.0 WARN: The package created was 'mimir/0.1.0.dev' but the reference being tested is 'mimir/[*]' ======== Testing the package ======== Removing previously existing 'test_package' build folder: /work/rleap1/michael.aichmueller/github/mimir/tests/integration/build/gcc-12-x86_64-gnu20-release mimir/[*] (test package): Test package build: build/gcc-12-x86_64-gnu20-release mimir/[*] (test package): Test package build folder: /work/rleap1/michael.aichmueller/github/mimir/tests/integration/build/gcc-12-x86_64-gnu20-release mimir/[*] (test package): Writing generators to /work/rleap1/michael.aichmueller/github/mimir/tests/integration/build/gcc-12-x86_64-gnu20-release/generators mimir/[*] (test package): Generator 'CMakeDeps' calling 'generate()' mimir/[*] (test package): CMakeDeps necessary find_package() and targets for your CMakeLists.txt find_package(mimir) target_link_libraries(... mimir::mimir) mimir/[*] (test package): Generator 'CMakeToolchain' calling 'generate()' mimir/[*] (test package): CMakeToolchain generated: conan_toolchain.cmake mimir/[*] (test package): CMakeToolchain generated: /work/rleap1/michael.aichmueller/github/mimir/tests/integration/build/gcc-12-x86_64-gnu20-release/generators/CMakePresets.json mimir/[*] (test package): CMakeToolchain generated: /work/rleap1/michael.aichmueller/github/mimir/tests/integration/CMakeUserPresets.json mimir/[*] (test package): Generating aggregated env files mimir/[*] (test package): Generated aggregated env files: ['conanbuild.sh', 'conanrun.sh'] ======== Testing the package: Building ======== mimir/[*] (test package): Calling build() mimir/[*] (test package): Running CMake.configure() mimir/[*] (test package): RUN: cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="/work/rleap1/michael.aichmueller/github/mimir/tests/integration" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Release" "/work/rleap1/michael.aichmueller/github/mimir/tests/integration" -- Using Conan toolchain: /work/rleap1/michael.aichmueller/github/mimir/tests/integration/build/gcc-12-x86_64-gnu20-release/generators/conan_toolchain.cmake -- Conan toolchain: Defining architecture flag: -m64 -- Conan toolchain: C++ Standard 20 with extensions ON -- The C compiler identification is GNU 11.4.0 -- The CXX compiler identification is GNU 11.4.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /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: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Conan: Target declared 'mimir::mimir' CMake Error at build/gcc-12-x86_64-gnu20-release/generators/cmakedeps_macros.cmake:67 (message): Library 'mimir' not found in package. If 'mimir' is a system library, declare it with 'cpp_info.system_libs' property Call Stack (most recent call first): build/gcc-12-x86_64-gnu20-release/generators/mimir-Target-release.cmake:23 (conan_package_library_targets) build/gcc-12-x86_64-gnu20-release/generators/mimirTargets.cmake:24 (include) build/gcc-12-x86_64-gnu20-release/generators/mimir-config.cmake:16 (include) CMakeLists.txt:24 (find_package) -- Configuring incomplete, errors occurred! ERROR: mimir/[*] (test package): Error in build() method, line 17 cmake.configure() ConanException: Error 1 while executing ```If I install my lib and then run cmake on the test-project manually by providing the conan deps per prefix-path, I can get my test project to compile fine.
cmake -S . -B build ...
``` cmake -S . -B build -DCMAKE_PREFIX_PATH="$(pwd)"/../../build/conan/build/Release/generators;"$(pwd)"/../../install -DCMAKE_BUILD_TYPE=Release -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=$(pwd)/../../conan_provider.cmake -- CMake-Conan: first find_package() found. Installing dependencies with Conan -- CMake-Conan: Checking if a default profile exists /u/michael.aichmueller/.conan2/profiles/default -- CMake-Conan: cmake_system_name=Linux -- CMake-Conan: cmake_system_processor=x86_64 -- CMake-Conan: CMake compiler=GNU -- CMake-Conan: CMake compiler version=11.4.0 -- CMake-Conan: [settings] compiler=gcc -- CMake-Conan: [settings] compiler.version=11 -- CMake-Conan: Creating profile /work/rleap1/michael.aichmueller/github/mimir/tests/integration/build/conan_host_profile -- CMake-Conan: Profile: [settings] arch=x86_64 os=Linux compiler=gcc compiler.version=11 compiler.cppstd=20 compiler.libcxx=libstdc++11 build_type=Release [conf] tools.cmake.cmaketoolchain:generator=Unix Makefiles tools.build:compiler_executables={"c":"/usr/bin/cc","cpp":"/usr/bin/c++"} -- CMake-Conan: Installing single configuration Release -- CMake-Conan: conan install /work/rleap1/michael.aichmueller/github/mimir/tests/integration -of=/work/rleap1/michael.aichmueller/github/mimir/tests/integration/build/conan --profile:host=default;--profile:host=/work/rleap1/michael.aichmueller/github/mimir/tests/integration/build/conan_host_profile;--profile:build=default;--build=missing ======== Input profiles ======== Profile host: [settings] arch=x86_64 build_type=Release compiler=gcc compiler.cppstd=20 compiler.libcxx=libstdc++11 compiler.version=11 os=Linux [conf] tools.build:compiler_executables={'c': '/usr/bin/cc', 'cpp': '/usr/bin/c++'} tools.cmake.cmaketoolchain:generator=Unix Makefiles Profile build: [settings] arch=x86_64 build_type=Release compiler=gcc compiler.cppstd=gnu20 compiler.libcxx=libstdc++11 compiler.version=12 os=Linux ======== Computing dependency graph ======== Graph root conanfile.py: /work/rleap1/michael.aichmueller/github/mimir/tests/integration/conanfile.py ======== Computing necessary packages ======== ======== Installing packages ======== ======== Finalizing install (deploy, generators) ======== conanfile.py: Writing generators to /work/rleap1/michael.aichmueller/github/mimir/tests/integration/build/conan/build/Release/generators conanfile.py: Generator 'CMakeDeps' calling 'generate()' conanfile.py: Generator 'CMakeToolchain' calling 'generate()' conanfile.py: CMakeToolchain generated: conan_toolchain.cmake conanfile.py: CMakeToolchain: Preset 'conan-release' added to CMakePresets.json. (cmake>=3.23) cmake --preset conan-release (cmake<3.23) cmakeIs my cpp_info.libs configuration perhaps wrong?
How to reproduce it
No response