<div dir="ltr">Hi Marcel,<div><br></div><div>Thanks for your e-mail. I am not sure if your approach wil fully satisfy my use case. I need to compile on both the back-end and front-end.</div><div><br></div><div>My question really boils down to whether it's possible to use two different compilers for the same language within the same configuration.</div><div><br></div><div>I was hoping there would be a way to set properties on individual files or directories and specify a different compiler (as one could specify different compilers flags). Is that possible?</div><div><br></div><div>Perhaps, another alternative is to define a FRONTEND_C, FRONTEND_CXX and FRONTEND_F90 languages, as well as, define associated "add_frontend_executable()" and "add_frontend_library()", which would work with the frontend compiler when we are cross-compiling, or call "add_executable()" and "add_library" otherwise. This may be a bit of overkill though (but very useful), given that only a relative small subset of the project needs to be compiled for the front-end. </div><div><br></div><div>Is there a good guide on how would one could define a different language in CMake?</div><div><br></div><div>I am curious if there are any other known alternatives?</div><div><br></div><div>Cheers,</div><div>George</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 15, 2014 at 1:54 AM, Marcel Loose <span dir="ltr"><<a href="mailto:loose@astron.nl" target="_blank">loose@astron.nl</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
Hi George,<br>
<br>
You could (ab)use the "assembler plugin" system for that. Define
your own CMake-ASM-BGQ*.cmake files and use the assembler to compile
the sources. <br>
<br>
Here's how I did this a couple of years ago for the BG/P.<br>
<br>
In the CMakeLists.txt file for the files that need to be compiled
with the BG/P compiler I have:<br>
<pre>## ---------------------------------------------------------------------------
## Enable BGP specific assembler.
## Use the BGP assembler also for linking C/C++ programs.
## ---------------------------------------------------------------------------
enable_language(ASM-BGP)
set(CMAKE_C_LINK_EXECUTABLE ${CMAKE_ASM-BGP_LINK_EXECUTABLE})
set(CMAKE_CXX_LINK_EXECUTABLE ${CMAKE_ASM-BGP_LINK_EXECUTABLE})
</pre>
CMakeASM-BGPInformation.cmake:<br>
<pre>set(ASM_DIALECT "-BGP")
set(CMAKE_ASM${ASM_DIALECT}_SOURCE_FILE_EXTENSIONS S)
set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT "<CMAKE_ASM${ASM_DIALECT}_COMPILER> <DEFINES> <FLAGS> -c -o <OBJECT> <SOURCE>")
set(CMAKE_ASM${ASM_DIALECT}_LINK_EXECUTABLE "<CMAKE_ASM${ASM_DIALECT}_COMPILER> <FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
include(CMakeASMInformation)
set(ASM_DIALECT)
</pre>
<br>
CMakeDetermineASM-BGPCompiler.cmake:<br>
<pre>set(ASM_DIALECT "-BGP")
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT ${CMAKE_ASM_COMPILER})
include(CMakeDetermineASMCompiler)
set(ASM_DIALECT)
</pre>
CMakeTestASM-BGPCompiler.cmake:<br>
<pre>set(ASM_DIALECT "-BGP")
include(CMakeTestASMCompiler)
set(ASM_DIALECT)
</pre>
<br>
Hope this helps.<br>
<br>
Regards,<br>
Marcel Loose.<div><div class="h5"><br>
<br>
<div>On 15/10/14 04:23, George Zagaris
wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">Dear all,
<div><br>
</div>
<div>I am working on a project where on certain platforms,
namely, on a BG/Q or Cray, we have to cross-compile the code,
but still, there are parts of the code that should only be
compiled for the front end, login nodes.</div>
<div><br>
</div>
<div>Typically, we have a toolchain file, which among other
things sets:</div>
<div>- CMAKE_CXX_COMPILER</div>
<div>- CMAKE_C_COMPILER</div>
<div>- CMAKE_FORTRAN_COMPILER</div>
<div><br>
</div>
<div>to the respective cross-compilers available on the target
platform.</div>
<div><br>
</div>
<div>This compiles everything for the back-end.</div>
<div><br>
</div>
<div>The obvious way to compile front-end tools is to create
another directory, e.g., "front-end-build" and run cmake
therein to re-configure and build with a front-end compiler.</div>
<div><br>
</div>
<div>However, since only a relatively small subset of the files
needs to be compiled for the front-end, it is desirable to do
this within the same build, which leads to my question:</div>
<div><br>
</div>
<div>Is it possible to tell CMake to build certain files with a
different compiler? I know there is a way to set file
properties to control the compiler flags of certain files. Is
there a "blessed" approach to control the compiler for certain
files and/or directories (and avoid things like
set(CMAKE_CXX_COMPILER...) within a CMakeLists file)?</div>
<div><br>
</div>
<div>Thank you very much for all your help.</div>
<div><br>
</div>
<div>Best,</div>
<div>George</div>
<div><br>
</div>
<div> </div>
</div>
<br>
<fieldset></fieldset>
<br>
</blockquote>
<br>
</div></div></div>
<br>--<br>
<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</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>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" target="_blank">http://cmake.org/cmake/help/training.html</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>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/cmake" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a><br></blockquote></div><br></div>