<div>Thank you very much for the answers, David and Michael.</div>
<div> </div>
<div>I am trying to get a QNX compiler to work with CMake. My host comp runs Ubuntu.</div>
<div>I did:</div>
<div> </div>
<div>cmake -G &quot;Unix Makefiles -D CMAKE_C_COMPILER=qcc -D CMAKE_CXX_COMPILER=QCC ..<br></div>
<div>but get</div>
<div>dpkg-architecture: warning: Couldn&#39;t determine gcc system type, falling back to default (native compilation)</div>
<div>cc: unknown option: &#39;-dumpmachine&#39;</div>
<div> </div>
<div>I have of course google&#39;d and found out that I probably have to make a new toolchain file.</div>
<div>Does that seem correct?</div>
<div> </div>
<div>qcc is basicly gcc with modifications and other libraries.</div>
<div>Is there an example toolchain file I can use as basis?</div>
<div> </div>
<div>Is there any documentation about what should be set up in a toolchain file?</div>
<div> </div>
<div>Thank you very much</div>
<div>paul</div>
<div> </div>
<div> </div>
<div><br> </div>
<div class="gmail_quote">On Fri, Nov 18, 2011 at 2:26 PM, Michael Hertling <span dir="ltr">&lt;<a href="mailto:mhertling@online.de" target="_blank">mhertling@online.de</a>&gt;</span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">On 11/17/2011 05:18 PM, Paul Hansen wrote:<br>&gt; Hi<br>&gt;<br>&gt; I have a project that has to be compiled with two different compilers on<br>
&gt; the same computer.<br>&gt;<br>&gt; Can I do that from the same CMakeLists.txt file?<br><br>What do you mean exactly?<br><br>(1) Compile the project twice, each time completely with a different<br>compiler? If so, use two different build trees, as already outlined<br>
in the meantime.<br><br>(2) A part of your project must be compiled with a different compiler<br>than the remaining parts? Difficult - besides a custom-command-based<br>approach, you might outsource the concerned part and reintegrate it<br>
as an external project which can be configured independently with a<br>different toolchain. Look at the following example:<br><br># CMakeLists.txt:<br>CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)<br>PROJECT(MAIN C)<br>
SET(CMAKE_VERBOSE_MAKEFILE ON)<br>SET(SUBCC ${CMAKE_C_COMPILER} CACHE FILEPATH &quot;Subproject C compiler&quot;)<br>INCLUDE(ExternalProject)<br>ExternalProject_Add(sub<br>   SOURCE_DIR ${CMAKE_SOURCE_DIR}/sub<br>   CMAKE_CACHE_ARGS<br>
       -DCMAKE_C_COMPILER:FILEPATH=${SUBCC}<br>       -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}/sub)<br>ADD_LIBRARY(f SHARED IMPORTED)<br>SET_TARGET_PROPERTIES(f PROPERTIES<br>   IMPORTED_LOCATION ${CMAKE_BINARY_DIR}/sub/lib/libf.so)<br>
ADD_DEPENDENCIES(f sub)<br>FILE(WRITE ${CMAKE_BINARY_DIR}/main.c &quot;int main(void){return 0;}\n&quot;)<br>ADD_EXECUTABLE(main main.c)<br>TARGET_LINK_LIBRARIES(main f)<br>ADD_DEPENDENCIES(main f)<br><br>sub/CMakeLists.txt:<br>
CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)<br>PROJECT(SUB C)<br>SET(CMAKE_VERBOSE_MAKEFILE ON)<br>FILE(WRITE ${CMAKE_BINARY_DIR}/f.c &quot;void f(void){}\n&quot;)<br>ADD_LIBRARY(f SHARED f.c)<br>INSTALL(TARGETS f LIBRARY DESTINATION lib)<br>
<br>Configure with the desired SUBCC to see the subproject being built with<br>that instead of the overall project&#39;s C compiler. The downside is that<br>you can&#39;t use FIND_*() on the subproject&#39;s targets since they&#39;re built<br>
after the overall project is already configured, so you must predict<br>their locations. Additionally, there may be issues w.r.t. the correct<br>handling of dependencies. Moreover, if the subproject is to share the<br>overall project&#39;s cache, you need to pass the concerned variables to<br>
ExternalProject_Add() individually, or do some trickery with LOAD_<br>CACHE(). Alternatively, you might use the so-called super-build<br>approach, but be prepared for other issues then, cf. [1].<br><br>&gt; Specifically I am wondering:<br>
&gt; - CMake finds a compiler and makes a test. A colleague has tried to change<br>&gt; the compiler variables but CMake made the test and overwrote his settings<br>&gt; (from the CMakeLists.txt file) in CMakeCache.txt<br>
<br>The toolchain can&#39;t be changed without a complete reconfiguration, and<br>during the latter, CMake even forgets the cache settings specified on<br>the command line, cf. [2].<br><br>&gt; - With target_link_directories I can point out specifically which libraries<br>
&gt; should be used with each executable. But what about header files?<br>&gt; include_directories() is not specified for each executable. Is there anyway<br>&gt; to control what is in the include path at different points in the<br>
&gt; CMakeLists.txt. I have tried to use set_directory_properties(PROPERTIES<br>&gt; INCLUDE_DIRECTORIES &quot;&quot;) to reset include path at one point. The deletion<br>&gt; works but just not at that specific point on CMakeLists.txt.<br>
<br>The INCLUDE_DIRECTORIES directory property is read-only.<br><br>&gt; - If split up into compiler1.cmake and compiler2.cmake I still get the<br>&gt; include_directories() problem since values are &quot;inherited&quot;<br>
<br>In general, I&#39;d recommend to invoke INCLUDE_DIRECTORIES() sufficiently<br>deep within the CMakeLists.txt files&#39; hierarchy to limit the scope of<br>its impact. Possibly, you even need to reorganize your project a bit,<br>
i.e. split one CMakeLists.txt in two and have INCLUDE_DIRECTORIES()<br>called for the latters with the correct directories separately.<br><br>Regards,<br><br>Michael<br><br>[1] <a href="http://www.mail-archive.com/cmake@cmake.org/msg36170.html" target="_blank">http://www.mail-archive.com/cmake@cmake.org/msg36170.html</a><br>
[2] <a href="http://www.mail-archive.com/cmake@cmake.org/msg37060.html" target="_blank">http://www.mail-archive.com/cmake@cmake.org/msg37060.html</a><br><font color="#888888">--<br><br>Powered by <a href="http://www.kitware.com/" target="_blank">www.kitware.com</a><br>
<br>Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br><br>Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>Follow this link to subscribe/unsubscribe:<br><a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br></font></blockquote></div><br>