Skip to content

Commit

Permalink
Merge branch 'master' into tnguyen/fix-for-libcpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Thien Nguyen committed Jan 27, 2021
2 parents 6703ff3 + 91c516b commit c64bce2
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 98 deletions.
3 changes: 2 additions & 1 deletion quantum/plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ add_subdirectory(xasm)
add_subdirectory(qpp)
add_subdirectory(staq)
add_subdirectory(observable_transforms)
#add_subdirectory(jaqal)

find_library(QRACK_LIBRARY NAMES qrack)
if (QRACK_LIBRARY)
Expand All @@ -39,4 +40,4 @@ add_subdirectory(qsim)
add_subdirectory(atos_qlm)
add_subdirectory(noise_model)

install (FILES utils/OperatorPool.hpp DESTINATION include/quantum/gate)
install (FILES utils/OperatorPool.hpp DESTINATION include/quantum/gate)
107 changes: 60 additions & 47 deletions quantum/plugins/atos_qlm/accelerator/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,57 +1,70 @@
set(LIBRARY_NAME xacc-atos-qlm)
find_package(Python COMPONENTS Interpreter Development)
get_filename_component(PYTHON_LIB_NAME ${Python_LIBRARIES} NAME)
configure_file(QlmAccelerator.in.cpp
${CMAKE_BINARY_DIR}/quantum/plugins/atos_qlm/accelerator/QlmAccelerator.cpp)
file(GLOB SRC ${CMAKE_BINARY_DIR}/quantum/plugins/atos_qlm/accelerator/QlmAccelerator.cpp)

set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing -O2 -g -pipe -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wformat -fexceptions --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=native -D_GNU_SOURCE -fPIC -fwrapv")

usfunctiongetresourcesource(TARGET ${LIBRARY_NAME} OUT SRC)
usfunctiongeneratebundleinit(TARGET ${LIBRARY_NAME} OUT SRC)

add_library(${LIBRARY_NAME} SHARED ${SRC})

target_include_directories(${LIBRARY_NAME} PUBLIC . ${Python_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/tpls/pybind11/include)
target_link_libraries(${LIBRARY_NAME} PUBLIC xacc xacc-quantum-gate Python::Python)

set(_bundle_name xacc_qlm)
set_target_properties(${LIBRARY_NAME}
PROPERTIES COMPILE_DEFINITIONS
US_BUNDLE_NAME=${_bundle_name}
US_BUNDLE_NAME
${_bundle_name})

usfunctionembedresources(TARGET
${LIBRARY_NAME}
WORKING_DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}
FILES
manifest.json)

if(APPLE)
set_target_properties(${LIBRARY_NAME}
PROPERTIES INSTALL_RPATH "@loader_path/../lib")
set_target_properties(${LIBRARY_NAME}
PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
else()
set_target_properties(${LIBRARY_NAME}
PROPERTIES INSTALL_RPATH "$ORIGIN/../lib")
set_target_properties(${LIBRARY_NAME} PROPERTIES LINK_FLAGS "-shared")
endif()

if(Python_FOUND)

get_filename_component(PYTHON_LIB_NAME ${Python_LIBRARIES} NAME)
configure_file(
QlmAccelerator.in.cpp
${CMAKE_BINARY_DIR}/quantum/plugins/atos_qlm/accelerator/QlmAccelerator.cpp)
file(
GLOB SRC
${CMAKE_BINARY_DIR}/quantum/plugins/atos_qlm/accelerator/QlmAccelerator.cpp)

set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -fno-strict-aliasing -O2 -g -pipe -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wformat -fexceptions --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=native -D_GNU_SOURCE -fPIC -fwrapv"
)

usfunctiongetresourcesource(TARGET ${LIBRARY_NAME} OUT SRC)
usfunctiongeneratebundleinit(TARGET ${LIBRARY_NAME} OUT SRC)

add_library(${LIBRARY_NAME} SHARED ${SRC})

target_include_directories(
${LIBRARY_NAME} PUBLIC . ${Python_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}/tpls/pybind11/include)
target_link_libraries(${LIBRARY_NAME} PUBLIC xacc xacc-quantum-gate
Python::Python)

