MantisBT - CMake
View Issue Details
0013379CMakeCMakepublic2012-07-06 05:142013-03-04 08:38
Yngve Inntjore Levinsen 
Alex Neundorf 
normalminoralways
closedfixed 
LinuxGNU/Linux3.4.3
CMake 2.8.8 
CMake 2.8.10CMake 2.8.10 
0013379: Toolchain prefix not set correctly for Fortran projects
I have a project involving Fortran, C, and C++. I was writing a toolchain file for MinGW so I could compile Windows binaries on my Linux box. I had the following on the top of my CMakeLists.txt:

project(name Fortran C CXX)

In my toolchain file I sat the C, CXX and Fortran compiler, and root path. What I then noticed was that instead of using the AR/RANLIB with the MinGW prefix, it was using the default /usr/bin/[ar/ranlib].

This was solved simply by changing the order in the project line as described above, to instead read:

project(name C CXX Fortran)

(not having Fortran first). See also mail exchange:
http://www.cmake.org/pipermail/cmake/2012-July/051136.html [^]
and attached two toolchain files in:
http://www.cmake.org/pipermail/cmake/2012-July/051152.html [^]

Please ask if something is unclear. I should also add that I do not know the origin of the problem, so for what I know it does not need to be fortran related.
Create a project with Fortran as the first enabled language
Create a toolchain file which should enable a prefix for additional tools
No tags attached.
has duplicate 0013475closed  Support cross-compiling fortran project in the same way as C and C++ 
log CmakeCrossCetup.log (64,283) 2012-07-20 14:51
https://public.kitware.com/Bug/file/4398/CmakeCrossCetup.log
? CMakeDetermineFortranCompiler.cmake (9,840) 2012-08-22 15:46
https://public.kitware.com/Bug/file/4431/CMakeDetermineFortranCompiler.cmake
? CMakeDetermineCompiler.cmake (2,946) 2012-08-22 16:22
https://public.kitware.com/Bug/file/4433/CMakeDetermineCompiler.cmake
Issue History
2012-07-06 05:14Yngve Inntjore LevinsenNew Issue
2012-07-09 08:39Brad KingAssigned To => Alex Neundorf
2012-07-09 08:39Brad KingStatusnew => assigned
2012-07-14 09:05Eric NOULARDNote Added: 0030047
2012-07-20 14:16ClausKleinNote Added: 0030096
2012-07-20 14:20ClausKleinNote Added: 0030097
2012-07-20 14:21ClausKleinNote Edited: 0030096bug_revision_view_page.php?bugnote_id=30096#r752
2012-07-20 14:22ClausKleinNote Edited: 0030097bug_revision_view_page.php?bugnote_id=30097#r754
2012-07-20 14:51ClausKleinFile Added: CmakeCrossCetup.log
2012-07-25 15:30Alex NeundorfNote Added: 0030124
2012-07-25 16:33Alex NeundorfCategoryCMakeSetup => CMake
2012-08-13 12:42Alex NeundorfTarget Version => CMake 2.8.10
2012-08-15 16:31Alex NeundorfRelationship addedhas duplicate 0013475
2012-08-19 14:36Alex NeundorfNote Added: 0030707
2012-08-19 15:16Yngve Inntjore LevinsenNote Added: 0030708
2012-08-22 15:46Alex NeundorfFile Added: CMakeDetermineFortranCompiler.cmake
2012-08-22 15:47Alex NeundorfNote Added: 0030736
2012-08-22 16:16Yngve Inntjore LevinsenNote Added: 0030739
2012-08-22 16:22Alex NeundorfFile Added: CMakeDetermineCompiler.cmake
2012-08-22 16:23Alex NeundorfNote Added: 0030740
2012-08-23 02:53Yngve Inntjore LevinsenNote Added: 0030746
2012-09-11 11:50Brad KingNote Added: 0030992
2012-09-11 11:50Brad KingStatusassigned => resolved
2012-09-11 11:50Brad KingResolutionopen => fixed
2012-09-11 11:50Brad KingFixed in Version => CMake 2.8.10
2013-03-04 08:38Robert MaynardNote Added: 0032444
2013-03-04 08:38Robert MaynardStatusresolved => closed

