Skip to content

CMake: Improve module finding #16

@certik

Description

@certik

If Lapack is installed in a custom location, the only way to compile dftatom is via this hack:

$ CC=gcc CXX=g++ FC=gfortran cmake -DWITH_C_INTERFACE=yes -DWITH_LAPACK=yes . -DCMAKE_SHARED_LINKER_FLAGS="-L$HASHSTACK/lib -Wl,-rpath,$HASHSTACK/lib" -DCMAKE_EXE_LINKER_FLAGS="-L$HASHSTACK/lib -Wl,-rpath,$HASHSTACK/lib" -DCMAKE_MODULE_LINKER_FLAGS="-L$HASHSTACK/lib -Wl,-rpath,$HASHSTACK/lib"
-- The C compiler identification is GNU 4.9.1
-- The CXX compiler identification is GNU 4.9.1
-- Check for working C compiler: /home/certik/repos/hashstack/default/bin/gcc
-- Check for working C compiler: /home/certik/repos/hashstack/default/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /home/certik/repos/hashstack/default/bin/g++
-- Check for working CXX compiler: /home/certik/repos/hashstack/default/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- The Fortran compiler identification is GNU
-- Check for working Fortran compiler: /home/certik/repos/hashstack/default/bin/gfortran
-- Check for working Fortran compiler: /home/certik/repos/hashstack/default/bin/gfortran  -- works
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Checking whether /home/certik/repos/hashstack/default/bin/gfortran supports Fortran 90
-- Checking whether /home/certik/repos/hashstack/default/bin/gfortran supports Fortran 90 -- yes
-- Found Lapack: lapack;blas  


Configuration results
---------------------
Fortran compiler: /home/certik/repos/hashstack/default/bin/gfortran
Build type: Debug
Fortran compiler flags: -std=f2003 -Wall -Wextra -Wimplicit-interface -fPIC -fmax-errors=1 -g -fbounds-check -fcheck-array-temporaries -fbacktrace
Installation prefix: /usr/local
LIBS: lapack;blas
With C interface: yes
With Python: no
With Lapack: yes
LAPACK_LIBRARIES: lapack;blas
-- Configuring done
-- Generating done
-- Build files have been written to: /home/certik/repos/dftatom

(This also uses custom compiled gcc 4.9.1 via the line CC=gcc CXX=g++ FC=gfortran, but that's fine.)

The way to do that is to allow the user to specify custom location of dependent libraries. We have figured it out in CSymPy, e.g. here: https://github.com/sympy/csympy/blob/96e80f5b9f67e5f02cbfaa7a5b941e64193b5455/cmake/FindGMP.cmake, so we can just copy that approach.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions