-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
56 lines (44 loc) · 1.73 KB
/
CMakeLists.txt
File metadata and controls
56 lines (44 loc) · 1.73 KB
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
cmake_minimum_required(VERSION 3.22)
project(linear_algebra)
enable_testing()
# Set up language settings
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_CXX_EXTENSIONS NO)
# Find Halide
find_package(Halide REQUIRED)
# Find BLAS-es
set(DEFAULT_BLAS "")
set(BLAS_TARGETS "")
set(BLAS_VENDORS OpenBLAS ATLAS Apple Generic)
# ATLAS is weird and has extra requirements
find_library(CBLAS_LIBRARY cblas)
set(ATLAS_EXTRA_LIBS ${CBLAS_LIBRARY})
message(STATUS "Checking for available CBLAS implementations")
foreach (BLA_VENDOR IN LISTS BLAS_VENDORS)
find_package(BLAS QUIET)
if (NOT BLAS_FOUND
OR ("${BLA_VENDOR}" STREQUAL "ATLAS" AND NOT CBLAS_LIBRARY)
OR ("${BLA_VENDOR}" STREQUAL "Generic" AND BLAS_TARGETS))
message(STATUS "${BLA_VENDOR}: Missing")
else ()
list(APPEND BLAS_LIBRARIES ${${BLA_VENDOR}_EXTRA_LIBS})
message(STATUS "${BLA_VENDOR}: Found ${BLAS_LIBRARIES}")
add_library(BLAS_${BLA_VENDOR} INTERFACE)
add_library(${BLA_VENDOR}::${BLA_VENDOR} ALIAS BLAS_${BLA_VENDOR})
target_link_libraries(BLAS_${BLA_VENDOR} INTERFACE ${BLAS_LIBRARIES})
target_link_options(BLAS_${BLA_VENDOR} INTERFACE ${BLAS_LINKER_FLAGS})
target_include_directories(BLAS_${BLA_VENDOR} SYSTEM INTERFACE include) # Use CBlas header in our own tree.
if (NOT DEFAULT_BLAS)
set(DEFAULT_BLAS ${BLA_VENDOR}::${BLA_VENDOR})
endif ()
list(APPEND BLAS_TARGETS ${BLA_VENDOR})
endif ()
endforeach ()
if (NOT BLAS_TARGETS)
message(FATAL_ERROR "Could not find any BLAS libraries! Searched among ${BLAS_VENDORS}")
endif ()
# Load in the rest of the project.
add_subdirectory(src)
add_subdirectory(tests)
add_subdirectory(benchmarks)