forked from PennyLaneAI/pennylane-lightning
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
99 lines (76 loc) · 3.92 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
cmake_minimum_required(VERSION 3.16)
set(LOGO [=[
░█░░░▀█▀░█▀▀░█░█░▀█▀░█▀█░▀█▀░█▀█░█▀▀░░░░▄▀▄░█░█░█▀▄░▀█▀░▀█▀
░█░░░░█░░█░█░█▀█░░█░░█░█░░█░░█░█░█░█░░░░█\█░█░█░█▀▄░░█░░░█░
░▀▀▀░▀▀▀░▀▀▀░▀░▀░░▀░░▀░▀░▀▀▀░▀░▀░▀▀▀░▀░░░▀\░▀▀▀░▀▀░░▀▀▀░░▀░
]=])
message(${LOGO})
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version")
set(CMAKE_CXX_STANDARD 20) # At least C++20 is required
project(pennylane_lightning
DESCRIPTION "C++ state-vector simulator bindings for PennyLane. "
LANGUAGES CXX
)
# Read and set pennylane_lightning version
function(set_pennylane_lightning_version VERSION_FILE_PATH)
file(STRINGS ${VERSION_FILE_PATH} VERSION_FILE_STR)
foreach (LINE IN LISTS VERSION_FILE_STR)
if("${LINE}" MATCHES "__version__.*")
set(VERSION_LINE_STR "${LINE}")
endif()
endforeach()
string(REGEX REPLACE "__version__ = \"(.*)\"" "\\1" VERSION_STRING ${VERSION_LINE_STR})
set(VERSION_STRING ${VERSION_STRING} PARENT_SCOPE)
endfunction()
set_pennylane_lightning_version(${PROJECT_SOURCE_DIR}/pennylane_lightning/_version.py)
message(STATUS "pennylane_lightning version ${VERSION_STRING}")
set(PROJECT_VERSION ${VERSION_STRING})
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo)
endif()
# Clang-tidy
option(ENABLE_CLANG_TIDY "Enable clang-tidy build checks" OFF)
# Compile options
option(ENABLE_COVERAGE "Enable code coverage" OFF)
option(ENABLE_WARNINGS "Enable warnings" ON)
option(ENABLE_NATIVE "Enable native CPU build tuning" OFF)
option(ENABLE_AVX "Enable AVX support" OFF)
option(ENABLE_OPENMP "Enable OpenMP" ON)
option(ENABLE_KOKKOS "Enable Kokkos" OFF)
option(ENABLE_BLAS "Enable BLAS" OFF)
# Other build options
option(BUILD_TESTS "Build cpp tests" OFF)
option(BUILD_BENCHMARKS "Enable cpp benchmarks" OFF)
# Process compile options
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/process_options.cmake")
set(CMAKE_POLICY_DEFAULT_CMP0127 NEW) # To suppress pybind11 CMP0127 warning
# Add pybind11
include(FetchContent)
FetchContent_Declare(pybind11
GIT_REPOSITORY https://github.com/pybind/pybind11.git
GIT_TAG v2.6.2
)
FetchContent_MakeAvailable(pybind11)
# All CMakeLists.txt in subdirectories use pennylane_lightning_compile_options and pennylane_lightning_external_libs
add_subdirectory(pennylane_lightning/src)
#####################################################
# Maintain for dependent external package development
#####################################################
add_library(pennylane_lightning INTERFACE)
target_link_libraries(pennylane_lightning INTERFACE lightning_utils
lightning_simulator
lightning_algorithms)
target_include_directories(pennylane_lightning INTERFACE "pennylane_lightning/src")
#####################################################
pybind11_add_module(lightning_qubit_ops "pennylane_lightning/src/bindings/Bindings.cpp")
target_link_libraries(lightning_qubit_ops PRIVATE lightning_algorithms
lightning_gates
lightning_simulator
lightning_utils)
target_link_libraries(lightning_qubit_ops PRIVATE lightning_compile_options
lightning_external_libs)
set_target_properties(lightning_qubit_ops PROPERTIES CXX_VISIBILITY_PRESET hidden)
target_compile_definitions(lightning_qubit_ops PRIVATE VERSION_INFO=${VERSION_STRING})
if (BUILD_TESTS)
enable_testing()
endif()