[CMake] Linker Flag error with SET

Bill Hoffman bill.hoffman at kitware.com
Mon Aug 3 08:52:46 EDT 2009


Matthias Noll wrote:
> Hi all,
> 
> I have a problem while adding something to the linker command line with 
> cmake. I'm trying to use the set command like this
> 
> SET(CMAKE_SHARED_LINKER_FLAGS ${CMAKE_MODULE_LINKER_FLAGS} 
> /NODEFAULTLIB:atlthunk )
> 
> After generation the value /NODEFAULTLIB:atlthunk is included in the 
> command line but there is also a
> 
> ";" between the old values and my new one. But the ";" results in a 
> error. How can I prevent the ";" to appear.
> 
You need to quote it:

SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}
/NODEFAULTLIB:atlthunk" )

CMake uses ; as a list separator so set(a b c) ends up as a;b;c, but 
set("a b c") is "a b c". (http://www.cmake.org/cmake/help/syntax.html)


-Bill


More information about the CMake mailing list