Request for Minimal Working Example of BLAS in FORTRAN 77 with CMake and Package Managers

I am working on a project to integrate Basic Linear Algebra Subprograms (BLAS) into a FORTRAN 77 application. I aim to set up this project on Windows using Intel’s ifort.exe compiler. To streamline the development process, I want to utilize a package manager, specifically Conan or VCPKG.

I am seeking guidance or a minimal working example (MWE) that demonstrates the following:

  1. Configuring CMake to build a FORTRAN 77 project using the ifort.exe compiler.
  2. Incorporating BLAS libraries through either Conan or VCPKG.
  3. Ensuring compatibility and smooth operation on the Windows platform.

Any advice or examples of CMakeLists.txt configurations and setup steps would be greatly appreciated. I’m especially interested in best practices for integrating these components seamlessly.

Here is an MWE of BLAS used in a Fortran code using Makefile.

In vcpkg you need to set(CMAKE_Fortran_FLAGS_INIT "/names:lowercase /assume:underscore") since the world does not follow Intels Fortran symbol mangling which is all uppercase for windows. Otherwise the compile check in FindBlas won’t be able to find the symbols it is looking for.

Followin up our discussion from here on VCPKG’s Discord, I added the said flags, and yet get:

Preset CMake variables:

  CMAKE_TOOLCHAIN_FILE="C:/dev/vcpkg/scripts/buildsystems/vcpkg.cmake"

-- Running vcpkg install
Fetching registry information from https://github.com/microsoft/vcpkg (HEAD)...
Detecting compiler hash for triplet x64-windows...
Compiler found: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.36.32532/bin/Hostx64/x64/cl.exe
The following packages will be built and installed:
    blas:x64-windows@2023-04-14 -- C:\Users\FoadS\AppData\Local\vcpkg\registries\git-trees\02dbca6ca7e22e44f5445b10f74e63644779eefd
  * openblas:x64-windows@0.3.27 -- C:\Users\FoadS\AppData\Local\vcpkg\registries\git-trees\653ab9ede4c3c8b556b5d1b8b7d98d6abab8ef9d
  * vcpkg-cmake:x64-windows@2023-05-04 -- C:\Users\FoadS\AppData\Local\vcpkg\registries\git-trees\88a7058fc7fa73a9c4c99cfcae9d79e2abf87a5a
  * vcpkg-cmake-config:x64-windows@2022-02-06#1 -- C:\Users\FoadS\AppData\Local\vcpkg\registries\git-trees\8d54cc4f487d51b655abec5f9c9c3f86ca83311f
Additional packages (*) will be modified to complete this operation.
Restored 4 package(s) from C:\Users\FoadS\AppData\Local\vcpkg\archives in 296 ms. Use --debug to see more details.
Installing 1/4 vcpkg-cmake:x64-windows@2023-05-04...
Elapsed time to handle vcpkg-cmake:x64-windows: 20.6 ms
vcpkg-cmake:x64-windows package ABI: e92cbafa7c7d362e0aa1f3defd78f00d2cc6bcdfe894f7851f52868d496d31b3
Installing 2/4 vcpkg-cmake-config:x64-windows@2022-02-06#1...
Elapsed time to handle vcpkg-cmake-config:x64-windows: 23 ms
vcpkg-cmake-config:x64-windows package ABI: a167cc445b2f42082b73851e160cb8fa48d90377f0e1cbaf9b54af46d959f8ac
Installing 3/4 openblas:x64-windows@0.3.27...
Elapsed time to handle openblas:x64-windows: 49.1 ms
openblas:x64-windows package ABI: 21adae8f800d5e89d85c3e5d4f9f6ffde33d69944d6d35078aa74f3a8416394b
Installing 4/4 blas:x64-windows@2023-04-14...
Elapsed time to handle blas:x64-windows: 26.2 ms
blas:x64-windows package ABI: 932edd5a269fe46dfa561f8e1050426fc757c35cd6b3455ca4e8edbb50d910bf
Total install time: 119 ms
blas provides pkg-config modules:

  # Implementation of BLAS
  blas

-- Running vcpkg install - done
-- The Fortran compiler identification is IntelLLVM 2024.0.2 with MSVC-like command-line
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: C:/Program Files (x86)/Intel/oneAPI/compiler/latest/bin/ifx.exe - skipped
-- Looking for Fortran sgemm
-- Looking for Fortran sgemm - not found
CMake Error at C:/Program Files/Microsoft Visual Studio/2022/Enterprise/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.26/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find BLAS (missing: BLAS_LIBRARIES)
Call Stack (most recent call first):
  C:/Program Files/Microsoft Visual Studio/2022/Enterprise/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.26/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  C:/Program Files/Microsoft Visual Studio/2022/Enterprise/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.26/Modules/FindBLAS.cmake:1346 (find_package_handle_standard_args)
  build/vcpkg_installed/x64-windows/share/blas/vcpkg-cmake-wrapper.cmake:7 (_find_package)
  C:/dev/vcpkg/scripts/buildsystems/vcpkg.cmake:813 (include)
  CMakeLists.txt:39 (find_package)


-- Configuring incomplete, errors occurred!

when I run cmake --preset=default.