Getting Started¶
You have multiple options for incorporating cmake-tools into your project:
With CMake FetchContent
As a Git submodule
With CMake FetchContent¶
You can use CMake’s FetchContent module to load cmake-tools.
In your CMakeLists.txt file, use
FetchContent
to load cmake-tools.Use find_package() and include() to load cmake-tools modules.
include(FetchContent)
FetchContent_Declare(
cmake-tools
GIT_REPOSITORY https://github.com/brobeson/cmake-tools.git
GIT_TAG main
)
FetchContent_MakeAvailable(cmake-tools)
list(APPEND CMAKE_MODULE_PATH "${cmake-tools_SOURCE_DIR}")
You may want to put these lines in your root CMakeLists.txt file, before your
top level project()
command if you plan to use any cmake-tools modules in
the project()
command. One example of this is setting the project version
from the Git tag. Here is an example:
include(CMakeToolsVersionFromGit)
project(
supernovas
VERSION ${CMAKE_TOOLS_GIT_TAG}
DESCRIPTION "A pure C++ implementation of the NOVAS library."
HOMEPAGE_URL "https://github.com/brobeson/supernovas"
LANGUAGES CXX
)
Using cmake-tools as a Submodule¶
You can clone cmake-tools as a submodule of your project.
git submodule add https://github.com/brobeson/cmake-tools.git
In your CMakeLists.txt file, set CMAKE_MODULE_PATH.
Use find_package() and include() to load cmake-tools modules.
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake-tools")
find_package(Lizard)
include(CMakeToolsCompileOptions)