-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
73 lines (57 loc) · 2.05 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
cmake_minimum_required(VERSION 3.19)
project(SVE VERSION 1.0)
include(GNUInstallDirs)
include(CTest)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set(IS_TOPLEVEL_PROJECT TRUE)
else()
set(IS_TOPLEVEL_PROJECT FALSE)
endif()
option(SVE_BUILD_TESTING "Build and run SVE tests " ${IS_TOPLEVEL_PROJECT})
option(SVE_INSTALL_LIBRARY
"Enable installing of SVE library into default locations"
${IS_TOPLEVEL_PROJECT})
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
if (NOT SVE_LENGTH)
set(SVE_LENGTH 128)
endif()
message(STATUS "Using sve length : ${SVE_LENGTH}")
add_library(sve INTERFACE)
add_library(SVE::sve ALIAS sve)
target_include_directories(
sve INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_compile_features(sve INTERFACE cxx_std_20)
target_compile_definitions(sve INTERFACE SVE_LEN=${SVE_LENGTH})
target_compile_options(sve INTERFACE "-msve-vector-bits=${SVE_LENGTH}")
if(BUILD_TESTING AND SVE_BUILD_TESTING)
add_subdirectory(tests)
endif()
if(SVE_INSTALL_LIBRARY)
install(
TARGETS sve
EXPORT SVE_Targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"SVEConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)
configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/SVEConfig.cmake.in"
"${PROJECT_BINARY_DIR}/SVEConfig.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/sve/cmake)
install(
EXPORT SVE_Targets
FILE SVETargets.cmake
NAMESPACE SVE::
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/sve/cmake)
install(FILES "${PROJECT_BINARY_DIR}/SVEConfig.cmake"
"${PROJECT_BINARY_DIR}/SVEConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/sve/cmake)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/sve
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
endif()