@@ -44,28 +44,54 @@ endif()
44
44
45
45
option (FIND_BLAS "Find external BLAS and LAPACK" ON )
46
46
47
- # --- find BLAS and LAPACK
47
+ # --- find external BLAS and LAPACK
48
48
if (FIND_BLAS)
49
- if (NOT BLAS_FOUND)
50
- #Required for MKL
51
- if (DEFINED ENV{MKLROOT} OR "${BLA_VENDOR} " MATCHES "^Intel" )
52
- enable_language ("C" )
53
- endif ()
54
- find_package ("BLAS" )
55
- endif ()
56
- if (BLAS_FOUND)
57
- add_compile_definitions (STDLIB_EXTERNAL_BLAS)
49
+
50
+ message (STATUS "Searching for external BLAS/LAPACK" )
51
+
52
+ # Common MKL setup
53
+ if (DEFINED ENV{MKLROOT} OR "${BLA_VENDOR} " MATCHES "^(Intel|Intel10_64)" )
54
+ enable_language ("C" )
55
+ message (STATUS "Detected Intel MKL environment" )
58
56
endif ()
59
- if (NOT LAPACK_FOUND)
60
- #Required for MKL
61
- if (DEFINED ENV{MKLROOT} OR "${BLA_VENDOR} " MATCHES "^Intel" )
62
- enable_language ("C" )
57
+
58
+ find_package (BLAS)
59
+ find_package (LAPACK)
60
+
61
+ if (BLAS_FOUND AND LAPACK_FOUND)
62
+ message (STATUS "Found external BLAS: ${BLAS_LIBRARIES} " )
63
+ message (STATUS "Found external LAPACK: ${LAPACK_LIBRARIES} " )
64
+
65
+ # Detect ILP64 (common function)
66
+ function (detect_ilp64 lib_name)
67
+ set (${lib_name} _ILP64 False PARENT_SCOPE)
68
+ # Prefer checking BLA_SIZEOF_INTEGER (available in CMake >= 3.22)
69
+ if (DEFINED BLA_SIZEOF_INTEGER AND BLA_SIZEOF_INTEGER EQUAL 8)
70
+ set (${lib_name} _ILP64 True PARENT_SCOPE)
71
+ # Fallback: Check BLA_VENDOR manually for signs of ILP64
72
+ elseif ("${BLA_VENDOR} " MATCHES ".*(_ilp|ILP64).*" )
73
+ set (${lib_name} _ILP64 True PARENT_SCOPE)
74
+ endif ()
75
+ endfunction ()
76
+
77
+ detect_ilp64(BLAS)
78
+ detect_ilp64(LAPACK)
79
+
80
+ # Set compile definitions
81
+ if (BLAS_ILP64 OR LAPACK_ILP64)
82
+ message (STATUS "Enabling 64-bit integer support (ILP64)" )
83
+ add_compile_definitions (STDLIB_EXTERNAL_BLAS_I64 STDLIB_EXTERNAL_LAPACK_I64)
84
+ set (WITH_ILP64 True CACHE BOOL "Use 64-bit integer BLAS/LAPACK" FORCE)
85
+ else ()
86
+ message (STATUS "Using standard 32-bit integer interface" )
87
+ add_compile_definitions (STDLIB_EXTERNAL_BLAS STDLIB_EXTERNAL_LAPACK)
63
88
endif ()
64
- find_package ( "LAPACK" )
65
- endif ()
66
- if (LAPACK_FOUND)
67
- add_compile_definitions (STDLIB_EXTERNAL_LAPACK )
89
+
90
+ else ()
91
+ message (WARNING "External BLAS/LAPACK not found - "
92
+ "Using built-in reference BLAS" )
68
93
endif ()
94
+
69
95
endif ()
70
96
71
97
# --- find preprocessor
0 commit comments