Several handy macros and modules for use with CMake
Go to file
Marius Zwicker 265e91ebf6 conan: Improve venv compatibility with VSCode Git bash 2024-04-26 21:05:37 +02:00
Conan conan: Configure protobuf 2024-03-24 17:30:11 +01:00
Modules Enable automatic management of license headers 2022-01-29 23:50:24 +01:00
.gitignore conan: Automatically install to venv 2024-04-12 21:43:21 +02:00
.license-tools-config.json qt5: Add helper 2022-08-12 08:01:57 +02:00
.pre-commit-config.yaml Bump pre-commit hooks 2023-10-03 14:28:21 +02:00
.pylintrc ccache-tidy: Accelerate clang-tidy using ccache 2022-05-08 09:35:13 +02:00
3rdparty.cmake Improve include_guard 2022-08-19 08:17:10 +02:00
LICENSE Add copy of Apache License 2018-01-26 17:15:24 +01:00
README.md Update Readme 2018-01-26 17:21:56 +01:00
RaspberryPi.cmake Enable automatic management of license headers 2022-01-29 23:50:24 +01:00
compiler.cmake compiler: Suppress errors testing compiler version 2024-02-18 18:12:27 +01:00
conan.cmake conan: Provide fallback path for profile 2024-04-12 20:58:24 +02:00
conan.sh conan: Improve venv compatibility with VSCode Git bash 2024-04-26 21:05:37 +02:00
conan_package.py conan_package: Flush log 2023-10-03 14:50:10 +02:00
generator.bat generator: Fix error propagation on MSVC 2023-11-01 10:52:14 +01:00
generator.sh conan: Make implicit run opt-in 2024-04-12 20:57:23 +02:00
global.cmake conan: Fix macos version definition in cross builds 2023-11-04 23:22:24 +01:00
iOS.cmake Enable automatic management of license headers 2022-01-29 23:50:24 +01:00
linting.cmake conan: Support universal builds on macOS 2024-01-04 11:38:00 +01:00
macros.cmake Enable automatic management of license headers 2022-01-29 23:50:24 +01:00
presets.cmake presets: Retain full MSVC path 2024-01-30 09:03:59 +01:00
presets.py presets: Stability improvements on Windows 2023-12-23 17:52:14 +01:00
qt5.cmake qt5: Retain upstream qt.conf 2023-11-26 17:38:21 +01:00
recode.py recode: Also catch errors on decode 2023-11-26 18:49:50 +01:00
s3storage.cmake Improve include_guard 2022-08-19 08:17:10 +02:00
semver.cmake semver: Include examples for generated versions 2023-01-15 18:11:03 +01:00

README.md

MZ CMake Tools

Provides some useful extensions to the normal functionality of CMake

Additional Modules

When using the mz tools more libraries can be searched for, see the Modules directory for details.

Macros and Functions

Additional commands, some are nothing more than cosmetic...

mz_add_definition ...

add the definition (and following) to the list of definitions passed to the compiler. Automatically switches between the syntax of msvc and gcc/clang Example: mz_add_definition(NO_DEBUG)

mz_add_cxx_flag GCC|CLANG|VS|ALL ...

pass the given flag to the C++ compiler when the compiler matches the given platform

mz_add_c_flag GCC|CLANG|VS|ALL ...

pass the given flag to the C compiler when the compiler matches the given platform

mz_add_flag GCC|CLANG|VS|ALL ...

pass the given flag to the compiler, no matter wether compiling C or C++ files. The selected platform is still respected

mz_use_default_compiler_settings

resets all configured compiler flags back to the cmake default. This is especially useful when adding external libraries which might still have compiler warnings

Provided CMake Variables

MZ_IS_VS true when the platform is MS Visual Studio

MZ_IS_GCC true when the compiler is gcc or compatible

MZ_IS_CLANG true when the compiler is clang

MZ_IS_XCODE true when configuring for the XCode IDE

MZ_IS_RELEASE true when building with CMAKE_BUILD_TYPE = "Release"

MZ_64BIT true when building for a 64bit system

MZ_32BIT true when building for a 32bit system

MZ_HAS_CXX0X see MZ_HAS_CXX11

MZ_HAS_CXX11 true when the compiler supports at least a (subset) of the upcoming C++11 standard

MZ_MACOS true when building on macOS

MZ_IOS true when building for iOS

MZ_WINDOWS true when building on Windows

MZ_LINUX true when building on Linux

MZ_DATE_STRING a string containing day, date and time of the moment cmake was executed e.g. Mo, 27 Feb 2012 19:47:23 +0100

Enabled compiler definitions/options

On all compilers supporting it, the option to treat warnings will be set. Additionally the warn level of the compiler will be decreased. See mz_use_default_compiler_settings whenever some warnings have to be accepted

Provided defines (defined to 1)

MZ_WINDOWS on Windows

MZ_LINUX on Linux

MZ_MACOS on macOS

MZ_IOS on iOS

WIN32_VS on MSVC - note this is deprecated, it is recommended to use _MSC_VER

WIN32_MINGW when using the mingw toolchain

WIN32_MINGW64 when using the mingw-w64 toolchain

MZ_HAS_CXX11 / MZ_HAS_CXX0X when subset of C++11 is available

Installation and Usage

Simply copy all files including the Module directory into your project and include it within your CMakelists.txt by typing

include(< your folder >/global.cmake)

All settings will be done automatically and the given functions can be directly used