9

I've got CMakeLists.txt file:

project(ip_filter LANGUAGES CXX)
cmake_minimum_required(VERSION 2.8)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

add_executable(ip_filter ip_filter.cpp)
target_link_libraries(ip_filter ${CONAN_LIBS})

At the same folder, I've got a conanfile.txt:

[requires]
range-v3/0.9.1@ericniebler/stable

[generators]
cmake

When I tried to build it, using:

$ cmake CMakeLists.txt

I've got this output:

CMake Error at CMakeLists.txt:4 (include):
  include could not find load file:

    /home/bogdasar/Documents/C++_Programming/ip_filter/conanbuildinfo.cmake


CMake Error at CMakeLists.txt:5 (conan_basic_setup):
  Unknown CMake command "conan_basic_setup".


-- Configuring incomplete, errors occurred!
See also "/home/bogdasar/Documents/C++_Programming/ip_filter/CMakeFiles/CMakeOutput.log".
Bogdasar
  • 181
  • 1
  • 1
  • 9
  • The error message is `include could not find load file: /home/bogdasar/Documents/C++_Programming/ip_filter/conanbuildinfo.cmake`. Did you check if the file exists? Is the file correct? – Thomas Sablik Apr 01 '20 at 09:11
  • @ThomasSablik yes, file don't exist. but in Conan documentation nothing is written about this file. What is he responsible for? What is inside it? Is it generated itself or should I write? – Bogdasar Apr 01 '20 at 09:19
  • 1
    Did you run `conan install`? https://docs.conan.io/en/latest/getting_started.html#installing-dependencies – Thomas Sablik Apr 01 '20 at 09:19
  • @ThomasSablik What should i install? – Bogdasar Apr 01 '20 at 09:23
  • Please read the documentation I linked you. _It is very important to understand the installation process._ Stackoverflow is not a platform for conan/cmake tutorials. – Thomas Sablik Apr 01 '20 at 09:25
  • 2
    Yes, please, do follow the Getting Started guide, make sure it works first: https://docs.conan.io/en/latest/getting_started.html. Then, and only after succeeding, start doing modifications to those files trying to achieve your goal. Most likely you also want to start using the more modern packages in ConanCenter, those that don't have "user/channel", like that "ericniebler/stable". Check https://conan.io/center/range-v3/0.9.1/?user=_&channel=_ – drodri Apr 01 '20 at 09:33
  • I did it, by using `conan install . --settings os="Linux" --settings compiler="gcc"` – Bogdasar Apr 01 '20 at 09:34

1 Answers1

5

I was stuck on the same issue for a while. After going through few threads I found the solution. Here I am summarizing the same.

Problem here is cmake is unable to find conanbuildinfo.cmake. This file should be generated when you call conan install.

If it is not getting generated then you should include cmake generator in conanfile.py. Like below:

generators = "virtualenv", "virtualrunenv", "cmake_find_package", "cmake"

or you can mention the same in your conan profile. Like below:

[generators]
cmake

Once this file is generated, cmake should be able to find it. And conan_basic_setup() step should pass.

rakesh.sahu
  • 465
  • 8
  • 18