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

List:       cmake
Subject:    Re: [CMake] Toolchain file for TI in CMake 3.10: how do I override compiler options and specify tool
From:       frodak17 <frodak17 () gmail ! com>
Date:       2019-02-23 21:46:18
Message-ID: CAM_JqVkmGqVZXR2xw=v1cVamisT9ga+BD=SrnVjqcNxkx5=32A () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


On Sat, Feb 23, 2019 at 2:24 PM Cristian Adam <cristian.adam@gmail.com>
wrote:

>
>
> On Sat, Feb 23, 2019 at 8:49 AM Jason Heeris <jason.heeris@gmail.com>
> wrote:
>
>> I am trying to use CMake (3.10) to build an ANSI C project that may be
>> compiled on PC with eg. GCC, but also needs to compile with Texas
>> Instruments' compilers for their microprocessors. So I have about a million
>> questions.
>>
>> According to[1] it seems like the way to do this is via a toolchain file.
>> So I'm trying to write a toolchain file to use TI's compiler/linker/etc,
>> which do not (always) take the same arguments as eg. GCC or Clang.
>>
>> Is there a complete list of tools I can override in a toolchain file?
>> Specifically, I want to set the C compiler, C++ compiler, assembler and
>> linker. I know about CMAKE_C(XX)_COMPILER, but what about the others? Are
>> they documented anywhere? (I could guess, but I don't think that's wise.)
>>
>> As I mentioned, TI's tools aren't the same as GCC, so I need to pare back
>> a lot of options and start from almost-scratch (there are some
>> commonalities). Options like "-D" and "-I" are fine, which is good because
>> then eg. target_include_directories() still works. But certain other flags
>> are just going to cause errors. How do I completely remove all compile
>> flags from the generated Makefiles and replace them with my own? I can do
>> this:
>>
>> set(CMAKE_C_FLAGS ${MINIMAL_FLAGS} CACHE STRING "" FORCE)
>> set(CMAKE_C_FLAGS_DEBUG ${MINIMAL_FLAGS} CACHE STRING "" FORCE)
>> set(CMAKE_C_FLAGS_RELEASE ${MINIMAL_FLAGS} CACHE STRING "" FORCE)
>> set(CMAKE_C_FLAGS_RELWITHDEBINFO ${MINIMAL_FLAGS} CACHE STRING "" FORCE)
>> set(CMAKE_C_FLAGS_MINSIZEREL ${MINIMAL_FLAGS} CACHE STRING "" FORCE)
>>
>> But I *still* see flags in the generated makefiles that I didn't put
>> there such as "--compile_only" and "--c_file=...". How do I get rid of
>> these and specify what's correct for my toolchain? (Also, why do I need the
>> CACHE STRING "" FORCE options? I pulled that out of various Stackoverflow
>> posts but I have no idea why it's necessary. Is that documented? What about
>> the configurations... where are they listed? Do I have them all?)
>>
>>
> Regarding the CMAKE_<LANG>_FLAGS_<CONFIG> have a look at this blog post:
> https://cristianadam.eu/20190223/modifying-the-default-cmake-build-types/
>
> You "just" need to modify the CMAKE_<LANG>_FLAGS_<CONFIG>_INIT variables,
> no need to force the cache entries.
>
> The "Modules" CMake folder is your friend, you can see how CMake handles
> other compilers.
> For debugging use CMake's "--trace-expand" command line parameter.
>
> Cheers,
> Cristian.
>
>
Take a look at Modules/CMakeCInformation.cmake.
Also CMAKE_USER_MAKE_RULES_OVERRIDE may be useful to you.
There are a few others that may also be used depending on what languages
you are trying to use.

StackOverflow isn't always correct even if something is marked as answered
and up-voted.

FYI, The "--compile_only" and "--c_file" probably come from the file
Modules/Compiler/TI-C.cmake.  At some point TI compilers were using those
options to build files but I guess in your case the compiler is no longer
compatible with what it used to be.