Notes
(0030047)
Eric NOULARD   
2012-07-14 09:05   
Alex,

In case you missed it on the ML,
there seems to be a related issue when cross-compiling on Darwin to Windows,
when no language is passed to the project command:
http://www.cmake.org/pipermail/cmake/2012-July/051253.html [^]
(0030096)
ClausKlein   
2012-07-20 14:16   
(edited on: 2012-07-20 14:21)
At least that would help, if not I have to set the language used for each project I use.


--- Modules/CMakeFindBinUtils.cmake 2012-05-20 19:04:26.000000000 +0200
+++ /usr/local/share/cmake-2.8/Modules/CMakeFindBinUtils.cmake 2012-07-20 20:10:00.000000000 +0200
@@ -64,7 +64,7 @@
 
 
 # on Apple there really should be install_name_tool
-IF(APPLE)
+IF(APPLE AND NOT CMAKE_INSTALL_NAME_TOOL)
   FIND_PROGRAM(CMAKE_INSTALL_NAME_TOOL NAMES install_name_tool HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
 
   IF(NOT CMAKE_INSTALL_NAME_TOOL)
@@ -72,4 +72,4 @@
   ENDIF(NOT CMAKE_INSTALL_NAME_TOOL)
 
   MARK_AS_ADVANCED(CMAKE_INSTALL_NAME_TOOL)
-ENDIF(APPLE)
+ENDIF(APPLE AND NOT CMAKE_INSTALL_NAME_TOOL)
claus-kleins-macbook-pro:cmake clausklein$

(0030097)
ClausKlein   
2012-07-20 14:20   
(edited on: 2012-07-20 14:22)
That is the diff at my project on darwin host to cross compile for windows.
The new one works only with patched version of CMakeFindBinUtils.cmake

claus-kleins-macbook-pro:ninja clausklein$ git diff
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9d7f5e1..3a5f007 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -83,7 +83,7 @@ if(compiler STREQUAL clang)
 endif()
 
 # this triggers the compiler detection
-project(ninja CXX)
+project(ninja)
 
 if(verbose)
     set(CMAKE_VERBOSE_MAKEFILE ON)
claus-kleins-macbook-pro:ninja clausklein$

(0030124)
Alex Neundorf   
2012-07-25 15:30   
Since I have never used Fortran and there were not yet any requests for cross compiling support for Fortran, I think I didn't actually add the cross compiling support for Fortran.
I guess I'll have to have a look at it.
(0030707)
Alex Neundorf   
2012-08-19 14:36   
What is the exact name of the fortran cross compiler executable ?
(0030708)
Yngve Inntjore Levinsen   
2012-08-19 15:16   
In my case the name is i486-mingw32-gfortran
(0030736)
Alex Neundorf   
2012-08-22 15:47   
Can you please check whether it works for you if you use the attached CMakeDetermineFortranCompiler.cmake (i.e. put it in the Modules/ dir of your installed cmake) ?
(0030739)
Yngve Inntjore Levinsen   
2012-08-22 16:16   
Missing file:
CMake Error at /usr/share/cmake-2.8/Modules/CMakeDetermineFortranCompiler.cmake:22 (include):
  include could not find load file:

    /usr/share/cmake-2.8/Modules/CMakeDetermineCompiler.cmake

I don't find this file in git neither..?
(0030740)
Alex Neundorf   
2012-08-22 16:23   
Indeed, this file is only three weeks old, I attached it, maybe it works if you simply put it in the Modules/ directory.

Or you can get the whole FortranCrossCompiling2 from cmake stage and build it yourself:
 http://cmake.org/gitweb?p=stage/cmake.git;a=summary [^]
(0030746)
Yngve Inntjore Levinsen   
2012-08-23 02:53   
Yes, these two files works for me, and sets the correct ar/ranlib it seems. Thank you for fixing! :)
(0030992)
Brad King   
2012-09-11 11:50   
This commit applies the changes:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7924aacb [^]
(0032444)
Robert Maynard   
2013-03-04 08:38   
Closing resolved issues that have not been updated in more than 4 months.