[CMake] [cmake-developers] Appending to LINK_FLAGS property of a target doesn't seem to work correctly

Nils Gladitz nilsgladitz at gmail.com
Thu Mar 3 17:02:02 EST 2016


On 03.03.2016 22:57, Dan Liew wrote:
> Hi,
>
> I noticed recently is you do something like this
>
> add_executable(foo a.cpp b.cpp)
> set_property(TARGET shell APPEND PROPERTY LINK_FLAGS "-fopenmp")
> set_property(TARGET shell APPEND PROPERTY LINK_FLAGS "-static")
>
> then the flags that end up being passed to the compiler during linking
> are like this.
>
> gcc -g -O0 -fopenmp;-static
>
> It looks like when using the property with APPEND it becomes a list
> but when emitted the list isn't expanded properly. I noticed this
> using CMake 3.4.3 using the "Unix Makefile" generator.
>
> Is this intentional or is this a bug?

LINK_FLAGS is not a list property; flags have to be whitespace separated.
You can use APPEND_STRING instead of APPEND for this.

Nils


More information about the CMake mailing list