(You can, and will, re-run CMake several times on the same binary folder.) Cache variables include user-configurable options defined by the project such as CMakeDemo’s DEMO_ENABLE_MULTISAMPLE option (explained later), and precomputed information to help speed up CMake runs. This is where cache variables are stored. It’s a single text file in the binary folder named CMakeCache.txt. You can even create several binary folders, side-by-side, that use different build systems or configuration options. A common practice is to create a subdirectory build beneath CMakeLists.txt.īy keeping the binary folder separate from the source, you can delete the binary folder at any time to get back to a clean slate. You can create the binary folder anywhere you want. The binary folder is where CMake generates the build pipeline. The source folder is the one containing CMakeLists.txt. To generate a build pipeline, CMake needs to know the source and binary folders. A build pipeline might be a Visual Studio.
The Source and Binary FoldersĬMake generates build pipelines.
You can also install it through MacPorts, Homebrew, Cygwin or MSYS2. In Unix-like environments, including Linux, it’s usually available through the system package manager. If you don’t have CMake yet, there are installers and binary distributions on the CMake website. However, I recommend reading the first two sections first.
To use our C++ library in a CMake project, you only need to include this file and to reference our library with the yoctolib name.The information here applies to any CMake-based project, so feel free to skip ahead to any section.
This file contains all the compilation rules for our library. Moreover, CMake is open source and is available on almost all platforms.įor these reasons, since version 0 of our C++ library, we added a CMakeLists.txt file in the Sources subdirectory. As we are going to see below, the CMake syntax is much simpler, making the life of the developer easier as well. cpp file into an executable, but its syntax is very complex and becomes almost incomprehensible for large projects. Indeed, GNU make already enables us to describe the commands to be run to transform a. We could wonder why not using GNU make directly. Usually under Linux, one uses CMake to generate a GNU make file which then uses gcc or g++ to compile the source file and to create the executable.ĬMake generates makefiles which enable you to compile the application with gccĪ CMake project is composed of source files and of one or several CMakeLists.txt files containing the required information to compile the application, such as the location of the source files, the name of the executable, the libraries to be used, and so on. In other words, the role of CMake is not to actually build the executable, but to prepare a list of commands to be performed to generate the executable. CMake is neither a compiler nor an IDE, but it is a "tool for managing the build process of software".
If it is not the case, we recommend that you start by reading our post " How to start in C++ with Yoctopuce modules" which explains how our library works.įirst of all, a few words on CMake. Note: we assume that you already have a minimal knowledge of the C++ language and of our programming libraries. However, we hadn't yet documented how to use CMake to compile the library and use it in a program. This process is documented in the README file and there is a post explaining how to compile the library with the Code::Blocks IDE. Recently, we have had several customers who decided to compile our C++ library under Linux.