dockgasra.blogg.se

Cmake install target
Cmake install target










Target_include_directories adds an include directory to a target. Now we've specified a target, how do we add information about it? For example, maybe it needs an include directory: target_include_directories(one PUBLIC include) The one benefit to this is that you can make libraries with :: in the name (which you'll see later). You can also make an ALIAS library with an existing library, which simply gives you a new name for a target. That is called an INTERFACE library, and is another choice the only difference is it cannot be followed by filenames. If you leave this choice off, the value of BUILD_SHARED_LIBS will be used to pick between STATIC and SHARED.Īs you'll see in the following sections, often you'll need to make a fictional target, that is, one where nothing needs to be compiled, for example, for a header-only library. You get to pick a type of library, STATIC, SHARED, or MODULE. Making a library is done with add_library, and is just about as simple: add_library(one STATIC two.cpp three.h) More about the general build system and targets is available at buildsystem. The headers will be, for most intents and purposes, ignored the only reason to list them is to get them to show up in IDEs. CMake is smart, and will only compile source file extensions. The source file list comes next, and you can list as many as you'd like. one is both the name of the executable file generated, and the name of the CMake target created (you'll hear a lot more about targets soon, I promise). With them, let's start with a simple executable. Making an executableĪlthough libraries are much more interesting, and we'll spend most of our time There's really nothing special about the project name. CMake does have an inline syntax for comments too, but This is what new projects should do: cmake_minimum_required(VERSION 3.7. Windows users, who also usually have a very recent version of CMake. New versions of policies tend to be most important for macOS and Version of the policies in this example, since those versions didn't treat this Versions of CMake (though actually running CMake 3.1-3.11 will only set the 3.1 Settings, and due to a trick in the syntax, it's backward compatible with older This is much nicer on users that need the better This means you support as low as 3.1 but have also tested it with the new Starting in CMake 3.12, this supports a range, such as VERSION 3.1.3.15 A list of policies and versions is available at If you set it to 3.3 or less, you'll get the wrong So, if you set minimum_required to VERSIONĢ.8, you'll get the wrong linking behavior on macOS, for example, even in the This line is special! 2 The version of CMake will also dictate the policies, This book, just click on the command name to see the official documentation,Īnd use the dropdown to switch documentation between CMake versions. And the value of the version follows the keyword. 1 The VERSION is a special keyword for thisįunction. The command nameĬmake_minimum_required is case insensitive, so the common practice The file CMake looks for: cmake_minimum_required(VERSION 3.1) Here's the first line of every CMakeLists.txt, which is the required name of Introduction to the basics Minimum Version












Cmake install target