You should see something similar to the following cmake version 3.5.1ĬMake suite maintained and supported by Kitware (/cmake). Once you have installed CMake you can check easily by doing the following cmake -version Will install CMake, while in case you use the Homebrew package manger you will type brew install cmake For example, in case of MacPorts, typing the following sudo port install cmake On Mac OSX, if you use one of the package managers available to install your software, the most notable being MacPorts ( MacPorts) and Homebrew ( Homebrew), you could also install CMake via one of them. On FreeBSD you can install the command-line and the Qt-based graphical application with: pkg install cmake On Ubuntu 16.04 you can install the command-line and graphical application with: sudo apt-get install cmake On Linux, you can also install the packages from the distribution's package manager. On Windows double click the binary to install. Head over to CMake download page and get a binary for your operating system, e.g. "Hello World" with multiple source filesįirst we can specify the directories of header files by include_directories(), then we need to specify the corresponding source files of the target executable by add_executable(), and be sure there's exactly one main() function in the source files.įollowing is a simple example, all the files are assumed placed in the directory PROJECT_SOURCE_DIR. Include_directories($)Īnd following the same steps, we'll get the same result. We modify CMakeLists.txt to cmake_minimum_required(VERSION 2.4) Instead of building from multiple source files, we can first deploy foo.cpp as a library by using add_library() and afterwards linking it with the main program with target_link_libraries(). Say we have the same set of source/header files as in the example. This example shows how to deploy the "Hello World" program as a library and how to link it with other targets. Each only handles as much of the build as is present in the current directory.įor official resources on CMake, see CMake's Documentation and Tutorial. The final CMakeLists files can be very clear and straightforward, because each is so limited in scope.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |