Skip to content

Commit 0add02f

Browse files
committed
fetch openblas, link and add to export set: linux OK
1 parent 685b016 commit 0add02f

File tree

3 files changed

+42
-4
lines changed

3 files changed

+42
-4
lines changed

cmake/FindHipoDeps.cmake

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,25 @@ if (BUILD_OPENBLAS)
2020
FetchContent_MakeAvailable(openblas)
2121
list(POP_BACK CMAKE_MESSAGE_INDENT)
2222
message(CHECK_PASS "fetched")
23+
24+
if (TARGET openblas)
25+
get_target_property(_openblas_aliased openblas ALIASED_TARGET)
26+
if(_openblas_aliased)
27+
set(_openblas_target ${_openblas_aliased})
28+
message(STATUS "OpenBLAS is an alias for: ${_openblas_target}")
29+
else()
30+
set(_openblas_target openblas)
31+
endif()
32+
elseif (TARGET openblas_static)
33+
set(_openblas_target openblas_static)
34+
elseif (TARGET openblas_shared)
35+
set(_openblas_target openblas_shared)
36+
else()
37+
message(FATAL_ERROR "OpenBLAS target not found")
38+
endif()
39+
message(STATUS "OpenBLAS target: ${_openblas_target}")
40+
41+
return()
2342
endif()
2443

2544
# Find BLAS

cmake/cpp-highs.cmake

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ install(TARGETS highs
5656
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
5757
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
5858
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
59-
59+
6060
if (NOT HIGHS_COVERAGE)
6161
# Add library targets to the build-tree export set
6262
export(TARGETS highs
@@ -71,7 +71,7 @@ if (CUPDLP_GPU)
7171
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
7272
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
7373
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
74-
74+
7575
if (NOT HIGHS_COVERAGE)
7676
# Add library targets to the build-tree export set
7777
export(TARGETS cudalin
@@ -80,6 +80,22 @@ if (CUPDLP_GPU)
8080
endif()
8181
endif()
8282

83+
if (BUILD_OPENBLAS)
84+
install(TARGETS ${_openblas_target}
85+
EXPORT ${lower}-targets
86+
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
87+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
88+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
89+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
90+
91+
if (NOT HIGHS_COVERAGE)
92+
# Add library targets to the build-tree export set
93+
export(TARGETS ${_openblas_target}
94+
NAMESPACE ${PROJECT_NAMESPACE}::
95+
APPEND FILE "${HIGHS_BINARY_DIR}/highs-targets.cmake")
96+
endif()
97+
endif()
98+
8399
if (NOT HIGHS_COVERAGE)
84100
install(EXPORT ${lower}-targets
85101
NAMESPACE ${PROJECT_NAMESPACE}::
@@ -91,10 +107,10 @@ endif()
91107
if(ZLIB AND ZLIB_FOUND)
92108
set(CONF_Z "find_dependency(ZLIB)")
93109
set(CONF_ZLIB ${CONF_Z})
94-
else()
110+
else()
95111
set(CONF_ZLIB "")
96112
endif()
97-
113+
98114

99115
include(CMakePackageConfigHelpers)
100116
string (TOUPPER "${PROJECT_NAME}" PACKAGE_PREFIX)

highs/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ else()
214214
elseif(OPENBLAS_LIB)
215215
target_link_libraries(highs PRIVATE "${OPENBLAS_LIB}")
216216
target_compile_definitions(highs PRIVATE HIPO_USES_OPENBLAS)
217+
elseif(BUILD_OPENBLAS)
218+
target_link_libraries(highs PRIVATE openblas)
219+
target_compile_definitions(highs PRIVATE HIPO_USES_OPENBLAS)
217220
else()
218221
message(FATAL_ERROR "No BLAS library available")
219222
endif(BLAS_LIB)

0 commit comments

Comments
 (0)