I am using CMake v3.13.4 with the Visual Studio 2017 Win64
generator and I need to modify the command line options for the Visual Studio Librarian (for a CMake object library).
To achieve that CMake offers the target property STATIC_LIBRARY_OPTIONS
that can be set by the set_property
and set_target_properties
command.
The documentation states that STATIC_LIBRARY_OPTIONS
supports generator expressions:
Contents of
STATIC_LIBRARY_OPTIONS
may use “generator expressions” with the syntax$<...>
. See the cmake-generator-expressions(7) manual for available expressions. See the cmake-buildsystem(7) manual for more on defining buildsystem properties.
But: No matter what I try, the values are not properly escaped´, e.g.
set_property(TARGET object_library PROPERTY STATIC_LIBRARY_OPTIONS $<$<CONFIG:Release>:/WX /NOLOGO /LTCG /ERRORREPORT:NONE>)
leads to the following in Visual Studio:
All Options: `/OUT:"..." /LTCG /MACHINE:X64 /NOLOGO
Additional Options: %(AdditionalOptions) /machine:x64 ""$"<1:/WX" "/ERRORREPORT:NONE>"
I've tried the following, all of them seem to fail.
set_property(TARGET object_library PROPERTY
STATIC_LIBRARY_OPTIONS $<$<CONFIG:Release>:/WX /NOLOGO /LTCG /ERRORREPORT:NONE>
#STATIC_LIBRARY_OPTIONS "$<$<CONFIG:Release>:/WX /NOLOGO /LTCG /ERRORREPORT:NONE>"
#STATIC_LIBRARY_OPTIONS $<$<CONFIG:Release>:"/WX /NOLOGO /LTCG /ERRORREPORT:NONE">
#STATIC_LIBRARY_OPTIONS $<$<CONFIG:Release>:/WX /NOLOGO /LTCG /ERRORREPORT:NONE>
#STATIC_LIBRARY_OPTIONS $<$<CONFIG:Release>:/WX;/NOLOGO;/LTCG;/ERRORREPORT:NONE>
#STATIC_LIBRARY_OPTIONS $<$<CONFIG:Release>:"/WX;/NOLOGO;/LTCG;/ERRORREPORT:NONE">
#STATIC_LIBRARY_OPTIONS "$<$<CONFIG:Release>:/WX;/NOLOGO;/LTCG;/ERRORREPORT:NONE>"
)
So my question is: How can I pass multiple values using generator expressions to STATIC_LIBRARY_OPTIONS
with the set_property
or set_target_properties
command?