MantisBT - CMake
View Issue Details
0013038CMakeCMakepublic2012-03-12 13:042012-09-03 16:00
Marcin Wojdyr 
Brad King 
normalmajoralways
closedno change required 
Linux
CMake 2.8.7 
 
0013038: cannot set CMAKE_AR when cross-compiling Fortran-only project
I'm trying to cross-compile LAPACK 3.4.0 on Fedora using MinGW cross-compiler.
Binutils paths are not set correctly.

The CMAKE_AR in cache file is set to /usr/bin/ar, even if I explicitly set in toolchain file
SET(CMAKE_AR:FILEPATH /usr/bin/i686-pc-mingw32-ar)
or
SET(CMAKE_AR /usr/bin/i686-pc-mingw32-ar)

The only way to have the paths set correctly is to do:
SET(_CMAKE_TOOLCHAIN_PREFIX i686-pc-mingw32-)
but this is cmake internal variable.

I don't know cmake well, so I may be wrong, but I'd suppose there are two issues here.

1. _CMAKE_TOOLCHAIN_PREFIX is set in CMakeDetermineCCompiler and CMakeDetermineCXXCompiler.cmake, but not in CMakeDetermineFortranCompiler.
Most of Fortran projects use also C, so it is set anyway, but LAPACK has only Fortran.

2. CMAKE_AR and CMAKE_RANLIB set explicitly are not respected.

Last note: it used to work, I cross-compiled this or previous lapack version with cmake 2.8.5 or 6.
No tags attached.
Issue History
2012-03-12 13:04Marcin WojdyrNew Issue
2012-03-12 15:24Brad KingNote Added: 0028897
2012-03-12 16:15Marcin WojdyrNote Added: 0028898
2012-03-12 16:20Brad KingNote Added: 0028899
2012-03-12 16:20Brad KingStatusnew => resolved
2012-03-12 16:20Brad KingResolutionopen => no change required
2012-03-12 16:20Brad KingAssigned To => Brad King
2012-09-03 16:00David ColeNote Added: 0030835
2012-09-03 16:00David ColeStatusresolved => closed

Notes
(0028897)
Brad King   
2012-03-12 15:24   
In the toolchain file try

  set(CMAKE_AR /usr/bin/i686-pc-mingw32-ar CACHE FILEPATH "Archiver")

and then test with a fresh build tree.
(0028898)
Marcin Wojdyr   
2012-03-12 16:15   
It works. Could you explain why?
(0028899)
Brad King   
2012-03-12 16:20   
CMAKE_AR caches the result for "find_program":

  http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:find_program [^]
  "A cache entry named by <VAR> is created to store the result of this command."

Read the documentation of the "set" command:

  http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:set [^]
  "If CACHE is present, then the <variable> is put in the cache."

to see how to set cache values. Please visit the mailing list:

  http://www.cmake.org/mailman/listinfo/cmake [^]

for further help.
(0030835)
David Cole   
2012-09-03 16:00   
Closing resolved issues that have not been updated in more than 4 months.