Reference-ScaLAPACK / scalapack

ScaLAPACK development repository
Other
132 stars 59 forks source link

CMake issues for building scalapack with VS2022 in windows #96

Open sephenisee opened 6 months ago

sephenisee commented 6 months ago

Hello,

First of all, thanks for managing this repository and provide cross-platform support for scalapack using Cmake. I have been trying to build scalapack in windows using VS2022 community version and found some issues in couple of CMakeLists files (in the main branch) that cause build errors using VS2022 (with intel fortran compiler).

I turned off the option, USE_OPTIMIZED_LAPACK_BLAS, to avoid using MKL lapack and blas pre-installed in my workstation. So, the main CMakeLists let me install netlib lapack to the dependency folder inside the main build directory.

Following are the issues and solutions, I found, and I am just listing them here so the people who may face same issues possibly benefit from this list. 1) In the main CMakeLists.txt, URL "http://www.netlib.org/lapack/lapack.tgz" seems to be outdated. I just used the lapack git repository and it seems to work fine.

2) In VS2022, ninja is the default build system for windows. It seems that ninja-build has a different way to identify external dependencies from UNIX Make when ExternalProject_ADD is used. Without adding the line "BUILD_BYPRODUCTS ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES}", it seems that ctest executable does not recognize the dependency with lapack.

3) After above fix, it still gives build errors for generating executable files for ctests in TEST folder. This seems to be because only scalapack is linked to each testing targets. It's fine if MSVC is not used but scalapack-F is also generated when MSVC is used and need to be linked to targets. I just created another library, SCALAPACK::SCALAPACK and liked both scalapack and scalapack-F in the case of MSVC. In addition, CMakeLists.txt files in TESTING/EIG and TESTING/LIN are modified so that each targets are linked with SCALAPACK::SCALAPACK instead of just scalapack.

This is just a note. I am building lapack in release version (hard coded - not a good practice). In this case, scalapack also needs to be built in release. This was my rookie mistake.

After these modifications, scalapack libraries seem to get built properly, and all the ctests provided in TEST folder seem to pass. I made a fork and you can check this modification in the latest commit there.

I am by no means proficient with CMake but these simple fixes seem to work. Hopefully, this helps people trying to build scalapack in windows using VS2022.