Skip to content

find_package error when building with openblas #4021

@minyez

Description

@minyez

Describe the bug

When building ABACUS on macOS using cmake (version 3.28.3), gcc, mpich, openblas and scalapack, find_package error is encountered when trying to find BLAS.

-- The CXX compiler identification is GNU 13.2.0
-- Checking whether CXX compiler has -isysroot
-- Checking whether CXX compiler has -isysroot - yes
-- Checking whether CXX compiler supports OSX deployment target flag
-- Checking whether CXX compiler supports OSX deployment target flag - yes
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /opt/homebrew/bin/g++-13 - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Git: /usr/bin/git (found version "2.39.3 (Apple Git-146)")
-- Found git: attempting to get commit info...
-- Current commit hash: 29b4eedc5
-- Last commit date: Thu Apr 18 12:22:38 2024 +0200
-- Found Cereal: /opt/homebrew/Cellar/cereal/1.3.2/include/cereal
-- Found MPI_CXX: /opt/homebrew/Cellar/mpich/4.1.2/lib/libmpicxx.dylib (found version "4.0")
-- Found MPI: TRUE (found version "4.0")
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Found OpenMP_CXX: -fopenmp (found version "4.5")
-- Found OpenMP: TRUE (found version "4.5")
-- Looking for a CUDA compiler
-- Looking for a CUDA compiler - NOTFOUND
-- Found FFTW3: /opt/packages/fftw/3.3.10/gcc-13.2.0-mpich-4.1.2/lib/libfftw3_omp.dylib
CMake Error at cmake/FindBLAS.cmake:8 (find_package):
  find_package maximum nesting depth of 500 exceeded.
Call Stack (most recent call first):
  cmake/FindBLAS.cmake:8 (find_package)
  cmake/FindBLAS.cmake:8 (find_package)
  cmake/FindBLAS.cmake:8 (find_package)
  cmake/FindBLAS.cmake:8 (find_package)
  cmake/FindBLAS.cmake:8 (find_package)
...
  cmake/FindBLAS.cmake:8 (find_package)
  cmake/FindBlas.cmake:8 (find_package)
  cmake/FindLapack.cmake:9 (find_package)
  CMakeLists.txt:398 (find_package)
...

Expected behavior

The configure process should terminate successfully.

To Reproduce

Clone the code and configure the build directory with the following script. Some path variables need to be adapted.

#!/usr/bin/env bash

BUILD_DIR=build

LAPACK="/opt/homebrew/Cellar/openblas/0.3.26/lib"
CEREAL="/opt/homebrew/Cellar/cereal/1.3.2/include/cereal"
# need to adapt following variables
SCALAPACK="/opt/packages/scalapack/2.2.0/gcc-13.2.0-mpich-4.1.2-openblas"
FFTW3="/opt/packages/fftw/3.3.10/gcc-13.2.0-mpich-4.1.2"
LIBXC="/opt/packages/libxc/6.2.2/gcc-13.2.0"

export MPICH_CXX="g++-13"

cmake -B $BUILD_DIR \
    -DCMAKE_CXX_COMPILER=g++-13 \
    -DMPI_CXX_COMPILER=mpicxx \
    -DBLAS_DIR="$LAPACK" \
    -DLAPACK_DIR="$LAPACK" \
    -DSCALAPACK_DIR="$SCALAPACK" \
    -DFFTW3_DIR="$FFTW3" \
    -DCEREAL_INCLUDE_DIR="$CEREAL" \
    -DLibxc_DIR="$LIBXC" \
    -DENABLE_LCAO=ON \
    -DENABLE_LIBXC=ON \
    -DUSE_OPENMP=ON \
    -DUSE_ELPA=OFF

Environment

  • OS: macOS Sonoma 14.2.1
  • Compiler: gcc 13.2.0 (homebrew)
  • MPI: mpich 4.1.2 (homebrew)
  • cmake: 3.28.3 (homebrew)
  • LAPACK: OpenBLAS 0.3.26 (homebrew)
  • ScaLAPACK: 2.2.0, built with gcc and openblas above
  • FFTW3: 3.3.10, built with gcc and mpich above

Additional Context

The error seems to be related to case sensitivity of find_package modules. The configure process goes smoothly if I

  • rename cmake/FindBlas.cmake to cmake/FindBlasWrap.cmake
  • rename cmake/FindLapack.cmake to cmake/FindLapackWrap.cmake and therein change find_package(Blas REQUIRED) to find_package(BlasWrap REQUIRED)
  • modify CMakeLists.txt to use find_package(LapackWrap REQUIRED)

I'm not sure if it is really a bug, or it is actually due to some mistake in my build script or recent change in cmake. Help would be greatly appreciated.

Task list for Issue attackers (only for developers)

  • Verify the issue is not a duplicate.
  • Describe the bug.
  • Steps to reproduce.
  • Expected behavior.
  • Error message.
  • Environment details.
  • Additional context.
  • Assign a priority level (low, medium, high, urgent).
  • Assign the issue to a team member.
  • Label the issue with relevant tags.
  • Identify possible related issues.
  • Create a unit test or automated test to reproduce the bug (if applicable).
  • Fix the bug.
  • Test the fix.
  • Update documentation (if necessary).
  • Close the issue and inform the reporter (if applicable).

Metadata

Metadata

Assignees

Labels

BugsBugs that only solvable with sufficient knowledge of DFT

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions