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