[CMake] Fortan and C++
Dominik Szczerba
dominik at itis.ethz.ch
Sat Aug 22 07:35:07 EDT 2009
Here the report of my tests:
Just ignorant approach (don't google):
It works out of the box on linux with intel compilers 10.x. Just add
Fortran to the languages in the project signature and add STUFF.F90 to
the source files. You need to link to ifcore library though.
It does not work out of the box with the compilers 11.x. Here the
ignorant approach failed. The errors were like:
-- Check for working CXX compiler: /usr/local/bin/icpc-11.0.083
-- Check for working CXX compiler: /usr/local/bin/icpc-11.0.083 -- broken
CMake Error at
/usr/local/share/cmake-2.6/Modules/CMakeTestCXXCompiler.cmake:25 (MESSAGE):
The C++ compiler "/usr/local/bin/icpc-11.0.083" is not able to compile a
simple test program.
It fails with the following output:
Change Dir: /home/domel/build/solve/CMakeFiles/CMakeTmp
Checking by foot what the compilers at all say during compilations I found:
> icpc-11.0.083 -c test.cxx
Catastrophic error: could not set locale "" to allow processing of
multibyte characters
Googling reveals a bug in the compiler to be circumvented with adding
'-no-multibyte-chars' to the compiler switches. However, adding this to
my CMAKE_XXX_FLAGS_RELEASE (my CMAKE_BUILD_TYPE is RELEASE) does not
help. I must now either specify CMAKE_XXX_FLAGS explicitly on the
commandline or in the cache. Probably because cmake uses default flags
(CMAKE_XXX_FLAGS) for compiler checks, even if CMAKE_BUILD_TYPE is
explicitly set release/debug (as well as corresponding release/debug flags).
Maybe cmake should use compiler flags as defined by CMAKE_BUILD_TYPE to
check for compilers?
- Dominik
Dominik Szczerba wrote:
> Michael,
> Many thanks for the feedback.
> What I am doing with a GNU makefile so far is compile just one file with
> the fortran compiler use C++ linker to link all object files as usual.
> A comprehensive solution I would expect in cmake would be 1) nothing
> (.f90 file is understood) or something along the lines of setting the
> file properties (sort of 'to be compiler with' flag)...
>
> - Dominik
>
> Michael Wild wrote:
>>
>>
>> On 21.08.2009, at 17:57, Dominik Szczerba <dominik at itis.ethz.ch> wrote:
>>
>>> I want to compile one file with fortran compiler (intel) and link
>>> with the rest of my project. Will the latest cmake allow to fully
>>> cmakify such scenario?
>> Hi Dominik
>>
>> If I remember correctly, you'll have to set the LINK_LANGUAGE property
>> of your target to Fortran and then ensure that the Fortran linker also
>> links against the C++ standard library. For Intel this would be -stdc+
>> + (or some such). If you are creating an executable, depending on
>> where your main-function is defined, you might also need to tell the
>> linker to not add a Fortran main-function, the flag is called -
>> nofor_main if I remember correctly. Otherwise the ifort man-page will
>> tell you :)
>>
>>
>> HTH
>>
>> Michael
>>
>>
>
>
--
d o m i n i k s z c z e r b a , p h d . . . . . . . . . . .
c o m p u t a t i o n a l l i f e s c i e n c e g r o u p
. . . . . . . i t ' i s r e s e a r c h f o u n d a t i o n
. . . . . . . . . . . . . . . . . . . . http://www.itis.ethz.ch
More information about the CMake
mailing list