12

What is the difference between

COMPILE_FLAGS: Additional flags to use when compiling this target's sources.

and

COMPILE_OPTIONS: List of options to pass to the compiler.

In terms of resulting VS2010 solution these commands produce the same result:

target_compile_options(target PRIVATE "/option=test1")
set_target_properties(target PROPERTIES COMPILE_FLAGS "/option=test1")
set_target_properties(target PROPERTIES COMPILE_OPTIONS "/option=test1")
Peter Petrik
  • 9,701
  • 5
  • 41
  • 65

2 Answers2

19

COMPILE_OPTIONS is a list, but COMPILE_FLAGS is a string.

set_target_properties(target PROPERTIES 
    COMPILE_OPTIONS "/option=test1;/option2=test2")
set_target_properties(target PROPERTIES 
    COMPILE_FLAGS "/option=test1 /option2=test2")

You can more-easily append to a list than to a string.

Also, COMPILE_OPTIONS is properly escaped, whereas some characters in COMPILE_FLAGS may need to be escaped manually or cause problems.

steveire
  • 10,694
  • 1
  • 37
  • 48
  • 1
    I was more wondering about difference between the target properties itself, not a way how to set them. question edited – Peter Petrik Jun 19 '14 at 12:24
  • I don't know what you're missing. The way to set the properties does not affect the fact that one is a string and the other is a list. Answer edited too. – steveire Jun 19 '14 at 13:43
2

Can be used to the same end, but flags are associated with some target enviroment. So you could use different sets of flags for different enviroments.

vicenteherrera
  • 1,442
  • 17
  • 20