cmake-conan
                                
                                 cmake-conan copied to clipboard
                                
                                    cmake-conan copied to clipboard
                            
                            
                            
                        [question] Conan in cmake found, but can't install
Hello, I am trying to install Google Test using Conan in cmake on Ubuntu 19.04, Cmake 3.17+. I installed Conan via pip inside Anaconda3! I am using the following script to run the installs:
macro(run_conan)
# Download automatically
if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
  message(
    STATUS
      "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
  file(DOWNLOAD "https://github.com/conan-io/cmake-conan/raw/v0.15/conan.cmake"
       "${CMAKE_BINARY_DIR}/conan.cmake")
endif()
if (CONAN_PATH)
  set(CONAN_CMD ${CONAN_PATH})
endif ()
include(${CMAKE_BINARY_DIR}/conan.cmake)
conan_add_remote(NAME bincrafters URL
                 https://api.bintray.com/conan/bincrafters/public-conan)
conan_cmake_run(
  CONANFILE deps/Conanfile.py
  BASIC_SETUP
  CMAKE_TARGETS 
  BUILD
  missing)
endmacro()
Cmake appears to find the conan binary, but then throws an error as it can't install:
-- ccache found and enabled -- Conan: checking conan executable -- Conan: Found program ~/anaconda3/bin/conan -- Conan: Version found -- Conan: Adding bincrafters remote repository (https://api.bintray.com/conan/bincrafters/public-conan) -- Conan: Automatic detection of conan settings from cmake -- Conan: Settings= -s;build_type=Debug;-s;compiler=gcc;-s;compiler.version=9;-s;compiler.libcxx=libstdc++11 -- Conan: checking conan executable -- Conan: Found program ~/anaconda3/bin/conan -- Conan: Version found -- Conan executing: ~/anaconda3/bin/conan install /home/michael/GitHub/loraine/deps/Conanfile.py -s build_type=Debug -s compiler=gcc -s compiler.version=9 -s compiler.libcxx=libstdc++11 -g=cmake --build=missing CMake Error at build/debug/conan.cmake:402 (message): Conan install failed='No such file or directory' Call Stack (most recent call first): build/debug/conan.cmake:497 (conan_cmake_install) cmake/Conan.cmake:19 (conan_cmake_run) CMakeLists.txt:82 (run_conan)
The conanfile.py is taken from here https://github.com/bincrafters/conan-gtest/blob/testing/1.8.1/conanfile.py
All the filepaths seem right to me, i.e. /home/michael/GitHub/loraine/deps/Conanfile.py is exactly where the conanfile is, so it should find it. So what exactly is missing in this case?
Best regards, Michael
Hi @maichmueller I think this sounds more like a "conan.cmake" issue, not a Conan one, we might want to move it that repo, I am moving it there.
Also, it seems you are still using the old gtest. I would recommend to use the more modern packages from the new ConanCenter (https://conan.io/center/) (generated from conan-center-index repo https://github.com/conan-io/conan-center-index). Those are the packages that doesn't have the "@user/channel" part anymore. Have you tried that?
Hello @memsharded thanks for your answer. I have just downloaded the conanfile.py for gtest 1.10 from https://conan.io/center/gtest/1.10.0/?user=&channel=&revision=&os=&tab=recipe and replaced the old one with it, but that didn't fix the problem. the same error message persists. Is that what you meant with replacing the @user/channel pacakges?
thanks for your answer. I have just downloaded the conanfile.py for gtest 1.10 from https://conan.io/center/gtest/1.10.0/?user=&channel=&revision=&os=&tab=recipe and replaced the old one with it, but that didn't fix the problem. the same error message persists. Is that what you meant with replacing the @user/channel pacakges?
Well, you don't need to download the conanfile.py, you can get it directly from ConanCenter with the Conan client, the ConanCenter is configured by default. Just declare the gtest/1.10 dependency in your conanfile.
Right, so as you can tell im rather new to conan, so thanks already for baring with me here.
I have now replaced deps/conanfile.py by deps/conanfile.txt with the content:
[requires]
gtest/1.10.0
And changed the cmake conan_cmake_run command to:
conan_cmake_run(
  CONANFILE deps/conanfile.txt
  ${CONAN_EXTRA_REQUIRES}
  OPTIONS
  ${CONAN_EXTRA_OPTIONS}
  BASIC_SETUP
  CMAKE_TARGETS # individual targets to link to
  BUILD
  missing)
Unfortunately I get the same error:
> -- ccache found and enabled
> -- Conan: checking conan executable
> -- Conan: Found program ~/anaconda3/bin/conan
> -- Conan: Version found 
> -- Conan: Adding bincrafters remote repository (https://api.bintray.com/conan/bincrafters/public-conan)
> -- Conan: Automatic detection of conan settings from cmake
> -- Conan: Settings= -s;build_type=Release;-s;compiler=gcc;-s;compiler.version=9;-s;compiler.libcxx=libstdc++11
> -- Conan: checking conan executable
> -- Conan: Found program ~/anaconda3/bin/conan
> -- Conan: Version found 
> -- Conan executing: ~/anaconda3/bin/conan install /home/michael/GitHub/loraine/deps/conanfile.txt -s build_type=Release -s compiler=gcc -s compiler.version=9 -s compiler.libcxx=libstdc++11 -g=cmake --build=missing
> CMake Error at build/release/conan.cmake:402 (message):
>   Conan install failed='No such file or directory'
> Call Stack (most recent call first):
>   build/release/conan.cmake:497 (conan_cmake_install)
>   cmake/Conan.cmake:19 (conan_cmake_run)
>   CMakeLists.txt:82 (run_conan)
Any other ideas as to why this is happening? Is the error telling me it doesn't find the conanfile?
Running the command stated by
-- Conan executing: ~/anaconda3/bin/conan install /home/michael/GitHub/loraine/deps/conanfile.txt -s build_type=Release -s compiler=gcc -s compiler.version=9 -s compiler.libcxx=libstdc++11 -g=cmake --build=missing
works in the command line and gives the following output:
~/anaconda3/bin/conan install /home/michael/GitHub/loraine/deps/conanfile.txt -s build_type=Debug -s compiler=gcc -s compiler.version=9 -s compiler.libcxx=libstdc++11 -g=cmake --build=missing Configuration: [settings] arch=x86_64 arch_build=x86_64 build_type=Debug compiler=gcc compiler.libcxx=libstdc++11 compiler.version=9 os=Linux os_build=Linux [options] [build_requires] [env]
gtest/1.10.0: Not found in local cache, looking in remotes... gtest/1.10.0: Trying with 'conan-center'... Downloading conanmanifest.txt completed [0.31k]
Downloading conanfile.py completed [4.21k]
Downloading conan_export.tgz completed [0.29k]
Decompressing conan_export.tgz completed [0.00k]
gtest/1.10.0: Downloaded recipe revision 0 conanfile.txt: Installing package Requirements gtest/1.10.0 from 'conan-center' - Downloaded Packages gtest/1.10.0:ec1caa886f1802381c5ecbb31ff59dda4dcdd8ce - DownloadInstalling (downloading, building) binaries... gtest/1.10.0: Retrieving package ec1caa886f1802381c5ecbb31ff59dda4dcdd8ce from remote 'conan-center' Downloading conanmanifest.txt completed [3.64k]
Downloading conaninfo.txt completed [0.58k]
Downloading conan_package.tgz completed [1516.55k]
Decompressing conan_package.tgz completed [0.00k]
gtest/1.10.0: Package installed ec1caa886f1802381c5ecbb31ff59dda4dcdd8ce gtest/1.10.0: Downloaded package revision 0 conanfile.txt: Generator cmake created conanbuildinfo.cmake conanfile.txt: Generator txt created conanbuildinfo.txt conanfile.txt: Generated conaninfo.txt conanfile.txt: Generated graphinfo
I think the cmake script may not run conan because it is installed in a non-standard directory. Could someone verify that?
So I have just confirmed, that the problem lies with a different than standard installation of conan. If conan is not in usr/local/bin, then conan is not able to install. Once I have created a symlink from my anaconda conan to usr/local/bin, the error went away. If this could be fixed, it would be great.