set(_bundle_name xacc_qlm)
set_target_properties(
${LIBRARY_NAME}
PROPERTIES COMPILE_DEFINITIONS US_BUNDLE_NAME=${_bundle_name}
US_BUNDLE_NAME ${_bundle_name})

usfunctionembedresources(TARGET ${LIBRARY_NAME} WORKING_DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR} FILES manifest.json)

if(APPLE)
set_target_properties(${LIBRARY_NAME} PROPERTIES INSTALL_RPATH
"@loader_path/../lib")
set_target_properties(${LIBRARY_NAME}
PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
else()
set_target_properties(${LIBRARY_NAME} PROPERTIES INSTALL_RPATH
"$ORIGIN/../lib")
set_target_properties(${LIBRARY_NAME} PROPERTIES LINK_FLAGS "-shared")
endif()

install(TARGETS ${LIBRARY_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/plugins)

# Check if we have QAT (Atos QLM library) installed
execute_process(COMMAND ${Python_EXECUTABLE} -c "import qat" RESULT_VARIABLE QAT_EXISTS)
if (QAT_EXISTS EQUAL "1")
message(STATUS "${BoldYellow}QAT not found. Atos QLM Accelerator will not work.${ColorReset}")
execute_process(COMMAND ${Python_EXECUTABLE} -c "import qat"
RESULT_VARIABLE QAT_EXISTS)
if(QAT_EXISTS EQUAL "1")
message(
STATUS
"${BoldYellow}QAT not found. Atos QLM Accelerator will not work.${ColorReset}"
)
else()
# We always build the accelerator, but only test if the QAT library is installed (on the QLM server).
# We always build the accelerator, but only test if the QAT library is
# installed (on the QLM server).
if(XACC_BUILD_TESTS)
add_subdirectory(tests)
endif()
endif()
else()
message(
STATUS
"${BoldYellow} Python Interpreter or Libs not found, skipping Atos Simulator Build.${ColorReset}"
)
endif()

install(TARGETS ${LIBRARY_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/plugins)

103 changes: 55 additions & 48 deletions quantum/plugins/circuits/py-qsearch/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,71 +1,78 @@
# *******************************************************************************
# Copyright (c) 2019 UT-Battelle, LLC.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# and Eclipse Distribution License v.10 which accompany this distribution.
# The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
# and the Eclipse Distribution License is available at
# https://eclipse.org/org/documents/edl-v10.php
# Copyright (c) 2019 UT-Battelle, LLC. All rights reserved. This program and the
# accompanying materials are made available under the terms of the Eclipse
# Public License v1.0 and Eclipse Distribution License v.10 which accompany this
# distribution. The Eclipse Public License is available at
# http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution License
# is available at https://eclipse.org/org/documents/edl-v10.php
#
# Contributors:
# Alexander J. McCaskey - initial API and implementation
# Contributors: Alexander J. McCaskey - initial API and implementation
# *******************************************************************************/
set(LIBRARY_NAME xacc-py-qsearch)

find_package(Python COMPONENTS Interpreter Development)
get_filename_component(PYTHON_LIB_NAME ${Python_LIBRARIES} NAME)
if(Python_FOUND)

configure_file(py_qsearch.in.cpp
${CMAKE_BINARY_DIR}/quantum/plugins/circuits/py-qsearch/py_qsearch.cpp)
file(GLOB SRC ${CMAKE_BINARY_DIR}/quantum/plugins/circuits/py-qsearch/py_qsearch.cpp)
get_filename_component(PYTHON_LIB_NAME ${Python_LIBRARIES} NAME)

set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing -O2 -g -pipe -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wformat -fexceptions --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=native -D_GNU_SOURCE -fPIC -fwrapv")
usfunctiongetresourcesource(TARGET ${LIBRARY_NAME} OUT SRC)
usfunctiongeneratebundleinit(TARGET ${LIBRARY_NAME} OUT SRC)
configure_file(
py_qsearch.in.cpp
${CMAKE_BINARY_DIR}/quantum/plugins/circuits/py-qsearch/py_qsearch.cpp)
file(GLOB SRC
${CMAKE_BINARY_DIR}/quantum/plugins/circuits/py-qsearch/py_qsearch.cpp)

add_library(${LIBRARY_NAME} SHARED ${SRC})
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -fno-strict-aliasing -O2 -g -pipe -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wformat -fexceptions --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=native -D_GNU_SOURCE -fPIC -fwrapv"
)
usfunctiongetresourcesource(TARGET ${LIBRARY_NAME} OUT SRC)
usfunctiongeneratebundleinit(TARGET ${LIBRARY_NAME} OUT SRC)

target_include_directories(
${LIBRARY_NAME}
PUBLIC . ${Python_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/tpls/pybind11/include)
add_library(${LIBRARY_NAME} SHARED ${SRC})

target_link_libraries(${LIBRARY_NAME} PUBLIC xacc xacc-quantum-gate Python::Python)
target_include_directories(
${LIBRARY_NAME} PUBLIC . ${Python_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}/tpls/pybind11/include)

set(_bundle_name xacc_py_qsearch)
set_target_properties(${LIBRARY_NAME}
PROPERTIES COMPILE_DEFINITIONS
US_BUNDLE_NAME=${_bundle_name}
US_BUNDLE_NAME
${_bundle_name})
target_link_libraries(${LIBRARY_NAME} PUBLIC xacc xacc-quantum-gate
Python::Python)

usfunctionembedresources(TARGET
${LIBRARY_NAME}
WORKING_DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}
FILES
manifest.json)
set(_bundle_name xacc_py_qsearch)
set_target_properties(
${LIBRARY_NAME}
PROPERTIES COMPILE_DEFINITIONS US_BUNDLE_NAME=${_bundle_name}
US_BUNDLE_NAME ${_bundle_name})

usfunctionembedresources(TARGET ${LIBRARY_NAME} WORKING_DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR} FILES manifest.json)

if(APPLE)
set_target_properties(${LIBRARY_NAME}
PROPERTIES INSTALL_RPATH "@loader_path/../lib")
set_target_properties(${LIBRARY_NAME}
PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
else()
set_target_properties(${LIBRARY_NAME}
PROPERTIES INSTALL_RPATH "$ORIGIN/../lib")
set_target_properties(${LIBRARY_NAME} PROPERTIES LINK_FLAGS "-rdynamic -shared")
endif()
if(APPLE)
set_target_properties(${LIBRARY_NAME} PROPERTIES INSTALL_RPATH
"@loader_path/../lib")
set_target_properties(${LIBRARY_NAME}
PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
else()
set_target_properties(${LIBRARY_NAME} PROPERTIES INSTALL_RPATH
"$ORIGIN/../lib")
set_target_properties(${LIBRARY_NAME} PROPERTIES LINK_FLAGS
"-rdynamic -shared")
endif()


if(Python_FOUND)
execute_process(COMMAND ${Python_EXECUTABLE} -c "import qsearch" RESULT_VARIABLE QSEARCH_EXISTS)
if (QSEARCH_EXISTS EQUAL "1")
message(STATUS "${BoldYellow}QSearch not found. py-qsearch Synthesis not available until you install it.${ColorReset}")
install(TARGETS ${LIBRARY_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/plugins)

execute_process(COMMAND ${Python_EXECUTABLE} -c "import qsearch"
RESULT_VARIABLE QSEARCH_EXISTS)
if(QSEARCH_EXISTS EQUAL "1")
message(
STATUS
"${BoldYellow}QSearch not found. py-qsearch Synthesis not available until you install it.${ColorReset}"
)
else()
if(XACC_BUILD_TESTS)
add_subdirectory(tests)
endif()
endif()
else()
message(STATUS "${BoldYellow} Python Interpreter or Libs not found, skipping QSearch Plugin Build.${ColorReset}")
endif()

install(TARGETS ${LIBRARY_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/plugins)
2 changes: 1 addition & 1 deletion quantum/plugins/dwave/tpls/legacy-sapi-clients
2 changes: 1 addition & 1 deletion tpls/cppmicroservices

0 comments on commit c64bce2

Please sign in to comment.