-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
101 lines (82 loc) · 2.78 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
cmake_minimum_required(VERSION 3.2)
cmake_policy(SET CMP0135 NEW)
project(tenseur VERSION 1.0.0
DESCRIPTION "A header only C++20 tensor library."
HOMEPAGE_URL "https://github.com/istmarc/tenseur")
include(GNUInstallDirs)
# Compiler options
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -march=native")
# Build shared library
option(TENSEUR_SHAREDLIB "Build shared Library." OFF)
if (TENSEUR_SHAREDLIB)
add_library(tenseur SHARED ${PROJECT_SOURCE_DIR}/ten/tensor.cxx)
set_target_properties(tenseur PROPERTIES POSITION_INDEPENDANT_CODE ON)
target_include_directories(tenseur PRIVATE ${PROJECT_SOURCE_DIR})
else()
add_library(tenseur INTERFACE)
target_include_directories(
tenseur
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/ten>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
# Compiler features
target_compile_features(tenseur INTERFACE cxx_std_20)
endif()
# Target paths
install(TARGETS tenseur
EXPORT ${PROJECT_NAME}_Targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
# Version
include(CMakePackageConfigHelpers)
write_basic_package_version_file("tenseurConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/${PROJECT_NAME}Config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION
${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake
)
# Targets to install
install(EXPORT ${PROJECT_NAME}_Targets
FILE ${PROJECT_NAME}Targets.cmake
NAMESPACE ${PROJECT_NAME}::
DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake
)
# Files to install
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake)
# Install directory
install(DIRECTORY ${PROJECT_SOURCE_DIR}/ten DESTINATION include)
# Build the tests
option(TENSEUR_TESTS "Build tests." OFF)
if (TENSEUR_TESTS)
add_subdirectory(tests)
endif()
# Build the examples
option(TENSEUR_EXAMPLES "Build examples." OFF)
if (TENSEUR_EXAMPLES)
add_subdirectory(examples)
endif()
# Build the docs
option(TENSEUR_DOCS "Build documentation." OFF)
if (TENSEUR_DOCS)
add_subdirectory(docs)
endif()
# Build the benchmarks
option(TENSEUR_BENCHMARKS "Build documentation." OFF)
if (TENSEUR_BENCHMARKS)
add_subdirectory(benchmarks)
endif()
# Python bindings
option(TENSEUR_PYTHON "Python bindings." OFF)
if (TENSEUR_PYTHON)
add_subdirectory(bindings)
endif()