COMPILE_OPTIONS

List of options to pass to the compiler.

This property holds a semicolon-separated list of options specified so far for its target. Use the target_compile_options() command to append more options. The options will be added after flags in the CMAKE_<LANG>_FLAGS and CMAKE_<LANG>_FLAGS_<CONFIG> variables, but before those propagated from dependencies by the INTERFACE_COMPILE_OPTIONS property.

This property adds compile options for all languages in a target. Use the COMPILE_LANGUAGE generator expression to specify per-language compile options.

This property is initialized by the COMPILE_OPTIONS directory property when a target is created, and is used by the generators to set the options for the compiler.

Contents of COMPILE_OPTIONS may use "generator expressions" with the syntax $<...>. See the cmake-generator-expressions(7) manual for available expressions. See the cmake-buildsystem(7) manual for more on defining buildsystem properties.

Option De-duplication

The final set of options used for a target is constructed by accumulating options from the current target and the usage requirements of its dependencies. The set of options is de-duplicated to avoid repetition.

New in version 3.12: While beneficial for individual options, the de-duplication step can break up option groups. For example, -option A -option B becomes -option A B. One may specify a group of options using shell-like quoting along with a SHELL: prefix. The SHELL: prefix is dropped, and the rest of the option string is parsed using the separate_arguments() UNIX_COMMAND mode. For example, "SHELL:-option A" "SHELL:-option B" becomes -option A -option B.