Cant create boost conan package from conan-center-index - "conanfile didn't specify version" - conan

I try to create conan package of boost library.
I got the recipe from https://github.com/conan-io/conan-center-index/tree/master/recipes/boost
When I execute command:
conan create . conan/stable
next error will appeared:
ERROR: conanfile didn't specify version
I see, that in recipe no version member, but I don't understand how to specify it manually in that case. And no any hint from official docs on conan create page(

Indeed the version is not listed in the recipe, but why? Because the same recipe is re-used for any version, so Conan Center Index don't need to replicate the same recipe for each new version.
All versions supported by Boost are listed in conandata.yml, which is a file with the download link and the checksum, according the version.
Thus, to build the desired version, you have to pass it with the command like. For instance, to build Boost 1.73:
cd recipes/boost/all
conan create . 1.73.0#
Note that I only passed the version, not the namespace (username/channel), because it's an official recipe from Conan Center Index, any other recipe should contain the namespace to avoid any conflict. In this case, you can use your namespace too, if you want:
cd recipes/boost/all
conan create . 1.73.0#hdnn/stable
The version in recipe is not mandatory, even without conandata.yml. When any mandatory attribute is missing (name or version), you can pass them by command line.

Related

Creating a recipe for a CMake project that finds its dependencies with find_package

I want to make a Conan package for a project I found on Github. This project is a CMake project and depends on openssl. The project finds openssl with a normal find_package.
My recipe declares the openssl dependency obviously, but where I struggle is how do I get the find_package(openssl) inside the project's CMake to find the openssl obtained by Conan?
You need cmake_find_package generator.
from conans import ConanFile
class Foo(ConanFile):
requires = "openssl/1.1.1l"
generators = "cmake", "cmake_find_package"
...
This will generate Findxxx.cmake for all your dependencies.
If you are creating packages for your first time, I suggest you reading how to create a package from official docs, and the best practices from Conan Center Index.
UPDATE: Using CMakeDeps
Many improvements have been made for Conan 2.0, including a new approach for generators. The CMakeDeps is new way to go when needing xxx-config.cmake. It's not documented on getting started yet, but its reference brings a very straightforward example.

cmake find_package unable to find Eigen3Config.cmake spectra Windows

