[CMake] How to specify $1 for compiler?

Michael Hertling mhertling at online.de
Wed Feb 9 10:30:02 EST 2011


On 02/08/2011 08:12 PM, Jed Brown wrote:
> On Mon, Feb 7, 2011 at 23:35, Jed Brown <jed at 59a2.org> wrote:
> 
>> On Fri, Feb 4, 2011 at 01:31, Michael Hertling <mhertling at online.de>wrote:
>>
>>> With a Makefile generator, you might use a RULE_LAUNCH_COMPILE property:
>>>
>>> SET_TARGET_PROPERTIES(<target> PROPERTIES RULE_LAUNCH_COMPILE "win32fe")
>>>
>>
>> Thanks for these suggestions. I went with this one, but I'll try the other
>> if someone complains (win32fe implies cygwin, I don't know if native Visual
>> Studio builds make sense in that context).
>>
> 
> Hmm, although the Makefile "would work", the compiler tests do not succeed
> because they don't use these properties. Where do I have to munge
> CMAKE_<LANG>_COMPILE_OBJECT to have that version used when testing whether a
> compiler works?

First of all, IIRC, if you need the win32fe wrapper for the compiler
tests, too, you must enable it for the whole project, i.e. you won't
be able to use the plain compiler without win32fe anymore.

On *nix with a simple C project, I can see the following work:

% CC="env gcc" cmake <srcdir>  # Initial configuration!
-- The C compiler identification is GNU
-- Check for working C compiler: /usr/bin/env
-- Check for working C compiler: /usr/bin/env -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
[...]
% make VERBOSE=1
[...]
[...] Building C object CMakeFiles/main.dir/main.c.o
/usr/bin/env gcc -o CMakeFiles/main.dir/main.c.o -c [...]/main.c
[...]

Although CMAKE_C_COMPILER turns out to be "/usr/bin/env", the "gcc" is
always in on it. Thus, setting FC="win32fe f90" before the very first
invocation of CMake on your project will possibly enable the win32fe
wrapper along with the Fortran compiler for the compiler tests as well
as for the actual compilations. If you want to enforce that, you might
have a SET(ENV{FC} "win32fe f90") in your CMakeLists.txt ahead of the
PROJECT() or ENABLE_LANGUAGE() command. In this way, you do not need
the RULE_LAUNCH_COMPILE property. If things keep failing, you should
consider to use a platform file for win32fe as Bill Hoffman already
mentioned.

'hope that helps.

Regards,

Michael


More information about the CMake mailing list