Target Property Macros

blt_add_target_compile_flags

blt_add_target_compile_flags( TO    <target>
                              SCOPE <PUBLIC (Default)| INTERFACE | PRIVATE>
                              FLAGS [FOO [BAR ...]])

Appends compiler flags to a CMake target by appending to the target’s existing flags.

TO
Name of CMake target
SCOPE
Defines the scope of the given flags. Defaults to PUBLIC and is case insensitive.
FLAGS
List of compile flags

This macro provides very similar functionality to CMake’s native add_compile_options() and target_compile_options() commands, but provides more fine-grained scoping for the compile flags on a per target basis.

The given target must be added via CMake’s add_executable() or add_library() commands or with the corresponding blt_add_executable and blt_add_library macros.

PRIVATE flags are used for the given target. INTERFACE flags are inherited by any target that depends on this target. PUBLIC flags are both INTERFACE and PRIVATE.

Note

This macro will strip away leading and trailing whitespace from each flag.

blt_add_target_definitions

blt_add_target_definitions( TO    <target>
                            SCOPE <PUBLIC (Default)| INTERFACE | PRIVATE>
                            TARGET_DEFINITIONS [FOO [BAR ...]])

Appends pre-processor definitions to the given target’s existing flags.

TO
Name of CMake target
SCOPE
Defines the scope of the given definitions. Defaults to PUBLIC and is case insensitive.
TARGET_DEFINITIONS
List of definitions flags

This macro provides very similar functionality to CMake’s native add_definitions() and target_add_definitions() commands, but provides more fine-grained scoping for the compile definitions on a per target basis. Given a list of definitions, e.g., FOO and BAR, this macro adds compiler definitions to the compiler command for the given target, i.e., it will pass -DFOO and -DBAR.

The given target must be added via CMake’s add_executable() or add_library() commands or with the corresponding blt_add_executable and blt_add_library macros.

PRIVATE flags are used for the given target. INTERFACE flags are inherited by any target that depends on this target. PUBLIC flags are both INTERFACE and PRIVATE.

Note

The target definitions can either include or omit the “-D” characters. E.g. the following are all valid ways to add two compile definitions (A=1 and B) to target foo.

Note

This macro will strip away leading and trailing whitespace from each definition.

Example
1
2
3
4
blt_add_target_definitions(TO foo TARGET_DEFINITIONS A=1 B)
blt_add_target_definitions(TO foo TARGET_DEFINITIONS -DA=1 -DB)
blt_add_target_definitions(TO foo TARGET_DEFINITIONS "A=1;-DB")
blt_add_target_definitions(TO foo TARGET_DEFINITIONS " " -DA=1;B)

blt_print_target_properties

blt_print_target_properties(TARGET <target>)

Prints out all properties of the given target.

TARGET
Name of CMake target

The given target must be added via add_executable() or add_library() or with the corresponding blt_add_executable, blt_add_library, blt_import_library, or blt_register_library macros.

Output is of the form for each property:
[<target> property] <property>: <value>

blt_set_target_folder

blt_set_target_folder( TARGET <target>
                       FOLDER <folder>)

Sets the FOLDER property of the given CMake target.

TARGET
Name of CMake target
FOLDER
Name of the folder

This is used to organize properties in an IDE.

This feature is only available when BLT’s ENABLE_FOLDERS option is ON and in CMake generators that support folders (but is safe to call regardless of the generator or value of ENABLE_FOLDERS).

Note

Do not use this macro on header-only, INTERFACE library targets, since this will generate a CMake configuration error.