Cmake install multiple files
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 Listing each file and what it depends on sounds really tedious.Introduction to the basics Minimum Version Target_link_libraries(test_meh_app src unity) Test/CMakeLists.txt add_executable(test_meh_app test_meh.c) THEN it will add that file to your makefile and you'll be good to go.įinally, let's look at the list in our test directory: You must explicitly call cmake again in order to get it to notice any files that you add to your source directory. CMake doesn't know when to add more release files to your list. One thing we should note about operating this way. # Let's tell it a bit about our environment CMakeLists.txt project("My Awesome Tested Project" C) Let's start with the one in our project root: It contains instructions for building the things in that directory. This file is a text file to reinforce that you're welcome to edit this with your handy dandy text editor. In each directory, it keeps a file called CMakeLists.txt. unity - where we have copied the latest copy of the Unity projectĬMake likes to think of the world as lists.test - where we have all our unit tests.
#Cmake install multiple files code#
src - where we have all our source code for release (and to be tested).Our project's directory structure will look something like this: So you would like to use CMake (and CTest) to handle your test builds? Good choice! Unity loves working with CMake and friends.įor the purpose of this simple example, we're going to organize our code in the same default as we do in our make and other intros.