Skip to content

Commit cc5b4e1

Browse files
authored
Merge pull request #2647 from ERGO-Code/openblas-win-config
OpenBLAS use find_package CONFIG for vcpkg
2 parents 1fe40aa + 226a227 commit cc5b4e1

File tree

2 files changed

+44
-29
lines changed

2 files changed

+44
-29
lines changed

cmake/FindHipoDeps.cmake

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -101,37 +101,46 @@ if (NOT USE_CMAKE_FIND_BLAS)
101101
endif()
102102
else()
103103

104-
if (NOT BLA_VENDOR)
105-
if (APPLE)
106-
set (BLA_VENDOR Apple)
107-
elseif(LINUX)
108-
set (BLA_VENDOR OpenBLAS)
109-
elseif(WIN32)
110-
set (BLA_VENDOR OpenBLAS)
104+
if (WIN32 AND NOT BLAS_LIBRARIES AND NOT BLA_VENDOR)
105+
find_package(OpenBLAS CONFIG)
106+
if(OpenBLAS_FOUND)
107+
message(STATUS "OpenBLAS CMake config path: ${OpenBLAS_DIR}")
111108
endif()
109+
endif()
110+
111+
if (NOT OpenBLAS_FOUND)
112+
if (NOT BLA_VENDOR)
113+
if (APPLE)
114+
set (BLA_VENDOR Apple)
115+
elseif(LINUX)
116+
set (BLA_VENDOR OpenBLAS)
117+
elseif(WIN32)
118+
set (BLA_VENDOR OpenBLAS)
119+
endif()
112120

113-
find_package(BLAS QUIET)
114-
if (BLAS_FOUND)
115-
message(STATUS "Using BLAS library: ${BLAS_LIBRARIES}")
116-
if (BLAS_INCLUDE_DIRS)
117-
message(STATUS "BLAS include dirs: ${BLAS_INCLUDE_DIRS}")
121+
find_package(BLAS QUIET)
122+
if (BLAS_FOUND)
123+
message(STATUS "Using BLAS library: ${BLAS_LIBRARIES}")
124+
if (BLAS_INCLUDE_DIRS)
125+
message(STATUS "BLAS include dirs: ${BLAS_INCLUDE_DIRS}")
126+
endif()
127+
else()
128+
unset(BLA_VENDOR)
118129
endif()
119130
else()
120-
unset(BLA_VENDOR)
131+
message(STATUS "Specified BLA_VENDOR: ${BLA_VENDOR}")
121132
endif()
122-
else()
123-
message(STATUS "Specified BLA_VENDOR: ${BLA_VENDOR}")
124-
endif()
125133

126-
if (NOT BLAS_FOUND)
127-
find_package(BLAS REQUIRED)
128-
if (BLAS_FOUND)
129-
message(STATUS "Using BLAS library: ${BLAS_LIBRARIES}")
130-
if (BLAS_INCLUDE_DIRS)
131-
message(STATUS "BLAS include dirs: ${BLAS_INCLUDE_DIRS}")
134+
if (NOT BLAS_FOUND)
135+
find_package(BLAS REQUIRED)
136+
if (BLAS_FOUND)
137+
message(STATUS "Using BLAS library: ${BLAS_LIBRARIES}")
138+
if (BLAS_INCLUDE_DIRS)
139+
message(STATUS "BLAS include dirs: ${BLAS_INCLUDE_DIRS}")
140+
endif()
141+
else()
142+
message(FATAL_ERROR "No BLAS library found!")
132143
endif()
133-
else()
134-
message(FATAL_ERROR "No BLAS library found!")
135144
endif()
136145
endif()
137146
endif()

highs/CMakeLists.txt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,19 @@ else()
219219
endif(BLAS_LIB)
220220
endif(APPLE)
221221
else()
222-
target_link_libraries(highs PRIVATE BLAS::BLAS)
223222

224-
string(TOLOWER "${BLAS_LIBRARIES}" blas_lower)
225-
if(blas_lower MATCHES "openblas")
223+
if (WIN32 AND TARGET OpenBLAS::OpenBLAS)
226224
target_compile_definitions(highs PRIVATE HIPO_USES_OPENBLAS)
227-
elseif(blas_lower MATCHES "accelerate")
228-
target_compile_definitions(highs PRIVATE HIPO_USES_APPLE_BLAS)
225+
target_link_libraries(highs PRIVATE OpenBLAS::OpenBLAS)
226+
else()
227+
target_link_libraries(highs PRIVATE BLAS::BLAS)
228+
229+
string(TOLOWER "${BLAS_LIBRARIES}" blas_lower)
230+
if(blas_lower MATCHES "openblas")
231+
target_compile_definitions(highs PRIVATE HIPO_USES_OPENBLAS)
232+
elseif(blas_lower MATCHES "accelerate")
233+
target_compile_definitions(highs PRIVATE HIPO_USES_APPLE_BLAS)
234+
endif()
229235
endif()
230236
endif()
231237

0 commit comments

Comments
 (0)