-
Notifications
You must be signed in to change notification settings - Fork 5
/
FindOpenBLAS.cmake
80 lines (68 loc) · 2.29 KB
/
FindOpenBLAS.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# SANITY CHECK
if( "ilp64" IN_LIST OpenBLAS_FIND_COMPONENTS AND "lp64" IN_LIST OpenBLAS_FIND_COMPONENTS )
message( FATAL_ERROR "OpenBLAS cannot link to both ILP64 and LP64 interfaces" )
endif()
if( OpenBLAS_PREFERS_STATIC )
set( OpenBLAS_LP64_LIBRARY_NAME "libopenblas.a" )
set( OpenBLAS_ILP64_LIBRARY_NAME "libopenblas_64.a" )
else()
set( OpenBLAS_LP64_LIBRARY_NAME "openblas" )
set( OpenBLAS_ILP64_LIBRARY_NAME "openblas_64" )
endif()
find_library( OpenBLAS_LIBRARIES
NAMES ${OpenBLAS_LP64_LIBRARY_NAME} ${OpenBLAS_ILP64_LIBRARY_NAME}
HINTS ${OpenBLAS_PREFIX}
PATHS ${OpenBLAS_LIBRARY_DIR} ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}
PATH_SUFFIXES lib lib64 lib32
DOC "OpenBLAS Library"
)
find_path( OpenBLAS_INCLUDE_DIR
NAMES openblas_config.h
HINTS ${OpenBLAS_PREFIX}
PATHS ${OpenBLAS_INCLUDE_DIR}
PATH_SUFFIXES include include/openblas include/openblas64
DOC "OpenBLAS header"
)
#if( OpenBLAS_LIBRARY AND OpenBLAS_PREFERS_STATIC )
# include( CMakeFindDependency )
# find_package( Threads QUIET )
# set( OpenBLAS_LIBRARIES ${OpenBLAS_LIBRARY} Threads::Threads "m")
#endif()
# check ILP64
if( OpenBLAS_INCLUDE_DIR )
try_run( OpenBLAS_USES_LP64
_openblas_idx_test_compile_result
${CMAKE_CURRENT_BINARY_DIR}
SOURCES ${CMAKE_CURRENT_LIST_DIR}/util/openblas_int_size.c
CMAKE_FLAGS -DINCLUDE_DIRECTORIES:STRING=${OpenBLAS_INCLUDE_DIR}
COMPILE_OUTPUT_VARIABLE _openblas_idx_compile_output
RUN_OUTPUT_VARIABLE _openblas_idx_run_output
)
if( ${OpenBLAS_USES_LP64} EQUAL 0 )
set( OpenBLAS_USES_LP64 TRUE )
else()
set( OpenBLAS_USES_LP64 FALSE )
endif()
## Handle components
if( OpenBLAS_USES_LP64 )
set( OpenBLAS_ilp64_FOUND FALSE )
set( OpenBLAS_lp64_FOUND TRUE )
else()
set( OpenBLAS_ilp64_FOUND TRUE )
set( OpenBLAS_lp64_FOUND FALSE )
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args( OpenBLAS
REQUIRED_VARS OpenBLAS_LIBRARIES OpenBLAS_INCLUDE_DIR
HANDLE_COMPONENTS
)
#if( OpenBLAS_FOUND AND NOT TARGET OpenBLAS::OpenBLAS )
#
# add_library( OpenBLAS::OpenBLAS INTERFACE IMPORTED )
# set_target_properties( OpenBLAS::OpenBLAS PROPERTIES
# INTERFACE_INCLUDE_DIRECTORIES "${OpenBLAS_INCLUDE_DIR}"
# INTERFACE_LINK_LIBRARIES "${OpenBLAS_LIBRARIES}"
# )
#
#endif()