CMake: Is there a difference between set_property(TARGET …) and set_target_properties?

Consider set_target_properties() as a specialized form of set_property().

Advantages of …

  • set_target_properties(...) is a convenience function because it allows to set multiple properties of multiple targets.

    For example:

    add_executable(a ...)
    add_executable(b ...)
    set_target_properties(
        a 
        b
        PROPERTIES 
            LINKER_LANGUAGE CXX
            FOLDER          "Executable"
    )
    
  • set_property(TARGET ...) can APPEND to a list- or APPEND_STRING to a string-based property of targets.

    For example:

    add_executable(a ...)
    set_property(
        TARGET a
        APPEND PROPERTY
            INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}"
    )  
    

References

  • How to change the name of the output binary to not be a.out with CMake?
  • target_include_directories prior to 2.8.12?
  • Appending compiler flags to a file with CMake

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)