[Attachment #5 (text/html)]

<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"></div><br><div \
class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Feb 23, 2019 at 2:24 PM \
Cristian Adam &lt;<a \
href="mailto:cristian.adam@gmail.com">cristian.adam@gmail.com</a>&gt; \
wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div \
dir="ltr"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div \
dir="ltr" class="gmail_attr">On Sat, Feb 23, 2019 at 8:49 AM Jason Heeris &lt;<a \
href="mailto:jason.heeris@gmail.com" target="_blank">jason.heeris@gmail.com</a>&gt; \
wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div \
dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div \
dir="ltr"><div>I am trying to use CMake (3.10) to build an ANSI C project that may be \
compiled on PC with eg. GCC, but also needs to compile with Texas Instruments&#39; \
compilers for their microprocessors. So I have about a million \
questions.</div><div><br></div><div>According to[1] it seems like the way to do this \
is via a toolchain file. So I&#39;m trying to write a toolchain file to use TI&#39;s \
compiler/linker/etc, which do not (always) take the same arguments as eg. GCC or \
Clang.<br></div><div><br></div><div>Is there a complete list of tools I can override \
in a toolchain file? Specifically, I want to set the C compiler, C++ compiler, \
assembler and linker. I know about CMAKE_C(XX)_COMPILER, but what about the others? \
Are they documented anywhere? (I could guess, but I don&#39;t think that&#39;s \
wise.)<br></div><div dir="ltr"><div><br></div><div><div>As I mentioned, TI&#39;s \
tools aren&#39;t the same as GCC, so I need to pare back a lot of options and start \
from almost-scratch (there are some commonalities). Options like &quot;-D&quot; and \
&quot;-I&quot; are fine, which is good because then eg. target_include_directories() \
still works. But certain other flags are just going to cause errors. How do I \
completely remove all compile flags from the generated Makefiles and replace them \
with my own? I can do \
this:<br></div></div><div><br></div><div><div><div>set(CMAKE_C_FLAGS ${MINIMAL_FLAGS} \
CACHE STRING &quot;&quot; FORCE)</div><div>set(CMAKE_C_FLAGS_DEBUG ${MINIMAL_FLAGS} \
CACHE STRING &quot;&quot; FORCE)</div><div>set(CMAKE_C_FLAGS_RELEASE ${MINIMAL_FLAGS} \
CACHE STRING &quot;&quot; FORCE)</div><div>set(CMAKE_C_FLAGS_RELWITHDEBINFO \
${MINIMAL_FLAGS} CACHE STRING &quot;&quot; \
FORCE)</div><div>set(CMAKE_C_FLAGS_MINSIZEREL ${MINIMAL_FLAGS} CACHE STRING \
&quot;&quot; FORCE)</div></div><div><br></div></div><div>But I *still* see flags in \
the generated makefiles that I didn&#39;t put there such as \
&quot;--compile_only&quot; and &quot;--c_file=...&quot;. How do I get rid of these \
and specify what&#39;s correct for my toolchain? (Also, why do I need the CACHE \
STRING &quot;&quot; FORCE options? I pulled that out of various Stackoverflow posts \
but I have no idea why it&#39;s necessary. Is that documented? What about the \
configurations... where are they listed? Do I have them \
all?)</div><div><br></div></div></div></div></div></div></div></div></div></blockquote><div><br></div><div>Regarding \
the CMAKE_&lt;LANG&gt;_FLAGS_&lt;CONFIG&gt; have a look at this blog \
post:</div><div><a href="https://cristianadam.eu/20190223/modifying-the-default-cmake-build-types/" \
target="_blank">https://cristianadam.eu/20190223/modifying-the-default-cmake-build-types/</a></div><div><br></div><div>You \
&quot;just&quot; need to modify the CMAKE_&lt;LANG&gt;_FLAGS_&lt;CONFIG&gt;_INIT \
variables, no need to force the cache entries.</div><div><br></div><div>The \
&quot;Modules&quot; CMake folder is your friend, you can see how CMake handles other \
compilers.  </div><div>For debugging use CMake&#39;s &quot;--trace-expand&quot; \
command line parameter.  \
</div><div><br></div><div>Cheers,</div><div>Cristian.</div></div></div></div></div><br></blockquote></div><div \
class="gmail_quote"><br></div><div class="gmail_quote">Take a look at \
Modules/CMakeCInformation.cmake.</div><div class="gmail_quote">Also \
CMAKE_USER_MAKE_RULES_OVERRIDE may be useful to you.<br></div><div \
class="gmail_quote">There are a few others that may also be used depending on what \
languages you are trying to use.<br></div><div class="gmail_quote"><br></div><div \
class="gmail_quote">StackOverflow isn&#39;t always correct even if something is \
marked as answered and up-voted.</div><div class="gmail_quote"><br></div><div \
class="gmail_quote">FYI, The &quot;--compile_only&quot; and &quot;--c_file&quot; \
probably come from the file Modules/Compiler/TI-C.cmake.   At some point TI compilers \
were using those options to build files but I guess in your case the compiler is no \
longer compatible with what it used to be.</div><div \
class="gmail_quote"><br></div><div class="gmail_quote"></div></div></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:
https://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