[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cmake
Subject:    Re: [CMake] Separate compile flags for ASM/C compilers and lists
From:       Andreas Pakulat <apaku () gmx ! de>
Date:       2013-09-16 9:46:34
Message-ID: CAExHGmSR4XOPsrTgAcLcvYT3JQi=X3Z+CLzNRpTNujcnH6Kccw () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi,

On Mon, Sep 16, 2013 at 10:24 AM, Nikolay <lorddoskias@gmail.com> wrote:

>
> On 14 September 2013 09:59, Alexander Neundorf <a.neundorf-work@gmx.net>wrote:
>
>> On Friday 13 September 2013, lorddoskias wrote:
>> > Hello list,
>> >
>> > I have a couple of questions whose answers I couldn't find. So first
>> > thing's first - I have the following function which I intend to use to
>> > add a number of library targets:
>> >
>> > function(build_mps_m3_lib LIBRARY_NAME C_SOURCE ASM_SOURCE CPU_TYPE)
>> >      set_property(SOURCE ${${C_SOURCE}} PROPERTY COMPILE_FLAGS "-g
>> > --cpu=${CPU_TYPE} -O0")
>> >      set_property(SOURCE ${${ASM_SOURCE}} PROPERTY COMPILE_FLAGS "-g
>> > --cpu=${CPU_TYPE} --apcs=interwork")
>> >      add_library(${LIBRARY_NAME}  ${${SOURCE}} ${${ASM_SOURCE}})
>> >      set(TARGET_DIR "mps-m3")
>> >      set(ASM_COMPILE_FLAGS "-g --cpu=${CPU_TYPE} --apcs=interwork")
>> >      #custom armasm command line
>> >      set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER>
>> > ${ASM_COMPILE_FLAGS} <SOURCE> -o <OBJECT>")
>> >      #set_target_properties(${LIBRARY_NAME} PROPERTIES C_COMPILE_FLAGS
>> > "-g --cpu=${CPU_TYPE} -O0")
>> > endfunction(build_mps_m3_lib)
>> >
>> >
>> > What I want to achieve is to have clear separation between the ASM
>> > compiler flags and the C compiler flags. Since I'm not using the GNU
>> > (ergo GCC) toolchain I cannot simply set the properties on the resulting
>> > library target to set the COMPILE_FLAGS. Essentially what I want to
>> > achieve is being able to set arbitrary compile options for the C and ASM
>> > compiler WITHOUT both of those interfering.
>>
>> In general they don't interfer.
>> What compiler and assembler are you using ?
>> Maybe you need a new "assembler dialect". Those are quite simply to do,
>> you
>> can have a look e.g. at the files containing "MASM" in their name in
>> Modules/.
>>
>
> Unfortunately I do not find the statement "In generla they don't interfere
> to be correct". Here is what I'm talking about:
>
> The default definitions of ASM_COMPILE_OBJECT is : ASM_COMPILE_OBJECTP:
> <CMAKE_ASM_COMPILER> <DEFINES> <FLAGS> -o <OBJECT> -c <SOURCE>
>
> meaning it will include all defines/flags set by
> add_definition/set_target_properties for COMPILE_DEFINITIONS or
> COMPILER_FLAGS. Unfortunately if I have something like the following:
> add_library(tx-mps-m4 ${KERNEL_SOURCE})
> set_target_properties(tx-mps-m4 PROPERTIES COMPILE_FLAGS "-g
> --cpu=cortex-m4 -O0")
>
> I get the exact same flags (-g --cpu and -O0) passed to the assmebler
> (armasm) in my case. And the assembler doesn't understand the -O0 and it
> exists. How can I avoid this situation?
>

Don't set those properties on the target. Instead use
set_source_file_properties to set those flags that differ between different
types of source files. CMake supports setting compile definitions as well
as flags for each source file individually.

Andreas

[Attachment #5 (text/html)]

<div dir="ltr">Hi,<div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep \
16, 2013 at 10:24 AM, Nikolay <span dir="ltr">&lt;<a \
href="mailto:lorddoskias@gmail.com" \
target="_blank">lorddoskias@gmail.com</a>&gt;</span> wrote:<br> <blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><div \
class="gmail_quote"><div><div class="h5">On 14 September 2013 09:59, Alexander \
Neundorf <span dir="ltr">&lt;<a href="mailto:a.neundorf-work@gmx.net" \
target="_blank">a.neundorf-work@gmx.net</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex"><div><div>On Friday 13 September 2013, lorddoskias \
wrote:<br> &gt; Hello list,<br>
&gt;<br>
&gt; I have a couple of questions whose answers I couldn&#39;t find. So first<br>
&gt; thing&#39;s first - I have the following function which I intend to use to<br>
&gt; add a number of library targets:<br>
&gt;<br>
&gt; function(build_mps_m3_lib LIBRARY_NAME C_SOURCE ASM_SOURCE CPU_TYPE)<br>
&gt;      set_property(SOURCE ${${C_SOURCE}} PROPERTY COMPILE_FLAGS &quot;-g<br>
&gt; --cpu=${CPU_TYPE} -O0&quot;)<br>
&gt;      set_property(SOURCE ${${ASM_SOURCE}} PROPERTY COMPILE_FLAGS &quot;-g<br>
&gt; --cpu=${CPU_TYPE} --apcs=interwork&quot;)<br>
&gt;      add_library(${LIBRARY_NAME}  ${${SOURCE}} ${${ASM_SOURCE}})<br>
&gt;      set(TARGET_DIR &quot;mps-m3&quot;)<br>
&gt;      set(ASM_COMPILE_FLAGS &quot;-g --cpu=${CPU_TYPE} \
--apcs=interwork&quot;)<br> &gt;      #custom armasm command line<br>
&gt;      set(CMAKE_ASM_COMPILE_OBJECT &quot;&lt;CMAKE_ASM_COMPILER&gt;<br>
&gt; ${ASM_COMPILE_FLAGS} &lt;SOURCE&gt; -o &lt;OBJECT&gt;&quot;)<br>
&gt;      #set_target_properties(${LIBRARY_NAME} PROPERTIES C_COMPILE_FLAGS<br>
&gt; &quot;-g --cpu=${CPU_TYPE} -O0&quot;)<br>
&gt; endfunction(build_mps_m3_lib)<br>
&gt;<br>
&gt;<br>
&gt; What I want to achieve is to have clear separation between the ASM<br>
&gt; compiler flags and the C compiler flags. Since I&#39;m not using the GNU<br>
&gt; (ergo GCC) toolchain I cannot simply set the properties on the resulting<br>
&gt; library target to set the COMPILE_FLAGS. Essentially what I want to<br>
&gt; achieve is being able to set arbitrary compile options for the C and ASM<br>
&gt; compiler WITHOUT both of those interfering.<br>
<br>
</div></div>In general they don&#39;t interfer.<br>
What compiler and assembler are you using ?<br>
Maybe you need a new &quot;assembler dialect&quot;. Those are quite simply to do, \
you<br> can have a look e.g. at the files containing &quot;MASM&quot; in their name \
in Modules/.<br></blockquote><div><br></div></div></div><div>Unfortunately I do not \
find the statement &quot;In generla they don&#39;t interfere to be correct&quot;. \
Here is what I&#39;m talking about: <br>

<br></div><div>The default definitions of ASM_COMPILE_OBJECT is : \
ASM_COMPILE_OBJECTP: &lt;CMAKE_ASM_COMPILER&gt; &lt;DEFINES&gt; &lt;FLAGS&gt; -o \
&lt;OBJECT&gt; -c &lt;SOURCE&gt; <br><br></div><div>meaning it will include all \
defines/flags set by add_definition/set_target_properties for COMPILE_DEFINITIONS or \
COMPILER_FLAGS. Unfortunately if I have something like the following: <br>

add_library(tx-mps-m4 ${KERNEL_SOURCE})<br>set_target_properties(tx-mps-m4 PROPERTIES \
COMPILE_FLAGS &quot;-g --cpu=cortex-m4 -O0&quot;)<br><br></div><div>I get the exact \
same flags (-g --cpu and -O0) passed to the assmebler (armasm) in my case. And the \
assembler doesn&#39;t understand the -O0 and it exists. How can I avoid this \
situation?<br>

</div><div class="im"><div></div></div></div></div></div></blockquote></div></div><div \
class="gmail_extra"><br></div><div class="gmail_extra">Don&#39;t set those properties \
on the target. Instead use set_source_file_properties to set those flags that differ \
between different types of source files. CMake supports setting compile definitions \
as well as flags for each source file individually.</div> <div \
class="gmail_extra"><br></div><div class="gmail_extra">Andreas</div><div \
class="gmail_extra"><br></div></div>



--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: \
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information \
on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at \
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic