-
Notifications
You must be signed in to change notification settings - Fork 92
/
Copy pathFindQPANDA.cmake
126 lines (108 loc) · 4.36 KB
/
FindQPANDA.cmake
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
#.rst:
# FindQPANDA
# --------
#
# Find qpanda
#
# Find the native qpanda headers and libraries.
#
# ::
#
# QPANDA_INCLUDE_DIR - QPanda-2 include etc.
# THIRD_INCLUDE_DIR - ThirdParty include
# QPANDA_LIBRARIES - List of libraries when using QPanda.
# COMPONENTS_LIBRARY - Variational library
# ANTLR4_LIBRARY - antlr4 library
# NLOPT_LIBRARY - nlopt library
# BZ2_LIBRARY - bz2 library
# QPANDA_LIBRARY - QPanda-2 library
# QPANDA_FOUND - True if curl found.
#
# Look for the header file.
find_path(QPANDA_INCLUDE_DIR NAMES qpanda2/QPanda.h qpanda2/QPandaVersion.h
PATHS
${QPANDA_INSTALL_DIR}/include)
set(QPANDA_INCLUDE_DIR "${QPANDA_INCLUDE_DIR}/qpanda2/")
find_path(THIRD_INCLUDE_DIR NAMES qpanda2/ThirdParty/rapidjson/rapidjson.h
PATHS
${QPANDA_INSTALL_DIR}/include)
include_directories(${THIRD_INCLUDE_DIR}/qpanda2/ThirdParty)
include_directories(${THIRD_INCLUDE_DIR}/qpanda2/Extensions)
mark_as_advanced(QPANDA_INCLUDE_DIR)
# Look for the library (sorted from most current/relevant entry to least).
find_library(QPANDA_LIBRARY NAMES QPanda2
PATHS
${QPANDA_INSTALL_DIR}/lib)
find_library(COMPONENTS_LIBRARY NAMES Components
PATHS
${QPANDA_INSTALL_DIR}/lib)
find_library(ANTLR4_LIBRARY NAMES antlr4
PATHS
${QPANDA_INSTALL_DIR}/lib)
find_library(NLOPT_LIBRARY NAMES nlopt
PATHS
${QPANDA_INSTALL_DIR}/lib)
find_library(GPUBACKEND_LIBRARY NAMES GPUQGates
PATHS
${QPANDA_INSTALL_DIR}/lib)
find_library(BZ2_LIBRARY NAMES bz2
PATHS
${QPANDA_INSTALL_DIR}/lib)
mark_as_advanced(QPANDA_LIBRARY)
mark_as_advanced(QALG_LIBRARY)
mark_as_advanced(COMPONENTS_LIBRARY)
mark_as_advanced(ANTLR4_LIBRARY)
mark_as_advanced(NLOPT_LIBRARY)
mark_as_advanced(BZ2_LIBRARY)
set(QPANDA_LIBRARIES)
list(APPEND QPANDA_LIBRARIES
${QALG_LIBRARY}
${COMPONENTS_LIBRARY}
${QPANDA_LIBRARY}
${ANTLR4_LIBRARY}
${NLOPT_LIBRARY}
${BZ2_LIBRARY})
if (GPUBACKEND_LIBRARY)
find_package(CUDA)
include_directories(${CUDA_INCLUDE_DIRS})
mark_as_advanced(GPUBACKEND_LIBRARY)
list(APPEND QPANDA_LIBRARIES
${GPUBACKEND_LIBRARY}
${CUDA_LIBRARIES})
endif()
find_package(OpenMP)
if(OPENMP_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif(OPENMP_FOUND)
if(QPANDA_INCLUDE_DIR AND QPANDA_LIBRARY)
set(QPANDA_FOUND TRUE)
mark_as_advanced(QPANDA_LIBRARIES)
if(QPANDA_INCLUDE_DIR AND NOT QPANDA_VERSION_STRING)
foreach(_qpanda_version_header QPandaVersion.h)
if(EXISTS "${QPANDA_INCLUDE_DIR}/${_qpanda_version_header}")
file(READ "${QPANDA_INCLUDE_DIR}/${_qpanda_version_header}" QPANDA_VERSION_H_CONTENTS)
string(REGEX MATCH "#define QPANDA_MAJOR_VERSION [0-9]+"
QPANDA_MAJOR_VERSION ${QPANDA_VERSION_H_CONTENTS})
string(REGEX REPLACE "[^0-9]" "" QPANDA_MAJOR_VERSION ${QPANDA_MAJOR_VERSION})
string(REGEX MATCH "#define QPANDA_MINOR_VERSION [0-9]+"
QPANDA_MINOR_VERSION ${QPANDA_VERSION_H_CONTENTS})
string(REGEX REPLACE "[^0-9]" "" QPANDA_MINOR_VERSION ${QPANDA_MINOR_VERSION})
string(REGEX MATCH "#define QPANDA_PATCH_VERSION [0-9]+"
QPANDA_PATCH_VERSION ${QPANDA_VERSION_H_CONTENTS})
string(REGEX REPLACE "[^0-9]" "" QPANDA_PATCH_VERSION ${QPANDA_PATCH_VERSION})
set(QPANDA_VERSION_STR "${QPANDA_MAJOR_VERSION}.${QPANDA_MINOR_VERSION}.${QPANDA_PATCH_VERSION}")
unset(qpanda_version_str)
break()
endif()
endforeach()
endif()
else(QPANDA_INCLUDE_DIR AND QPANDA_LIBRARY)
message("QPANDA Not Find")
endif(QPANDA_INCLUDE_DIR AND QPANDA_LIBRARY)
include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
find_package_handle_standard_args(QPANDA
REQUIRED_VARS QPANDA_LIBRARY QPANDA_INCLUDE_DIR
VERSION_VAR QPANDA_VERSION_STR
HANDLE_COMPONENTS)