[CMake] Bad flags being passed to NAG Fortran compiler

Neil Carlson neil.n.carlson at gmail.com
Sun Feb 17 19:13:17 EST 2013


When building a shared library using the NAG Fortran compiler, cmake is
invoking
the compiler with the "-fPIC" option.  This is wrong.  The correct option
is "-PIC".
I've found I can get things to work if I add the following two lines to my
CMakeLists.txt
file (probably not the right way to fix things):

set(CMAKE_Fortran_COMPILE_OPTIONS_PIC "-PIC")
set(CMAKE_SHARED_LIBRARY_Fortran_FLAGS "-PIC")

Several questions (I'm *very* new to cmake, so apologies if they're stupid):
1)  I've found the file Modules/Platform/Linux-NAG-Fortran.cmake.  Is that
where
    compiler-specific settings like this belong?   And are the above two
lines the
    correct thing to add to that file?
2) Is there a maintainer for the Fortran (esp. NAG) related module files?
 I suspect
    that there are other areas where cmake will not drive the NAG compiler
correctly.
3) Until this is fixed in cmake, I need to find a robust way of making this
work.  the
    problem with what I did above is that I only want to set the variables
if I'm using
    the NAG compiler.  Is there some cmake variable available that gives
the identity
    of the Fortran compiler it identified against which I can test?  Or can
my code
    distribution include a "fixed" version of Linux-NAG-Fortran.cmake
(assuming it's the
    culprit) that somehow gets used instead?  What are the standard
strategies
    in cases like this?

Thanks for your help!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130217/838740ed/attachment.htm>


More information about the CMake mailing list