Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between COMPILE_FLAGS and COMPILE_OPTIONS

Tags:

cmake

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")
like image 271
Peter Avatar asked Jun 19 '14 08:06

Peter


1 Answers

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.

like image 133
steveire Avatar answered Oct 07 '22 00:10

steveire