<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' 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'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.<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't think that's wise.)<br></div><div dir="ltr"><div><br></div><div><div>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:<br></div></div><div><br></div><div><div><div>set(CMAKE_C_FLAGS ${MINIMAL_FLAGS} CACHE STRING "" FORCE)</div><div>set(CMAKE_C_FLAGS_DEBUG ${MINIMAL_FLAGS} CACHE STRING "" FORCE)</div><div>set(CMAKE_C_FLAGS_RELEASE ${MINIMAL_FLAGS} CACHE STRING "" FORCE)</div><div>set(CMAKE_C_FLAGS_RELWITHDEBINFO ${MINIMAL_FLAGS} CACHE STRING "" FORCE)</div><div>set(CMAKE_C_FLAGS_MINSIZEREL ${MINIMAL_FLAGS} CACHE STRING "" FORCE)</div></div><div><br></div></div><div>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?)</div><div><br></div><div><div><div>(I keep asking "is this documented anywhere" because I like to provide references in code for future maintainers. I'm not trying to be unkind. Maybe once I know enough I can volunteer to write any missing docs myself.)</div></div></div><div><br></div><div>How do I add default flags that involve the source file name eg. for a file "main.c" I want to have a C compiler flag "--some_option='main.x'"?</div><div><br></div><div>Finally, this really seems like a lot of work despite the fact that toolchain files are (I thought) meant to be the way to define a different toolchain. It really feels like I'm swimming against the tide here. Is there another, more-CMake-ish way to accomplish what I'm trying to do?</div><div><br></div><div><div>[1] <a href="https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/CrossCompiling">https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/CrossCompiling</a></div><br class="gmail-Apple-interchange-newline"></div><div>Thanks for any help.</div><div><br></div><div>- Jason</div></div></div></div></div></div></div></div></div>