forked from kokkos/stdBLAS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
146 lines (115 loc) · 4.6 KB
/
CMakeLists.txt
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
cmake_minimum_required(VERSION 3.12)
project(LinAlg
VERSION 0.0.1
LANGUAGES CXX
)
################################################################################
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
################################################################################
option(LINALG_ENABLE_TESTS "Enable tests." Off)
option(LINALG_ENABLE_EXAMPLES "Build examples." Off)
#option(LINALG_ENABLE_BENCHMARKS "Enable benchmarks." Off)
#option(LINALG_ENABLE_COMP_BENCH "Enable compilation benchmarks." Off)
# Option to override which C++ standard to use
set(LINALG_CXX_STANDARD DETECT CACHE STRING "Override the default CXX_STANDARD to compile with.")
set_property(CACHE LINALG_CXX_STANDARD PROPERTY STRINGS DETECT 20)
option(LINALG_ENABLE_CONCEPTS "Try to enable concepts support by giving extra flags." On)
################################################################################
# Make sure that the compiler supports C++20
if(LINALG_CXX_STANDARD STREQUAL "20")
if("cxx_std_20" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
message(STATUS "Using C++20 standard")
set(CMAKE_CXX_STANDARD 20)
else()
message(FATAL_ERROR "Requested LINALG_CXX_STANDARD \"20\" not supported by provided C++ compiler")
endif()
else()
if("cxx_std_20" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
set(CMAKE_CXX_STANDARD 20)
message(STATUS "Detected support for C++20 standard")
else()
message(FATAL_ERROR "Cannot detect CXX_STANDARD of C++20")
endif()
endif()
################################################################################
if(LINALG_ENABLE_CONCEPTS)
if(CMAKE_CXX_STANDARD STREQUAL "20")
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-fconcepts" COMPILER_SUPPORTS_FCONCEPTS)
if(COMPILER_SUPPORTS_FCONCEPTS)
message(STATUS "-- Using \"-fconcepts\" to enable concepts support")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fconcepts")
else()
CHECK_CXX_COMPILER_FLAG("-fconcepts-ts" COMPILER_SUPPORTS_FCONCEPTS_TS)
if(COMPILER_SUPPORTS_FCONCEPTS)
message(STATUS "-- Using \"-fconcepts-ts\" to enable concepts support")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fconcepts-ts")
endif()
endif()
# Otherwise, it's possible that the compiler supports concepts without flags,
# but if it doesn't, they just won't be used, which is fine
endif()
endif()
################################################################################
find_package(mdspan REQUIRED)
find_package(BLAS)
option(LINALG_ENABLE_BLAS
"Assume that we are linking with a BLAS library."
${BLAS_FOUND})
################################################################################
CONFIGURE_FILE(include/experimental/__p1673_bits/linalg_config.h.in
include/experimental/__p1673_bits/linalg_config.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/experimental)
message(STATUS "Build include directory: ${CMAKE_CURRENT_BINARY_DIR}/include/experimental")
################################################################################
add_library(linalg INTERFACE)
add_library(std::linalg ALIAS linalg)
target_link_libraries(linalg INTERFACE std::mdspan)
target_include_directories(linalg INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
################################################################################
install(TARGETS linalg EXPORT linalgTargets
INCLUDES DESTINATION include
)
install(EXPORT linalgTargets
FILE linalgTargets.cmake
NAMESPACE std::
DESTINATION cmake
)
export(TARGETS linalg
NAMESPACE std::
FILE linalgTargets.cmake
)
install(DIRECTORY include/experimental DESTINATION include)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/experimental/__p1673_bits/linalg_config.h
DESTINATION include/experimental/__p1673_bits
)
include(CMakePackageConfigHelpers)
configure_package_config_file(cmake/LinAlgConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/LinAlgConfig.cmake
INSTALL_DESTINATION cmake
)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/LinAlgConfigVersion.cmake
COMPATIBILITY SameMajorVersion
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/LinAlgConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/LinAlgConfigVersion.cmake
DESTINATION cmake
)
################################################################################
if(LINALG_ENABLE_TESTS)
enable_testing()
add_subdirectory(tests)
add_subdirectory(compilation_tests)
endif()
if(LINALG_ENABLE_EXAMPLES)
add_subdirectory(examples)
endif()
#if(LINALG_ENABLE_BENCHMARKS)
# add_subdirectory(benchmarks)
#endif()
#
#if(LINALG_ENABLE_COMP_BENCH)
# add_subdirectory(comp_bench)
#endif()