The project code is in the GitHub repository directory, where you will see only the two files described in Listings 1 and 2 cd ls For example, under sudo apt-get install cmake -version To build the project, first test that you have CMake installed, and if not, install it using the package manager that is used by your flavor of Linux. ![]() The first argument to the add_executable() function is the name of the executable to be built, and the second argument is the source file from which to build the executable. The third line is the add_executable() command, which requests that an executable is to be built using the helloworld.cpp source file.The second line is the project() command that sets the project name.Therefore, you should use the current version of CMake on your system, which for this example is determined just below. This version is somewhat arbitrary in this example, but providing a version number allows for future support for your build environment. The first line sets the minimum version of CMake for this project, which is major version 2, minor version 8, and patch version 9 in this example.The CMakeLists.txt file in Listing 2 consists of only three lines: It can do much more than that too (e.g., build MS Visual Studio solutions), but in this discussion I focus on the auto-generation of Makefiles for C/C++ projects. ![]() The make utility and Makefiles provide a build system that can be used to manage the compilation and re-compilation of programs that are written in any programming language. I use Makefiles quite often in my projects to automate the build process however, there are times when Makefiles become overly complex for the task - particularly when building projects that have multiple sub directories, or projects that are to be deployed to multiple platforms.īuilding complex projects is where CMake really shines - CMake is a cross-platform Makefile generator! Simply put, CMake automatically generates the Makefiles for your project. This article provides a straightforward set of “Hello World!” introductions to using CMake for building C++ projects. All steps are performed using Linux on the BeagleBone platform, but the instructions are relevant to most Linux platforms.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |