Creating testing and uploading conan binary packages


To start learning about creating packages, we will create a package from an existing source code repository: It has nothing related to conan in it. We are using such github repository as an example, but the same process would apply to other source code origins, like downloading a zip or tarball from the internet.

They are not required by conan, you could use your own build system and version control instead. At the root level, there is a conanfile. It is useful to make sure that our package is correctly created. This is a creating testing and uploading conan binary packages package recipe. Without worrying too much about every detail, these are the basics:. The settings field defines the configuration that defines the different binary packages. In this example we are defining that any change to the OS, compiler, architecture or build type will generate a different binary package.

Remember, Conan generates different binary packages for different introduced configuration in this case settings for the same creating testing and uploading conan binary packages.

Note that the platform where the recipe is running and the package is being build can be different from the final platform where the code will be running self. So if you want to apply a different build depending on the current build machine, you need to check it:.

Learn more in the Cross building section. This package recipe is also able to create different binary packages for static and shared libraries with the shared option, which is defaulted to False i. The source method executes a git clone to retrieve the sources from github. Other origins, as downloading a zip file are also available. As you can see, any manipulation of the code can be done, as checking out any branch or tag, or patching the source code.

In this example, we are adding two lines to the existing CMake code, to ensure binary compatibility. The build first configures the project, then builds it, with standard CMake commands. The CMake object is just a helper to ease the translation of conan settings to CMake command line arguments. Also remember that CMake is not strictly required.

Check the existing build helpers. The package method copies artifacts headers, libs from the build folder to the final package folder. Other information as include or lib paths can be defined as well. This information is used for files created creating testing and uploading conan binary packages generators to be used by consumers, as conanbuildinfo.

This requires will be automatically injected by conan while running. You can however declare it explicitely, it will work, but you will have to remember to bump the version, and possibly the user and channel if you change them. Using conan commands, the conan create command would be equivalent to:. The conan create command receives the same command line parameters as conan install so you can pass to it the same settings, options, and command line switches.

If you want to create and test packages for different configurations, you could:. We have used settings as osarch and compiler. What is the difference between settings and options? Settings are project-wide configuration, something that typically affect to the whole project that is being built. For example the Operating System or the architecture would be naturally the same for all packages in a dependency graph, linking a Linux library for a Windows app, or mixing architectures is impossible.

Settings cannot be defaulted in a package recipe. The os will be given by the environment in which that recipe is processed. It is a necessary input.

You can edit, add, remove settings or subsettings in your settings. On the other hand, options are package-specific configuration. Being a static or shared library is not something that applies to all packages. Some can be header only libraries. Other packages can be just data, or package executables. Or packages can contain creating testing and uploading conan binary packages mixture of different artifacts.

Options are defined in the package recipe, including their allowed values, and it can be defaulted by the package recipe itself. A package for a library can well define that by default it will be a static library a typical default. If no one else specifies something different, the package will be static.

There are some exceptions to the above, for example, settings can be defined per-package, like in creating testing and uploading conan binary packages line:. This will use gcc for MyPkg and clang for the rest of the dependencies extremely unusual case. Or you can have a very widely used option in many packages and set its value all at once with patterns, like:. Please check out our FAQ section or write us.

Upgrading to conan 1. See also Check the existing build helpers. There are some exceptions to the above, for example, settings can be defined per-package, like in command line: Read the Docs v:

This how-to illustrates how to put them together to create and consume packages that are purely based on Visual Studio. This how-to is using VS, but other versions can be used too. It contains a src folder with the source code and a build folder with a Visual Studio solution, containing 2 projects: In the repository, there is already a conanfile. This recipe is using the MSBuild build helper to build the sln project. If our recipe had requiresthe MSBUILD helper will also take care of inject all the needed information from the requirements, as include directories, library names, definitions, flags etc to allow our project to locate the declared dependencies.

In this example, the consuming application is creating testing and uploading conan binary packages cmake to build, but it could also use Visual Studio too. We have left the cmake one because it is the default generated with conan newand also to show that packages created from Visual Studio projects can also be consumed with other build systems like CMake.

Instead of closing the IDE and running command: It is not mandatory to specify the compiler. Your locally created packages can creating testing and uploading conan binary packages be uploaded to a conan remote. Of course, you can also directly use your user name in conan create. Another alternative is to configure the permissions in the remote, to allow uploading packages with different usernames. As above, the repository contains a Visual Studio solution in the build folder.

But if you try to open it, it will fail to load. This is because it is expecting to find a file with the required information about dependencies, so it is necessary to obtain that file first. You will see that it created two files, a conaninfo. Now you can open the IDE and build and run the app by the way, the chat function is just calling the hello function two or three times, depending on the build type:. If you wish to link with the debug version of Hello package, just install it and change IDE build type:.

Again, there is a conanfile. The recipe is almost identical to the above one, just with two minor differences:. The above example creating testing and uploading conan binary packages as-is for VS, because VS supports upgrading from previous versions.

The MSBuild already implements such functionality, so building and testing packages with VS can be done. If you have to build for older versions of Visual Studio, it is also possible. In that case, you would probably have different solution projects inside your creating testing and uploading conan binary packages folder. Then the recipe only has to select the correct one, something like:.

Finally, we used just one conanbuildinfo. You could also define multiple conanbuildinfo. Please report and provide feedback submit an issue in github to request this feature if necessary. Upgrading to conan 1. Note It is not mandatory to specify the compiler. Read the Docs v: