cmake-conan: conan_cmake_run fails when conan is installed locally (not system-wide)

CMake:

if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
    message(STATUS "Downloading conan.cmake from https://github.com/memsharded/cmake-conan")
    file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/master/conan.cmake"
            "${CMAKE_BINARY_DIR}/conan.cmake")
endif()

include(${CMAKE_BINARY_DIR}/conan.cmake)
conan_cmake_run(CONANFILE conanfile.txt  # or relative build/conanfile.txt
                BASIC_SETUP CMAKE_TARGETS
                BUILD missing)

Output:

-- Conan ** WARNING** : This detection of settings from cmake is experimental and incomplete. Please check 'conan.cmake' and contribute
-- Conan executing: conan install -f=/home/sztomi/Projects/MyCoolProject/conanfile.txt -g cmake -s build_type=Debug -s os=Linux -s compiler=gcc -s compiler.version=6.3 -s compiler.libcxx=libstdc++11 --build=missing
CMake Error at cmake-build-debug/conan.cmake:221 (message):
  Conan install failed='No such file or directory'
Call Stack (most recent call first):
  cmake-build-debug/conan.cmake:298 (conan_cmake_install)
  CMakeLists.txt:14 (conan_cmake_run)

However, when I run the same command from the command line, it works. Tried CMake 3.7 (bundled) and 3.8 with the same result.

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Comments: 19 (5 by maintainers)

Most upvoted comments

I ended up using sudo ln -s ~/.local/bin/conan /usr/bin/conan both methods work I didn’t know I could use the find_program outside the conan.cmake. I had a custom conan.cmake for a while where I was doing that.

Interestingly, it fails the same way in KDevelop. My guess is that the conan executable is not found because I don’t have it system-wide installed (I installed via pip install conan --user, so it lives in ~/.local/bin)

You shouldn’t need to edit conan.cmake for that to work, just place it in your projects root cmake file.

On Tue, May 24, 2022, 10:49 AM Robert Russell @.***> wrote:

I was using this but it required I alter the existing conan.cmake.

find_program(CONAN_BIN NAMES conan PATHS $ENV{HOME}/.local/bin) This I found was more useful in the long run. Thanks for the help. sudo ln -s ~/.local/bin/conan /usr/bin/conan

— Reply to this email directly, view it on GitHub https://github.com/conan-io/cmake-conan/issues/32#issuecomment-1136029485, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOBAS2LBMSJ5P3DMS2NHWDVLTUAJANCNFSM4DLJTL3A . You are receiving this because you commented.Message ID: @.***>

Yep, after symlinking conan to /usr/bin, it works without a hitch.

Thank you! Had the same issue with yuzu emulator. Fixed with symlink: sudo ln -s ~/.local/bin/conan /usr/bin/conan

Just FYI this is also a problem in Qt Creator. It can be worked around with sudo ln -s ~/.local/bin/conan /usr/local/bin/conan. I haven’t yet investigated if it could be fixed in other way.

Yeah, lets leave this open until we review the CLion flow too. Though it seems that the possible solution could be what @sixten-hilborn is pointing, because trying to detect the user’s shell and loading the path from there, could be too complex and fragile, specially if we want to achieve that multi-OS. But we will have a look. Thanks everyone!

Here’s a related post on SO: http://stackoverflow.com/a/37663546/2515282 I’ve never used CLion myself, but it looks like a clean solution to add your ~/.local/bin to CLion’s PATH.