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

find_program working when building from command line, but not when using the CLion Conan plugin #624

Open
rturrado opened this issue Mar 10, 2024 · 11 comments
Assignees

Comments

@rturrado
Copy link

Hi there!

I have this project, libqasm, which is doing:

def build_requirements(self):
    self.tool_requires("tree-gen/1.0.6")

at conanfile.py. Later on, at CMakeLists.txt, it tries to find a package, and a binary exported by that package:

find_package(tree-gen 1.0.6 REQUIRED)
find_program(TREE_GEN_EXECUTABLE tree-gen REQUIRED)

The logs show that the package is found, but not the binary:

-- CMake-Conan: find_package(tree-gen) found, 'conan install' already ran
-- Conan: Target declared 'tree-gen::tree-gen'
-- Conan: Including build module from '/home/rturrado/.conan2/p/b/tree-3b20ed43700df/p/lib/cmake/generate_tree.cmake'
CMake Error at src/CMakeLists.txt:86 (find_program):
  Could not find TREE_GEN_EXECUTABLE using the following names: tree-gen

However, the binary is correctly found when building from the command line.

These are my CMake options (CLion > CMake tab > Settings):

-DCMAKE_PROJECT_TOP_LEVEL_INCLUDES="conan_provider.cmake" -DCONAN_HOST_PROFILE="default;auto-cmake;/mnt/e/Programacion/code/c++/libqasm/conan/profiles/tests-debug" -DLIBQASM_BUILD_TESTS=ON -DLIBQASM_COMPAT=ON -DASAN_ENABLED=ON -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++

May I be missing something from the CLion Conan configuration, a path where to search for the executable or something?

Many thanks!

@memsharded memsharded self-assigned this Mar 11, 2024
@memsharded
Copy link
Member

Hi @rturrado

Thanks for your report.

I am not sure what would be the difference. What command line without CLion are you using?

The main difference could be if using the CMakeToolchain somehow, but if you are using CMAKE_PROJECT_TOP_LEVEL_INCLUDES="conan_provider.cmake" in the command line, it should behave the same.

If you are using conan install + cmake --preset on the command line, that would explain, because the presets use the generated conan_toolchain.cmake and that toolchain defines the necessary paths so find_program() finds executables.

@rturrado
Copy link
Author

Hi @memsharded ,

Thanks for your quick reply. For the command line, I'm just building with conan build . <profile(s)> -b missing. For example:

conan build . -pr:a=conan/profiles/tests-debug -b missing

@memsharded
Copy link
Member

That explains the behavior.

The conan build uses the full CMakeToolchain with the conan_toolchain.cmake, etc, that contains those paths so find_program() is found.

So this would be a cmake-conan issue, if it is possible or not to have find_program() work for tool-requires transparently.

To reproduce, you can run in the command line with -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES argument, and it should be the same, so not specifically a CLion plugin issue.

I am moving this to cmake-conan repo, thanks.

@memsharded memsharded transferred this issue from conan-io/conan-clion-plugin Mar 11, 2024
@memsharded
Copy link
Member

@jcar87 maybe we want to consider adding CMAKE_PROGRAM_PATH definition to the provider?

@rturrado
Copy link
Author

Actually, I also do self.requires("tree-gen/1.0.6").

Excuse me, how can I pass that -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES on to conan build?

@memsharded
Copy link
Member

Excuse me, how can I pass that -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES on to conan build?

It is not passed to Conan, but to cmake -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=...

@rturrado
Copy link
Author

rturrado commented Mar 11, 2024

Well, this command line indeed reproduces the issue:

cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES="conan_provider.cmake" -DCONAN_HOST_PROFILE="default;auto-cmake;/mnt/e/Programacion/code/c++/libqasm/conan/profiles/tests-debug-compat" -DLIBQASM_BUILD_TESTS=ON -DLIBQASM_COMPAT=ON -DASAN_ENABLED=OFF

I basically copied what I had in the CLion CMake settings (see screenshot attached), and added the CMAKE_BUILD_TYPE.

CLionCMakeSettings

Thanks for your help @memsharded !

@memsharded
Copy link
Member

Yes, exactly, the CLion plugin uses the cmake-conan integration, so this is why I moved this to this project.

@jcar87
Copy link
Contributor

jcar87 commented Mar 12, 2024

Hi @rturrado - thanks for reporting this. This is listed as one of the current limitations in the Readme, however we are currently working to implement support for this in #626

@rturrado
Copy link
Author

rturrado commented Mar 12, 2024

Many thanks guys! Great work. I also noticed (quite some time ago) that you had fixed another issue I was experiencing with the CLion Conan plugin (the one that forced you to comment out the deps = CMakeDeps(self); deps.generate() lines in def generate(self) in conanfile.py).

@jcar87
Copy link
Contributor

jcar87 commented Mar 12, 2024

Indeed we have :) Thanks for reporting these things - little by little this integration is proving to be robust :D

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

No branches or pull requests

3 participants