[CMake] Setting target properties

Tyler Roscoe tyler at cryptio.net
Thu Aug 27 16:58:46 EDT 2009


On Thu, Aug 27, 2009 at 11:11:54PM +0400, Andrey Maslennikov wrote:
> file. How can I define and undefine macros in *one* CMakeLists file?
> 
> For this case more useful another command - set_target_properties() with
> property COMPILE_FLAGS. It really helped me, but I was confronted with
> difficulties in this way. I can't call it with 2 parameters, like
> set_target_properties( target PROPERTIES COMPILE_FLAGS -D__flag1__
> COMPILE_FLAGS -D__flag2__ ). In this case no keys were defined... It's very
> strange, because CMake's documentation present usage example with multiple
> properties in one command. I solved this issue with variable which contains
> all needed keys.

You probably want set_source_files_properties().

In y our set_target_properties example, how about:

set_target_properties( target PROPERTIES COMPILE_FLAGS "-Dflag1 -Dflag2")

tyler


More information about the CMake mailing list