Compiler flags
Example project that sets compiler flags and preprocessor defines for various platforms.
[project]
name = "compile-options"
description = "Compiler flags"
[target.hello]
type = "executable"
sources = ["src/main.cpp"]
msvc.compile-options = ["/W2"]
msvc.compile-definitions = ["PLATFORM=\"msvc\""]
gcc.compile-options = ["-Wall"]
gcc.compile-definitions = ["PLATFORM=\"gcc\""]
clang.compile-options = ["-Wall"]
clang.compile-definitions = ["PLATFORM=\"clang\""]
The hello
target uses conditions to set different compiler flags and definitions depending on the platform. See the targets documentation for other things you can set.
Note: In general you only want to specify flags required to compile your code without errors.
This page was automatically generated from tests/compile-options/cmake.toml.