[CMake] How to define a compiler flags that do not appear in linker command line

Emmanuel Blot eblot.ml at gmail.com
Mon Jun 17 09:32:14 EDT 2013


Hi,

I'm using CMake (2.8.10.1) to cross-compile from OS X and Linux x86_64
hosts to ARM EABI platform running eCos.

I'm looking for a way (and if possible, a clean one ;-)) to define C
compiler flags that are not propagated to the final link stage.

My current CMake files use:

SET (CMAKE_SYSTEM_NAME eCos)
  then
SET (CMAKE_C_FLAGS …)

It seems that the CMAKE_C_FLAGS is also expanded into the link command
line, that is the "<FLAGS>" parameter in

  set(CMAKE_C_LINK_EXECUTABLE    "<CMAKE_C_COMPILER>   <FLAGS>
<CMAKE_C_LINK_FLAGS>   <LINK_FLAGS> <OBJECTS> -o <TARGET> -nostdlib
-nostartfiles -L${ECOS_LIBTARGET_DIRECTORY} -Ttarget.ld  <LINK_LIBRARIES>")

defined with CMake's Modules/Platform/eCos.cmake file (line 56).

As it seems there is no way to tweak <FLAGS> here, I guess there is a
better way to define compiler C flags that are distinct from the linker
flags. In other word, I guess I should not use CMAKE_C_FLAGS but another
variable to define the flags that should appear at compile time but not at
link time.

Anyway, any piece of advice would be warmly welcomed, as I'm unable to find
a clue within the documentation.
It seems there are many way to deal with compiler flags, I tried several of
them (inclusing the TARGET properties) but I've not been able to find a
working solution.

BTW, what does mean the <...> modifiers (rather than the common ${...} one)
? Can/could they be changed ?

Thanks in advance,
Manu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130617/fe4c93ea/attachment.htm>


More information about the CMake mailing list