I am using Eigen3 with spectra (https://spectralib.org/), a library built on top of Eigen. Spectra uses find_package to find Eigen, and comes up with the error:
Could not find a package configuration file provided by "Eigen3" with any
of the following names:
Eigen3Config.cmake
eigen3-config.cmake
Looking through the directory of Eigen, I found that there were no files by those names, but rather one called Eigen3Config.cmake.in. I tried copying the file and renaming it Eigen3Config.cmake, but that gave me a different error of
find_package Error reading CMake code from "C:/Program Files
(x86)/Eigen3/cmake/Eigen3Config.cmake".
which was somewhat expected, but it does tell me that it can at least find the directory where Eigen3Config.cmake.in is. I'm assuming that either find_package is supposed to use Eigen3Config.cmake.in, or Eigen3Config.cmake.in is supposed to generate Eigen3Config.cmake, but i'm very new to cmake, so i'm not sure. How do I fix this?
There is no need to build/install Eigen to use it if you include it manually, as done in the getting started example (https://eigen.tuxfamily.org/dox/GettingStarted.html#title0)
But in order to be found by CMake, you will need to build / install it, as explained in the INSTALL file. https://gitlab.com/libeigen/eigen/-/blob/master/INSTALL
Usually, your error is followed by an hint asking you to set the variable Eigen3_DIR (or something similar) to point the build/install dir of the target project (Eigen3 here). It appears typically when you have built but not installed the project.
So:
Build Eigen
Install it (optional)
For spectra set the cmake var Eigen3_DIR to /path/to/Eigen/build . (if eigen not install or still not found)
These steps worked for me:
Install Eigen
Create a build directory for Eigen
cd into the build directory created
run "cmake ../"Your Eigen Source Directory""
After this is done, in your CMakeLists.txt of your project, you'll want to add "find_package( Eigen3 REQUIRED)" and "include_directories( ${EIGEN3_INCLUDE_DIR})".

CMake get list of tried package when find_package fails

I have a cmake project and I want to obtain information when a find_package fails.
My setup is this: I have a project that compiles a few libraries and export the targets. The package is exported to the CMake package registry. Then, I have another project that depends on it.
The thing is, the library project has dependencies too. To make the importing package aware, we are using find_dependency in the config file.
When find_package(libs REQUIRED) fails because of missing dependencies, I would like to extract the path of the package it tried. I would use that information to maybe update the list of prefix path in order to find the missing dependencies next time, but I only want to do that if the reason of the failed import is missing dependencies.
Is there any way to obtain these information in a failed find package?
From the CMake documentation for find_package:
All configuration files which have been considered by CMake while searching for an installation of the package with an appropriate version are stored in the cmake variable <PackageName>_CONSIDERED_CONFIGS, the associated versions in <PackageName>_CONSIDERED_VERSIONS.
So using <PackageName>_CONSIDERED_CONFIGS and <PackageName>_CONSIDERED_VERSIONS can tell what packages CMake has found.

Upgrading cmake in Yocto

I'm using Yocto and struggling to update cmake. The poky version that we are using provides cmake version 3.3.1, but one of the packages that I'm building requires cmake version 3.5 or greater.
Looking at the poky git repo, the latest provides version 3.8.2. I figured that the easiest way to upgrade cmake was to include the recipes for cmake from the current poky master branch within my own meta repo, in order to override the lesser version. So I copied the cmake directory, and expected the build to continue along...
Unfortunately, the cmake recipes that I copied in aren't working. The recipes won't even load, as they throw an error, saying "docker must contain prefix as its prefix." Printing the output of the prefix and docdir variables to the console, I see that docdir is set to "${datadir}/doc" -- the datadir variable is not expanded.
In summary, the questions that I have are:
What is the best way to upgrade cmake? Is the best way to copy in the updated recipes into my own meta repo?
Why isn't the datadir variable being expanded, and how can I fix that?
What is probably happening is that the recipe for cmake 3.8.2 (2.4) is not backward compatible with the poky version from 3.3.1 (Version 1.9). The reference is here. I guess some refactoring and important milestones happened meanwhile
The easiest way is to upgrade the whole poky folder in your ecosystem, hoping it is not breaking your other recipes.

Integrating application Yocto arm bitbake

I'm trying to have my recipe be compiled and linked against the arm libraries. I'm using cmake. I can't seem to figure out the right work flow, after having read trough multiple documents on the yocto site and reference materials. My approach right now is:
Set the source
Build my target minal image, without the layer that I want to use
Try to build my specific recipe: bitbake Test
I have downloaded the arm toolchain from the Yocto site, and prepared it in my sources/poky. Here I can see the systroots and all the libraries that I would need. My recipe bb file is the following:
# This file was derived from the 'Hello World!' example recipe in the
# Yocto Project Development Manual.
#
SUMMARY = "Project"
SECTION = "examples"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "file://."
S = "${WORKDIR}/project/src"
inherit pkgconfig cmake externalsrc
And my CMake file contains, among more:
link_directories(/media/traffic/Yocto/QorIQ-SDK-V2.0-20160527-yocto/sources/poky/sysroots/aarch64-poky-linux/usr/lib)
I'm able to compile a hello world project fine, but as soon as external libraries take a role, it goes wrong.
cannot find /usr/lib/libpthread_nonshared.a
/media/traffic/Yocto/QorIQ-SDK-V2.0-20160527-yocto/build_ls2084abluebox/tmp/sysroots/x86_64-linux/usr/bin/aarch64-fsl-linux/../../libexec/aarch64-fsl-linux/gcc/aarch64-fsl-linux/4.9.3/ld: cannot find /usr/lib/libpthread_nonshared.a
It seems to look in the wrong folder. Are the steps that I'm taking correctly? Or am i missing something?
Elmar
Which poky version are you using? I got exactly the same issue recently with another package. There are 2 issues here:
It cannot find the pThread library. I added a FindThreads.cmake in the tree and imported it. But then the linker could not make it. I went to the conclusion, cmake itself had an issue with this library and ended changing the poky commit to have a different version of CMake. Note that you can also keep the new poky versions and have the custom CMake in your layer.
CMake 3.7 and 3.8.2 were not working properly but the 3.7.1 was for me (hash c9a512b6408d4cc11c1b36f7bc1b9b1c31056ce1). To find out which commit, you can execute
git log --pretty=oneline | grep cmake: