MantisBT - CMake
View Issue Details
0010119CMakeCMakepublic2010-01-11 16:012016-06-10 14:31
Ken Moreland 
Brad King 
normalminorhave not tried
closedmoved 
CMake-2-8 
 
0010119: 64-bit libraries not found with Fortran project
I have a 64-bit Linux machine which means that programs (C, C++, and Fortran) are by default compiled with 64-bit memory access and therefore must be linked against 64-bit libraries. This all works fine for C and C++, but I have found that if the language is Fortran, then FIND_LIBRARY find the 32-bit library instead of the 64-bit version. For example, when I run CMake with the CMakeLists.txt file

PROJECT(findlib Fortran)
FIND_LIBRARY(MATH_LIB m)

on my system I get the following entry in my CMakeCache.txt file.

MATH_LIB:FILEPATH=/usr/lib/libm.so

If I attempt to link with this library, I get an error. However, if I add C to the list of languages like this

PROJECT(findlib Fortran C)
FIND_LIBRARY(MATH_LIB m)

CMake now finds the correct math library.

MATH_LIB:FILEPATH=/usr/lib64/libm.so
No tags attached.
related to 0014870closed Brad King FindMPI.cmake returns 32-bit libraries on 64-bit systems for Fortran-only projects 
Issue History
2010-01-11 16:01Ken MorelandNew Issue
2010-01-12 08:23Brad KingStatusnew => assigned
2010-01-12 08:23Brad KingAssigned To => Brad King
2010-01-12 08:28Brad KingNote Added: 0019096
2010-01-12 09:38Brad KingNote Added: 0019098
2010-06-10 14:59Brad KingNote Added: 0020977
2010-06-10 15:03Brad KingNote Added: 0020978
2012-08-13 10:37Brad KingStatusassigned => backlog
2012-08-13 10:37Brad KingNote Added: 0030529
2014-04-10 10:26Brad KingRelationship addedrelated to 0014870
2016-06-10 14:27Kitware RobotNote Added: 0041639
2016-06-10 14:27Kitware RobotStatusbacklog => resolved
2016-06-10 14:27Kitware RobotResolutionopen => moved
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0019096)
Brad King   
2010-01-12 08:28   
CMake is able to detect that the C compiler produces 64-bit binaries because it can do a try-compile with sizeof(void*) and encode the result in the binary using a combination of preprocessor and C initializer syntax. We'll need a totally different way to detect the Fortran binary type.

It looks like at least some Fortran compilers preprocess with _LP64 defined for 64-bit architectures.
(0019098)
Brad King   
2010-01-12 09:38   
I've committed a fix that will work on at least some platforms, including Linux.

Detect Fortran ABI Information
/cvsroot/CMake/CMake/Modules/CMakeFortranCompiler.cmake.in,v <-- Modules/CMakeFortranCompiler.cmake.in
new revision: 1.15; previous revision: 1.14
/cvsroot/CMake/CMake/Modules/CMakeFortranCompilerABI.F,v <-- Modules/CMakeFortranCompilerABI.F
new revision: 1.2; previous revision: 1.1
(0020977)
Brad King   
2010-06-10 14:59   
Commits of interest:

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6c1e2427 [^]
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0457d531 [^]
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a443308c [^]
(0020978)
Brad King   
2010-06-10 15:03   
Note for future investigation:

Fortran does not expose pointers in the language so we cannot detect their size with code. Preprocessor-based detection works only in some cases. We need a different approach. Perhaps we should try inspecting the binary produced by the compiler ("file a.out"). For ELF-based systems we can detect the binary type using cmELF.
(0030529)
Brad King   
2012-08-13 10:37   
Sending issues I'm not actively working on to the backlog to await someone with time for them.

If an issue you care about is sent to the backlog when you feel it should have been addressed in a different manner, please bring it up on the CMake mailing list for discussion. Sign up for the mailing list here, if you're not already on it:

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

It's easy to re-activate a bug here if you can find a CMake developer or contributor who has the bandwidth to take it on.
(0041639)
Kitware Robot   
2016-06-10 14:27   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.