[CMake] Adding definitions to compile one file ?
Gregor Jasny
gjasny at googlemail.com
Thu Jan 21 09:24:00 EST 2016
Hi,
On 21/01/16 15:14, Vania Joloboff wrote:
> Hi
>
> I want to add two definitions to compile one specific files
> in addition to the global definitions.
> I have the following problem. If I use
>
> set_source_files_properties(source.cpp
> PROPERTIES
> COMPILE_DEFINITIONS VAR1=${MY_VAR1} VAR2=${MY_VAR2} )
>
> then I get error message incorrect number of arguments for
> set_source_files_properties
>
> If I put
> set_source_files_properties(source.cpp
> PROPERTIES COMPILE_DEFINITIONS "VAR1=${MY_VAR1} VAR2=${MY_VAR2}" )
Try to delimit the two definitions by a ; to create a list.
Alternatively set property should do the trick:
https://cmake.org/cmake/help/v3.2/command/set_property.html
set_property(SOURCE source.cpp PROPERTY COMPILE_DEFINITIONS
VAR1=${MY_VAR1} VAR2=${MY_VAR2})
With set_property you also have the option to specify APPEND or
APPEND_STRING.
Thanks,
Gregor
More information about the CMake
mailing list