<div dir="ltr"><div><div><div><div><div><div><div>I'm trying to create binaries as statically as possible. The fortran code I've got has got X11 and quadmath as dependencies, and I've come across a number of issues (maybe each of these issues should be in a different email?):<br>
</div></div><br></div> - My variables are currently<br><br>set(CMAKE_LIBRARY_PATH /usr/X11/lib /usr/X11/include/X11 ${CMAKE_LIBRARY_PATH})<br>find_package(X11 REQUIRED)<br>find_library(X11 NAMES X11.a PATHS /usr/X11/include/X11/ /usr/X11/lib) <br>
find_library(X11_Xaw_LIB NAMES Xaw Xaw /usr/X11/include/X11/ /usr/X11/lib ${X11_LIB_SEARCH_PATH})<br>find_library(Xaw Xaw7 PATHS ${X11_LIB_SEARCH_PATH})<br><br>set(CMAKE_LIBRARY_PATH /usr/lib/gcc/x86_64-linux-gnu/4.7 /usr/lib/gcc/x86_64-linux-gnu/4.7/x32 /usr/lib/gcc/x86_64-linux-gnu/4.7/32 ${CMAKE_LIBRARY_PATH})<br>
<br>find_library(quadmath NAMES quadmath.a)<br><br>set(BUILD_SHARED_LIBS ON)<br>set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})<br>set(LINK_SEARCH_START_STATIC TRUE)<br>set(LINK_SEARCH_END_STATIC TRUE)<br>
<br>set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")<br><br></div>Using these, CMake attempts to build *every* program statically (as expected) - however, it fails because I don't have Xaw.a - I can't find out whether this actually should exist. I have installed the latest libxaw7-dev which I was expecting to fix it. One option would be to compile the X11 libraries myself, but I don't really want to do that...<br>
<br></div> - if I comment out only 'set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")', then CMake compiles everything, *but* uses shared libraries for every program, even though I specify the location of .a X11 libraries in my find_library() calls. I was expecting CMake to use the .a files where it could and then only use shared libraries - is there a way to force this behaviour?<br>
<br> - does anyone know yet of a fix for the bug
described here: <a href="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46539">http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46539</a>;
whereby gfortran seemingly can't statically link libquadmath? I tried
the fix using gcc but I can't get CMake to recognise the libgfortran
flag:<br><br> cmake -DCMAKE_Fortran_COMPILER=gcc -DCMAKE_Fortran_FLAGS=-gfortran<br><br>results in<br><br>-- The Fortran compiler identification is unknown<br>-- Check for working Fortran compiler: /usr/bin/gcc<br>-- Check for working Fortran compiler: /usr/bin/gcc -- broken<br>
CMake Error at /usr/share/cmake-2.8/Modules/CMakeTestFortranCompiler.cmake:54 (message):<br> The Fortran compiler "/usr/bin/gcc" is not able to compile a simple test<br> program.<br><br></div>*However*, as you might have noticed, I set the location of the libquadmath.a; when I build a program which doesn't use X11 but does use quadmath when I use <br>
<br>set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")<br><br></div>then the program does compile successfully (running ldd reports 'not a dynamic executable') - does this mean that the bug has been fixed, or does it only work because I set the location in CMake?<br>
</div>