Bunch of macros to simplifying use of CMake in projects.
All files in repo witch is started with "_" are private and should not be included in user files directly. Subdirectory version also should not be included in user files: use macros from VersionTargetGenerator.cmake instead.
toolchains folder contains toolchain-files. They can
be used throw -DCMAKE_TOOLCHAIN_FILE
flag. See
example of use below.
Example of usage see in Pastilda project repo: https://bitbucket.org/thirdpin_team/pastilda
Toolchain file provides information about build tools
to CMake. Also it adds some platform and compiler specific
global flags. You can set toolchain file throw
-DCMAKE_TOOLCHAIN_FILE
flag:
cmake . -GNinja -DCMAKE_TOOLCHAIN_FILE=./cmake/toolchain-clang.cmake
All files require CMake 3.13 or higher.
The best way to add this repo to your project is to used it as submodule. Some files has inner dependencies.
To add all public files into a scope use CMAKE_MODULE_PATH
variable:
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
where cmake is submodule. After that you can include any
file with include
directive:
include(FileWithSomeMacroces)
Preamble.cmake should be included right after the adding path to submodule to CMAKE_MODULE_PATH. It provides some important global flags for better integration with IDEs.
Other files must be included only after the project
directive. Every file contains description of itself.
Use it to better understanding files purpose. Also
use Pastilda project repo
as example of macros usage.
add_libopencm3_for
macros from Opencm3.cmake can be
used for Opencm3 library compilation.
Macros usage precondtions is:
- Opencm3 should be a submodule of your project;
- Opencm3 should be located in
/src/libopencm3
folder; - if your are using Windows you should install WSL (Windows Subsystem for Linux
If all requirements are satisfied you can call the macros like this:
include(Opencm3)
add_libopencm3_for(f1 f2)
After that two targets will be generated: Opencm3::stm32f2
and
Opencm3::stm32f1
.