Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ORNL Quantum Computing Institute
xacc
Commits
64454408
Commit
64454408
authored
Jul 24, 2019
by
Mccaskey, Alex
Browse files
updating xacc-config.cmake to export targets according to modern cmake
Signed-off-by:
Alex McCaskey
<
mccaskeyaj@ornl.gov
>
parent
0ab2532f
Pipeline
#64321
passed with stage
in 6 minutes and 26 seconds
Changes
17
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
cmake/xacc-config.cmake.in
View file @
64454408
...
...
@@ -29,7 +29,133 @@ set (XACC_LIBRARIES "xacc;xacc-quantum-gate;xacc-quantum-aqc;xacc-pauli;antlr4-r
set (XACC_TEST_LIBRARIES "${XACC_LIBRARIES};gtest;gtest_main")
macro(add_xacc_test _TEST_NAME)
include_directories(${XACC_INCLUDE_ROOT}/gtest)
add_executable(${_TEST_NAME}Tester ${_TEST_NAME}Tester.cpp)
add_test(NAME xacc_${_TEST_NAME}Tester COMMAND ${_TEST_NAME}Tester)
target_link_libraries(${_TEST_NAME}Tester ${XACC_TEST_LIBRARIES})
endmacro()
set(CppMicroServicesConfig_DIR "${XACC_ROOT}/share/cppmicroservices4/cmake")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${XACC_ROOT}/share/xacc")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CppMicroServicesConfig_DIR}")
include(CppMicroServicesConfig)
macro(xacc_configure_library_rpath LIBNAME)
if(APPLE)
set_target_properties(${LIBNAME} PROPERTIES INSTALL_RPATH "@loader_path")
set_target_properties(${LIBNAME}
PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
else()
set_target_properties(${LIBNAME} PROPERTIES INSTALL_RPATH "$ORIGIN")
set_target_properties(${LIBNAME} PROPERTIES LINK_FLAGS "-shared")
endif()
endmacro()
macro(xacc_configure_plugin_rpath LIBNAME)
if(APPLE)
set_target_properties(${LIBNAME} PROPERTIES INSTALL_RPATH "@loader_path/../lib")
set_target_properties(${LIBNAME}
PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
else()
set_target_properties(${LIBNAME} PROPERTIES INSTALL_RPATH "$ORIGIN/../lib")
set_target_properties(${LIBNAME} PROPERTIES LINK_FLAGS "-shared")
endif()
endmacro()
# Create imported target CppMicroServices::CppMicroServices
add_library(CppMicroServices::CppMicroServices SHARED IMPORTED)
set_target_properties(CppMicroServices::CppMicroServices PROPERTIES
INTERFACE_COMPILE_FEATURES "cxx_variadic_templates;cxx_nullptr"
INTERFACE_INCLUDE_DIRECTORIES "${XACC_INCLUDE_ROOT}/cppmicroservices4"
INTERFACE_LINK_LIBRARIES "dl;-pthread"
)
# Import target "CppMicroServices::CppMicroServices" for configuration "Release"
set_property(TARGET CppMicroServices::CppMicroServices APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(CppMicroServices::CppMicroServices PROPERTIES
IMPORTED_LOCATION_RELEASE "${XACC_ROOT}/lib/libCppMicroServices.so.4.0.0"
IMPORTED_SONAME_RELEASE "libCppMicroServices.so.4.0.0"
)
# Create imported target xacc::xacc
add_library(xacc::xacc SHARED IMPORTED)
set_target_properties(xacc::xacc PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${XACC_INCLUDE_ROOT}/xacc"
INTERFACE_LINK_LIBRARIES "CppMicroServices"
)
# Import target "xacc::xacc" for configuration "Release"
set_property(TARGET xacc::xacc APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(xacc::xacc PROPERTIES
IMPORTED_LOCATION_RELEASE "${XACC_ROOT}/lib/libxacc.so"
IMPORTED_SONAME_RELEASE "libxacc.so"
)
add_library(xacc::quantum_gate SHARED IMPORTED)
set_target_properties(xacc::quantum_gate PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${XACC_INCLUDE_ROOT}/xacc;${XACC_INCLUDE_ROOT}/quantum/gate"
INTERFACE_LINK_LIBRARIES "xacc;CppMicroServices"
)
# Import target "xacc::quantum_gate" for configuration "Release"
set_property(TARGET xacc::quantum_gate APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(xacc::quantum_gate PROPERTIES
IMPORTED_LOCATION_RELEASE "${XACC_ROOT}/lib/libxacc-quantum-gate.so"
IMPORTED_SONAME_RELEASE "libxacc-quantum-gate.so"
)
# Create imported target xacc::quantum_aqc
add_library(xacc::quantum_aqc SHARED IMPORTED)
set_target_properties(xacc::quantum_aqc PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${XACC_INCLUDE_ROOT}/xacc;${XACC_INCLUDE_ROOT}/quantum/aqc"
INTERFACE_LINK_LIBRARIES "xacc;CppMicroServices"
)
# Import target "xacc::quantum_aqc" for configuration "Release"
set_property(TARGET xacc::quantum_aqc APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(xacc::quantum_aqc PROPERTIES
IMPORTED_LOCATION_RELEASE "${XACC_ROOT}/lib/libxacc-quantum-aqc.so"
IMPORTED_SONAME_RELEASE "libxacc-quantum-aqc.so"
)
# Create imported target xacc::pauli
add_library(xacc::pauli SHARED IMPORTED)
set_target_properties(xacc::pauli PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${XACC_INCLUDE_ROOT}/xacc;${XACC_INCLUDE_ROOT}/quantum/gate"
INTERFACE_LINK_LIBRARIES "xacc;CppMicroServices"
)
# Import target "xacc::pauli" for configuration "Release"
set_property(TARGET xacc::pauli APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(xacc::pauli PROPERTIES
IMPORTED_LOCATION_RELEASE "${XACC_ROOT}/lib/libxacc-pauli.so"
IMPORTED_SONAME_RELEASE "libxacc-pauli.so"
)
# Create imported target xacc::fermion
add_library(xacc::fermion SHARED IMPORTED)
set_target_properties(xacc::fermion PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${XACC_INCLUDE_ROOT}/xacc;${XACC_INCLUDE_ROOT}/quantum/gate"
INTERFACE_LINK_LIBRARIES "xacc;CppMicroServices"
)
# Import target "xacc::fermion" for configuration "Release"
set_property(TARGET xacc::fermion APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(xacc::fermion PROPERTIES
IMPORTED_LOCATION_RELEASE "${XACC_ROOT}/lib/libxacc-fermion.so"
IMPORTED_SONAME_RELEASE "libxacc-fermion.so"
)
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set (CMAKE_INSTALL_PREFIX "${XACC_ROOT}" CACHE PATH "default install path" FORCE )
endif()
quantum/gate/CMakeLists.txt
View file @
64454408
...
...
@@ -42,6 +42,7 @@ target_include_directories(${LIBRARY_NAME}
ir/instructions
ir/algorithms
accelerator
PRIVATE
${
CMAKE_BINARY_DIR
}
${
CMAKE_SOURCE_DIR
}
/quantum/utils
${
CMAKE_SOURCE_DIR
}
/tpls/exprtk
...
...
@@ -66,7 +67,7 @@ usFunctionEmbedResources(TARGET
FILES
manifest.json
)
target_link_libraries
(
${
LIBRARY_NAME
}
PUBLIC xacc PRIVATE
CppMicroServices
Boost::graph
)
target_link_libraries
(
${
LIBRARY_NAME
}
PUBLIC xacc PRIVATE Boost::graph
)
if
(
APPLE
)
set_target_properties
(
xacc-quantum-gate
...
...
quantum/gate/ir/GateFunction.cpp
View file @
64454408
...
...
@@ -18,6 +18,12 @@
#include
"rapidjson/prettywriter.h"
using
namespace
rapidjson
;
#include
"exprtk.hpp"
using
symbol_table_t
=
exprtk
::
symbol_table
<
double
>
;
using
expression_t
=
exprtk
::
expression
<
double
>
;
using
parser_t
=
exprtk
::
parser
<
double
>
;
namespace
xacc
{
namespace
quantum
{
...
...
quantum/gate/ir/GateFunction.hpp
View file @
64454408
...
...
@@ -17,7 +17,6 @@
#include
"IRProvider.hpp"
#include
"GateInstruction.hpp"
#include
"XACC.hpp"
#include
"exprtk.hpp"
namespace
xacc
{
...
...
@@ -26,12 +25,6 @@ class Graph;
namespace
quantum
{
static
constexpr
double
pi
=
3.141592653589793238
;
using
symbol_table_t
=
exprtk
::
symbol_table
<
double
>
;
using
expression_t
=
exprtk
::
expression
<
double
>
;
using
parser_t
=
exprtk
::
parser
<
double
>
;
/**
* The GateFunction is a realization of Function for gate-model
* quantum computing. It is composed of GateInstructions that
...
...
quantum/gate/ir/GateIR.cpp
View file @
64454408
...
...
@@ -10,6 +10,7 @@
* Contributors:
* Alexander J. McCaskey - initial API and implementation
*******************************************************************************/
#include
<set>
#include
"JsonVisitor.hpp"
#include
"GateIR.hpp"
#define RAPIDJSON_HAS_STDSTRING 1
...
...
quantum/plugins/dwave/accelerator/DWAccelerator.cpp
View file @
64454408
...
...
@@ -258,7 +258,7 @@ DWAccelerator::processInput(std::shared_ptr<AcceleratorBuffer> buffer,
}
annealingStr
=
gen
.
getAsString
(
as
);
xacc
::
info
(
"Annealing Schedule: "
+
annealingStr
);
//
xacc::info("Annealing Schedule: " + annealingStr);
if
(
xacc
::
optionExists
(
"dwave-num-reads"
))
{
trials
=
xacc
::
getOption
(
"dwave-num-reads"
);
...
...
@@ -315,7 +315,7 @@ DWAccelerator::processResponse(std::shared_ptr<AcceleratorBuffer> buffer,
}
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
100
));
xacc
::
info
(
msg
);
//
xacc::info(msg);
}
// We've completed, so let's get
...
...
quantum/plugins/dwave/ir/rbm/RBMGenerator.cpp
View file @
64454408
...
...
@@ -49,8 +49,6 @@ std::shared_ptr<Function> RBMGenerator::generate(
std
::
shared_ptr
<
AcceleratorBuffer
>
buffer
,
std
::
vector
<
InstructionParameter
>
parameters
)
{
xacc
::
info
(
"Running RBM IRGenerator."
);
int
n_visible
=
parameters
[
1
].
as
<
int
>
();
int
n_hidden
=
parameters
[
0
].
as
<
int
>
();
...
...
quantum/plugins/ibm/CMakeLists.txt
View file @
64454408
...
...
@@ -43,7 +43,9 @@ if(LAPACK_FOUND)
accelerator/qiskit-terra/src/qasm-simulator-cpp/src/utilities
accelerator/qiskit-terra/src/qasm-simulator-cpp/src/third-party/headers
accelerator/json
${
CMAKE_SOURCE_DIR
}
/tpls/antlr/runtime/src
)
${
CMAKE_SOURCE_DIR
}
/tpls/antlr/runtime/src
${
CMAKE_SOURCE_DIR
}
/tpls/rapidjson/include
${
CMAKE_SOURCE_DIR
}
/tpls/exprtk
)
target_link_libraries
(
${
LIBRARY_NAME
}
...
...
@@ -62,7 +64,9 @@ else()
compiler/generated
accelerator/qiskit-terra/src/qasm-simulator-cpp/src/third-party/headers
accelerator/json
${
CMAKE_SOURCE_DIR
}
/tpls/antlr/runtime/src
)
${
CMAKE_SOURCE_DIR
}
/tpls/antlr/runtime/src
${
CMAKE_SOURCE_DIR
}
/tpls/rapidjson/include
${
CMAKE_SOURCE_DIR
}
/tpls/exprtk
)
target_link_libraries
(
${
LIBRARY_NAME
}
PUBLIC xacc
xacc-quantum-gate
...
...
quantum/plugins/ibm/accelerator/IBMAccelerator.cpp
View file @
64454408
...
...
@@ -32,6 +32,7 @@
#include
"OpenPulseVisitor.hpp"
#include
"OpenQasmVisitor.hpp"
#include
<cctype>
#include
<fstream>
#include
"QObjectExperimentVisitor.hpp"
...
...
quantum/plugins/ibm/accelerator/LocalIBMAccelerator.cpp
View file @
64454408
...
...
@@ -34,6 +34,13 @@
#include
"simulator.hpp"
#include
<regex>
#define RAPIDJSON_HAS_STDSTRING 1
#include
"rapidjson/document.h"
#include
"rapidjson/prettywriter.h"
using
namespace
rapidjson
;
// for convenience
using
json
=
nlohmann
::
json
;
...
...
quantum/plugins/ibm/accelerator/LocalIBMAccelerator.hpp
View file @
64454408
...
...
@@ -35,13 +35,6 @@
#include
"InstructionIterator.hpp"
#include
"OpenQasmVisitor.hpp"
#define RAPIDJSON_HAS_STDSTRING 1
#include
"rapidjson/document.h"
#include
"rapidjson/prettywriter.h"
using
namespace
rapidjson
;
using
namespace
xacc
;
namespace
xacc
{
...
...
quantum/plugins/rigetti/CMakeLists.txt
View file @
64454408
...
...
@@ -19,7 +19,9 @@ target_include_directories(${LIBRARY_NAME}
PUBLIC accelerator
compiler
compiler/generated
${
CMAKE_SOURCE_DIR
}
/tpls/antlr/runtime/src
)
${
CMAKE_SOURCE_DIR
}
/tpls/antlr/runtime/src
${
CMAKE_SOURCE_DIR
}
/tpls/rapidjson/include
${
CMAKE_SOURCE_DIR
}
/tpls/exprtk
)
target_link_libraries
(
${
LIBRARY_NAME
}
PUBLIC xacc
xacc-quantum-gate
...
...
xacc/CMakeLists.txt
View file @
64454408
...
...
@@ -61,7 +61,7 @@ target_include_directories(xacc
${
CMAKE_SOURCE_DIR
}
/tpls/mpark-variant
)
message
(
STATUS
"LIBS:
${
LIBUNWIND_LIBRARIES
}
${
LIBUNWINDX86_LIBRARIES
}
"
)
target_link_libraries
(
xacc P
RIVATE
CppMicroServices cpr
${
LIBUNWIND_LIBRARIES
}
${
LIBUNWINDX86_LIBRARIES
}
)
target_link_libraries
(
xacc P
UBLIC
CppMicroServices
PRIVATE
cpr
${
LIBUNWIND_LIBRARIES
}
${
LIBUNWINDX86_LIBRARIES
}
)
else
()
...
...
@@ -82,7 +82,7 @@ target_include_directories(xacc
algorithm
optimizer
${
CMAKE_SOURCE_DIR
}
/tpls/mpark-variant
)
target_link_libraries
(
xacc P
RIVATE
CppMicroServices cpr
)
target_link_libraries
(
xacc P
UBLIC
CppMicroServices
PRIVATE
cpr
)
endif
()
if
(
APPLE
)
...
...
@@ -93,7 +93,6 @@ else()
set_target_properties
(
xacc PROPERTIES LINK_FLAGS
"-shared"
)
endif
()
# Add the tests
if
(
XACC_BUILD_TESTS
)
include_directories
(
${
GTEST_INCLUDE_DIRS
}
)
...
...
xacc/XACC.cpp
View file @
64454408
...
...
@@ -267,6 +267,19 @@ std::shared_ptr<Compiler> getCompiler(const std::string &name) {
}
return
c
;
}
std
::
shared_ptr
<
IRProvider
>
getIRProvider
(
const
std
::
string
&
name
)
{
if
(
!
xacc
::
xaccFrameworkInitialized
)
{
error
(
"XACC not initialized before use. Please execute "
"xacc::Initialize() before using API."
);
}
auto
irp
=
xacc
::
getService
<
IRProvider
>
(
name
);
if
(
!
irp
)
{
error
(
"Invalid IRProvicer. Could not find "
+
name
+
" in Service Registry."
);
}
return
irp
;
}
std
::
shared_ptr
<
Compiler
>
getCompiler
()
{
if
(
!
xacc
::
xaccFrameworkInitialized
)
{
...
...
xacc/XACC.hpp
View file @
64454408
...
...
@@ -15,10 +15,14 @@
#include
"Compiler.hpp"
#include
"RemoteAccelerator.hpp"
//
#include "
AcceleratorBuff
er.hpp"
#include
"
IRProvid
er.hpp"
namespace
xacc
{
namespace
constants
{
static
constexpr
double
pi
=
3.141592653589793238
;
}
class
CLIParser
;
// Boolean indicating that framework has been initialized
...
...
@@ -185,6 +189,8 @@ const std::string getOption(const std::string &optionKey);
void
setOption
(
const
std
::
string
&
optionKey
,
const
std
::
string
&
value
);
void
unsetOption
(
const
std
::
string
&
optionKey
);
std
::
shared_ptr
<
IRProvider
>
getIRProvider
(
const
std
::
string
&
name
);
/**
* Set the Compiler to use.
*
...
...
xacc/service/ServiceRegistry.cpp
View file @
64454408
#include
"ServiceRegistry.hpp"
#include
"xacc_config.hpp"
namespace
xacc
{
...
...
xacc/service/ServiceRegistry.hpp
View file @
64454408
...
...
@@ -20,8 +20,6 @@
#include
"OptionsProvider.hpp"
#include
"Cloneable.hpp"
#include
"xacc_config.hpp"
#include
<cppmicroservices/FrameworkFactory.h>
#include
<cppmicroservices/Framework.h>
#include
<cppmicroservices/BundleContext.h>
...
...
@@ -63,7 +61,7 @@ public:
const
std
::
string
getRootPathString
()
{
return
rootPathStr
;
}
void
initialize
(
const
std
::
string
rootPath
);
template
<
typename
ServiceInterface
>
bool
hasService
(
const
std
::
string
name
)
{
auto
allServiceRefs
=
context
.
GetServiceReferences
<
ServiceInterface
>
();
for
(
auto
s
:
allServiceRefs
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment