Add Conan package manager to the buildsystem (#648)

* Update thrust requirement treatment. 
* Added conan info to contributing guide
* Handle thrust TBB & OMP dependency
* Fixed llvm-openmp treatment for macos. Making it shared for python addon.
* Removing unneeded cmake coded regarding third party libraries.
* Removing unneeded distribution of third party libraries.
* Fixes to make travis work. Muparserx fPIC and conan installation for standalone build.
* Disable fpic for muparserx on windows
* Add catch2 to conan packages
* Remove catch2 distributed files
* Conan dep up in file to avoid requirements conflict
* Back to openmp 9.0.1
* Update requires. Remove conan from requirements
* Remove FindXXXX.cmake files not used any more
* llvm-openmp to 8.0.1 to avoid deprecation warning. Added conan.cmake instead of downloading. Removed hack to avoid deprecation warning
* No global include dir. Removed conanfile.txt
* Remove openblas dependencies in ci
* Bump shots from 2000 to 4000 for non-deterministic/random tests
This commit is contained in:
Victor Villar 2020-05-27 19:06:27 +02:00 committed by GitHub
parent 787514e3fa
commit 05245061b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
57 changed files with 810 additions and 31941 deletions

6
.gitmodules vendored
View File

@ -1,6 +0,0 @@
[submodule "src/third-party/headers/muparserx"]
path = src/third-party/headers/muparserx
url = https://github.com/beltoforion/muparserx
[submodule "src/third-party/headers/thrust"]
path = src/third-party/headers/thrust
url = https://github.com/thrust/thrust.git

View File

@ -52,7 +52,6 @@ stage_linux: &stage_linux
before_install:
- sudo apt-get -y update
- sudo apt-get -y install g++-7
- sudo apt-get -y install libopenblas-dev
before_script:
- |
if [ ! "$(ls -A .stestr)" ]; then
@ -148,7 +147,7 @@ jobs:
services:
- docker
env:
- CIBW_BEFORE_BUILD="pip install -U Cython pip virtualenv pybind11 && yum install -y openblas-devel"
- CIBW_BEFORE_BUILD="pip install -U Cython pip virtualenv pybind11"
- CIBW_SKIP="cp27-* cp34-* *-manylinux_i686"
- CIBW_MANYLINUX_X86_64_IMAGE="manylinux2010"
- CIBW_MANYLINUX_I686_IMAGE="manylinux2010"
@ -166,7 +165,7 @@ jobs:
script:
- python setup.py sdist
- mkdir out; cd out; virtualenv aer-test
- aer-test/bin/pip install git+https://github.com/Qiskit/qiskit-terra
- aer-test/bin/pip install -c ../constraints.txt git+https://github.com/Qiskit/qiskit-terra
- aer-test/bin/pip install ../dist/*tar.gz
- aer-test/bin/python ../tools/verify_wheels.py
- aer-test/bin/pip check
@ -185,7 +184,7 @@ jobs:
script:
- python setup.py sdist
- mkdir out; cd out; virtualenv aer-test
- aer-test/bin/pip install git+https://github.com/Qiskit/qiskit-terra
- aer-test/bin/pip install -c ../constraints.txt git+https://github.com/Qiskit/qiskit-terra
- aer-test/bin/pip install ../dist/*tar.gz
- aer-test/bin/python ../tools/verify_wheels.py
- aer-test/bin/pip check
@ -194,7 +193,8 @@ jobs:
name: Standalone Build Linux
<<: *stage_linux
language: cpp
install: true
install:
- pip install conan
before_script: true
script:
- mkdir out; cd out; cmake ..
@ -277,7 +277,7 @@ jobs:
services:
- docker
env:
- CIBW_BEFORE_BUILD="pip install -U Cython pip virtualenv pybind11 && yum install -y openblas-devel"
- CIBW_BEFORE_BUILD="pip install -U Cython pip virtualenv pybind11"
- CIBW_SKIP="cp27-* cp34-* *-manylinux_i686"
- CIBW_MANYLINUX_X86_64_IMAGE="manylinux2010"
- CIBW_MANYLINUX_I686_IMAGE="manylinux2010"
@ -313,10 +313,6 @@ jobs:
- TWINE_USERNAME=qiskit
- CIBW_TEST_COMMAND="python3 {project}/tools/verify_wheels.py"
- CIBW_TEST_REQUIRES="git+https://github.com/Qiskit/qiskit-terra.git"
addons:
homebrew:
packages:
- openblas
script:
- sudo pip2 install -U pip virtualenv
- sudo pip2 install cibuildwheel==1.1.0 'twine<2.0'
@ -337,7 +333,8 @@ jobs:
name: Standalone Build Linux (Power)
arch: ppc64le
<<: *stage_linux
install: true
install:
- pip install conan
before_script: true
script:
- mkdir out; cd out; cmake ..

View File

@ -27,6 +27,7 @@ include(CTest)
include(compiler_utils)
include(Linter)
include(findBLASInSpecificPath)
include(conan_utils)
# Get version information
get_version(${VERSION_NUM})
@ -36,12 +37,7 @@ configure_file("${PROJECT_SOURCE_DIR}/contrib/standalone/version.hpp.in"
set(AER_SIMULATOR_CPP_SRC_DIR "${PROJECT_SOURCE_DIR}/src")
set(AER_SIMULATOR_CPP_MAIN
"${PROJECT_SOURCE_DIR}/contrib/standalone/qasm_simulator.cpp")
set(AER_SIMULATOR_CPP_EXTERNAL_LIBS
"${AER_SIMULATOR_CPP_SRC_DIR}/third-party/headers"
"${AER_SIMULATOR_CPP_SRC_DIR}/third-party/macos/lib"
"${AER_SIMULATOR_CPP_SRC_DIR}/third-party/win64/lib"
"${AER_SIMULATOR_CPP_SRC_DIR}/third-party/linux/lib"
"${USER_LIB_PATH}")
set(AER_SIMULATOR_CPP_EXTERNAL_LIBS "${USER_LIB_PATH}")
set(AER_COMPILER_DEFINITIONS "")
@ -58,11 +54,11 @@ if(CCACHE_FOUND)
endif(CCACHE_FOUND)
# Set default build type to Release with Debug Symbols
IF(NOT CMAKE_BUILD_TYPE)
if(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: Debug Release"
FORCE)
ENDIF(NOT CMAKE_BUILD_TYPE)
endif(NOT CMAKE_BUILD_TYPE)
if(APPLE AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# In order to build for MacOSX 10.9 and above with Clang, we need to force the "deployment target" to 10.9
@ -117,46 +113,37 @@ endif()
#
# Looking for external libraries
#
setup_conan()
# If we do not set them with a space CMake fails afterwards if nothing is set for this vars!
set(AER_LINKER_FLAGS " ")
set(AER_COMPILER_FLAGS " ")
message(STATUS "Looking for OpenMP support...")
find_package(OpenMP QUIET)
# This is a hack for building with Apple's LLVM, which doesn't support OpenMP yet
# so we need to link with an external library: libomp.
# NOTE: CMake >= 3.12.0 doesn't need this hack. It will just find OpenMP in the
# first find_package(OpenMP) call
if(NOT "${OpenMP_FOUND}" OR NOT "${OpenMP_CXX_FOUND}")
if(APPLE)
set(OpenMP_CXX_FLAGS "-Xpreprocessor -fopenmp")
set(OpenMP_CXX_LIB_NAMES "omp")
set(OpenMP_omp_LIBRARY "${AER_SIMULATOR_CPP_SRC_DIR}/third-party/macos/lib/libomp.dylib")
include_directories("${AER_SIMULATOR_CPP_SRC_DIR}/third-party/macos/lib")
set(OPENMP_FOUND TRUE)
if(APPLE)
set(OPENMP_FOUND TRUE)
if(NOT SKBUILD)
set(AER_LIBRARIES ${AER_LIBRARIES} CONAN_PKG::llvm-openmp)
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CONAN_CXX_FLAGS_LLVM-OPENMP}")
set(AER_SIMULATOR_CPP_EXTERNAL_LIBS ${AER_SIMULATOR_CPP_EXTERNAL_LIBS} ${CONAN_INCLUDE_DIRS_LLVM-OPENMP})
endif()
endif()
if(OPENMP_FOUND)
set(AER_COMPILER_FLAGS "${AER_COMPILER_FLAGS} ${OpenMP_CXX_FLAGS}")
set(AER_LINKER_FLAGS "${AER_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
if(APPLE)
# On Apple and clang, we do need to link against the library unless we are building
# the Terra Addon, see issue: https://github.com/Qiskit/qiskit-aer/issues/1
if(NOT SKBUILD)
set(OPENMP_EXTERNAL_LIB "${OpenMP_${OpenMP_CXX_LIB_NAMES}_LIBRARY}")
message(STATUS "Adding Clang: ${OPENMP_EXTERNAL_LIB}")
endif()
endif()
message(STATUS "OpenMP found!")
message(STATUS "OpenMP_CXX_FLAGS = ${OpenMP_CXX_FLAGS}")
message(STATUS "OpenMP_EXE_LINKER_FLAGS = ${OpenMP_EXE_LINKER_FLAGS}")
else()
message(STATUS "WARNING: No OpenMP support found!")
find_package(OpenMP QUIET)
if(OPENMP_FOUND)
set(AER_COMPILER_FLAGS "${AER_COMPILER_FLAGS} ${OpenMP_CXX_FLAGS}")
set(AER_LINKER_FLAGS "${AER_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
message(STATUS "OpenMP found!")
message(STATUS "OpenMP_CXX_FLAGS = ${OpenMP_CXX_FLAGS}")
message(STATUS "OpenMP_EXE_LINKER_FLAGS = ${OpenMP_EXE_LINKER_FLAGS}")
else()
message(STATUS "WARNING: No OpenMP support found!")
endif()
endif()
message(STATUS "Looking for NLOHMANN Json library...")
set(NLOHMANN_JSON_PATH ${AER_SIMULATOR_CPP_EXTERNAL_LIBS})
find_package(nlohmann_json REQUIRED)
if(STATIC_LINKING)
message(STATUS "Using static linking with Threads...")
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
@ -172,37 +159,10 @@ endif()
if(BLAS_LIB_PATH)
find_BLAS_in_specific_path(${BLAS_LIB_PATH})
else()
if(APPLE)
message(STATUS "Looking for Apple BLAS library...")
set(BLA_VENDOR "Apple")
else()
message(STATUS "Looking for OpenBLAS library...")
set(BLA_VENDOR "OpenBLAS")
endif()
if(WIN32)
message(STATUS "Uncompressing OpenBLAS static library...")
execute_process(COMMAND ${CMAKE_COMMAND} -E tar "xvfj" "${AER_SIMULATOR_CPP_SRC_DIR}/third-party/win64/lib/openblas.7z" WORKING_DIRECTORY "${AER_SIMULATOR_CPP_SRC_DIR}/third-party/win64/lib/")
endif()
find_package(BLAS QUIET)
if(NOT BLAS_FOUND)
message(STATUS "OpenBLAS not found. Looking for any other BLAS library...")
unset(BLA_VENDOR)
find_package(BLAS REQUIRED)
endif()
set(BLAS_LIBRARIES CONAN_PKG::openblas)
endif()
message(STATUS "BLAS library found: ${BLAS_LIBRARIES}")
message(STATUS "Looking for spdlog library...")
find_package(spdlog QUIET)
if(spdlog_FOUND)
message(STATUS "spdlog found.")
set(SPDLOG_LIB spdlog::spdlog)
else()
message(STATUS "spdlog not found.")
set(SPDLOG_LIB "")
endif()
# Windows don't have a DL library (dlopen, dlclose, etc...)
if(NOT MSVC)
find_library(DL_LIB NAMES dl)
@ -226,19 +186,17 @@ if(AER_THRUST_SUPPORTED)
set(AER_COMPILER_DEFINITIONS ${AER_COMPILER_DEFINITIONS} THRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_CUDA)
set(THRUST_DEPENDANT_LIBS "")
elseif(AER_THRUST_BACKEND STREQUAL "TBB")
message(STATUS "Thrust library: Looking for TBB backend...")
find_package(TBB REQUIRED)
message(STATUS "TBB Support found!")
get_thrust_source_code()
set(THRUST_DEPENDANT_LIBS ${TBB_LIBRARIES})
set(AER_COMPILER_DEFINITIONS ${AER_COMPILER_DEFINITIONS} THRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_TBB AER_THRUST_CPU=TRUE)
set(AER_SIMULATOR_CPP_EXTERNAL_LIBS ${AER_SIMULATOR_CPP_EXTERNAL_LIBS} ${CONAN_INCLUDE_DIRS_THRUST})
set(THRUST_DEPENDANT_LIBS CONAN_PKG::tbb)
set(AER_COMPILER_DEFINITIONS ${AER_COMPILER_DEFINITIONS} AER_THRUST_CPU=TRUE)
elseif(AER_THRUST_BACKEND STREQUAL "OMP")
message(STATUS "Thrust library: Setting OMP backend")
if(NOT OPENMP_FOUND)
message(FATAL_ERROR "There's no OMP support. We cannot set Thrust backend to OMP!!")
endif()
get_thrust_source_code()
set(AER_COMPILER_DEFINITIONS ${AER_COMPILER_DEFINITIONS} THRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_OMP AER_THRUST_CPU=TRUE)
set(AER_SIMULATOR_CPP_EXTERNAL_LIBS ${AER_SIMULATOR_CPP_EXTERNAL_LIBS} ${CONAN_INCLUDE_DIRS_THRUST})
set(AER_COMPILER_DEFINITIONS ${AER_COMPILER_DEFINITIONS} AER_THRUST_CPU=TRUE)
# We don't need to add OMP because it's already an AER dependency
set(THRUST_DEPENDANT_LIBS "")
else()
@ -254,21 +212,20 @@ else()
endif()
# Set dependent libraries
set(AER_LIBRARIES
${OPENMP_EXTERNAL_LIB}
${AER_LIBRARIES}
${BLAS_LIBRARIES}
nlohmann_json
CONAN_PKG::nlohmann_json
Threads::Threads
${SPDLOG_LIB}
CONAN_PKG::spdlog
${DL_LIB}
${THRUST_DEPENDANT_LIBS})
set(AER_COMPILER_DEFINITIONS ${AER_COMPILER_DEFINITIONS} ${CONAN_DEFINES})
# Cython build is only enabled if building through scikit-build.
if(SKBUILD) # Terra Addon build
add_muparserx_lib()
set(AER_LIBRARIES ${AER_LIBRARIES} CONAN_PKG::muparserx)
add_subdirectory(qiskit/providers/aer/pulse/qutip_extra_lite/cy)
add_subdirectory(qiskit/providers/aer/backends/wrappers)
add_subdirectory(src/open_pulse)

View File

@ -253,6 +253,15 @@ Most of the required dependencies can be installed via *pip*, using the
$ cd qiskit-aer
$ pip install -r requirements-dev.txt
This will also install [**Conan**](https://conan.io/), a C/C++ package manager written in Python. This tool will handle
most of the dependencies needed by the C++ source code. Internet connection may be needed for the first build or
when dependencies are added/updated, in order to download the required packages if they are not in your **Conan** local
repository.
If we are only building the standalone version and do not want to install all Python requirements you can just install
**Conan**:
$ pip install conan
### Linux
@ -272,23 +281,6 @@ Ubuntu
$ sudo apt install build-essential
Although the *BLAS* and *LAPACK* library implementations included in the
*build-essential* package are sufficient to build all of the `Aer` simulators, we
recommend using *OpenBLAS*, which you can install by running
CentOS/Red Hat
$ yum install openblas-devel
Fedora
$ dnf install openblas-devel
Ubuntu
$ sudo apt install libopenblas-dev
And of course, `git` is required in order to build from repositories
CentOS/Red Hat
@ -318,9 +310,7 @@ As any other python package, we can install from source code by just running:
This will build and install `Aer` with the default options which is probably suitable for most of the users.
There's another pythonic approach to build and install software: build the wheels distributable file.
qiskit-aer$ python ./setup.py bdist_wheel
qiskit-aer$ python ./setup.py bdist_wheel
This is also the way we will choose to change default `Aer` behavior by passing parameters to the build system.
@ -370,7 +360,7 @@ option):
qiskit-aer/out$ cd Release
qiskit-aer/out/Release/$ ls
aer_simulator_cpp
qasm_simulator
**Advanced options**
@ -391,13 +381,6 @@ otherwise. To install it manually, in a terminal window, run:
$ brew install libomp
We recommend installing *OpenBLAS*, which is our default choice:
$ brew install openblas
The *CMake* build system will search for other *BLAS* implementation
alternatives if *OpenBLAS* is not installed in the system.
You further need to have *Xcode Command Line Tools* installed on macOS:
$ xcode-select --install
@ -466,7 +449,7 @@ option):
qiskit-aer/out$ cd Release
qiskit-aer/out/Release/$ ls
aer_simulator_cpp
qasm_simulator
***Advanced options***
@ -561,7 +544,7 @@ option):
(QiskitDevEnv) qiskit-aer\out> cd Release
(QiskitDevEnv) qiskit-aer\out\Release> dir
aer_simulator_cpp
qasm_simulator
***Advanced options***

View File

@ -41,7 +41,7 @@ stages:
source activate qiskit-aer-$version
conda update --yes -n base conda
conda config --add channels conda-forge
conda install --yes --quiet --name qiskit-aer-$version python=$version numpy cmake openblas virtualenv pip setuptools pybind11 cython
conda install --yes --quiet --name qiskit-aer-$version python=$version numpy cmake virtualenv pip setuptools pybind11 cython
python setup.py bdist_wheel -- -G "Visual Studio 15 2017 Win64"
virtualenv test-$version
test-$version/Scripts/pip install dist/*whl
@ -94,7 +94,7 @@ stages:
source activate qiskit-aer
conda update --yes -n base conda
conda config --add channels conda-forge
conda install --yes --quiet --name qiskit-aer python=$(python.version) numpy cmake openblas virtualenv pip setuptools pybind11 cython
conda install --yes --quiet --name qiskit-aer python=$(python.version) numpy cmake virtualenv pip setuptools pybind11 cython
displayName: Create Anaconda environments
- bash: |
set -x
@ -133,7 +133,7 @@ stages:
source activate qiskit-aer
conda update --yes -n base conda
conda config --add channels conda-forge
conda install --yes --quiet --name qiskit-aer python=$(python.version) numpy cmake openblas virtualenv pip setuptools pybind11 cython
conda install --yes --quiet --name qiskit-aer python=$(python.version) numpy cmake virtualenv pip setuptools pybind11 cython
displayName: Create Anaconda environments
- bash: |
set -x
@ -166,7 +166,7 @@ stages:
source activate qiskit-aer
conda update --yes -n base conda
conda config --add channels conda-forge
conda install --yes --quiet --name qiskit-aer numpy cmake
conda install --yes --quiet --name qiskit-aer conan numpy cmake
displayName: Create Anaconda environments
- bash: |
set -x
@ -200,7 +200,7 @@ stages:
python -m pip install --upgrade pip virtualenv
pip install -U tox
sudo apt-get update
sudo apt-get install -y build-essential libopenblas-dev
sudo apt-get install -y build-essential
displayName: 'Install dependencies'
- bash: |
tox -edocs
@ -250,7 +250,7 @@ stages:
set -e
source activate qiskit-aer-$(Build.BuildNumber)
conda install --yes --quiet --name qiskit-aer-$(Build.BuildNumber) python=$(python.version) mkl
conda install -c conda-forge --yes --quiet --name qiskit-aer-$(Build.BuildNumber) python=$(python.version) openblas pip setuptools
conda install -c conda-forge --yes --quiet --name qiskit-aer-$(Build.BuildNumber) python=$(python.version) pip setuptools
displayName: Install Anaconda packages
condition: or(eq(variables['python.version'], '3.5'), eq(variables['python.version'], '3.8'))
- bash: |

View File

@ -1,10 +0,0 @@
find_package(Catch2 CONFIG QUIET)
if(NOT Catch2_FOUND)
message("Catch2_PATH is ${Catch2_PATH}")
find_path(CATCH2_INCLUDE_DIR catch.hpp PATH ${Catch2_PATH})
message("Catch2 include dir: ${CATCH2_INCLUDE_DIR}")
add_library(Catch2::Catch INTERFACE IMPORTED)
set_target_properties(Catch2::Catch PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CATCH2_INCLUDE_DIR})
endif()

View File

@ -1,47 +0,0 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
#.rst:
# FindMuparserx
# =============
# This module finds a muparserx library installed in the system (see https://beltoforion.de/article.php?a=muparserx
# and https://github.com/beltoforion/muparserx).
#
# This module defines the following target:
#
# ::
#
# PkgConfig::muparserx
#
# and sets the typical package variables:
#
# ::
#
# muparserx_FOUND
# muparserx_INCLUDE_DIRS
# muparserx_LIBRARIES
# muparserx_VERSION
# ....
#
find_package(PkgConfig QUIET)
pkg_check_modules(muparserx QUIET IMPORTED_TARGET muparserx)
if(NOT muparserx_FIND_QUIETLY)
if(NOT muparserx_FOUND)
message(FATAL_ERROR "muparserx library not found!")
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(muparserx REQUIRED_VARS muparserx_INCLUDE_DIRS muparserx_LIBRARIES
VERSION_VAR muparserx_VERSION)

View File

@ -1,165 +0,0 @@
#-------------------------------------------------------------------
# This file is part of the CMake build system for OGRE
# (Object-oriented Graphics Rendering Engine)
# For the latest info, see http://www.ogre3d.org/
#
# The contents of this file are placed in the public domain. Feel
# free to make use of it in any way you like.
#-------------------------------------------------------------------
##################################################################
# Provides some common functionality for the FindPackage modules
##################################################################
# Begin processing of package
macro(findpkg_begin PREFIX)
if (NOT ${PREFIX}_FIND_QUIETLY)
message(STATUS "Looking for ${PREFIX}...")
endif ()
endmacro(findpkg_begin)
# Display a status message unless FIND_QUIETLY is set
macro(pkg_message PREFIX)
if (NOT ${PREFIX}_FIND_QUIETLY)
message(STATUS ${ARGN})
endif ()
endmacro(pkg_message)
# Get environment variable, define it as ENV_$var and make sure backslashes are converted to forward slashes
macro(getenv_path VAR)
set(ENV_${VAR} $ENV{${VAR}})
# replace won't work if var is blank
if (ENV_${VAR})
string( REGEX REPLACE "\\\\" "/" ENV_${VAR} ${ENV_${VAR}} )
endif ()
endmacro(getenv_path)
# Construct search paths for includes and libraries from a PREFIX_PATH
macro(create_search_paths PREFIX)
foreach(dir ${${PREFIX}_PREFIX_PATH})
set(${PREFIX}_INC_SEARCH_PATH ${${PREFIX}_INC_SEARCH_PATH}
${dir}/include ${dir}/Include ${dir}/include/${PREFIX} ${dir}/Headers)
set(${PREFIX}_LIB_SEARCH_PATH ${${PREFIX}_LIB_SEARCH_PATH}
${dir}/lib ${dir}/Lib ${dir}/lib/${PREFIX} ${dir}/Libs)
set(${PREFIX}_BIN_SEARCH_PATH ${${PREFIX}_BIN_SEARCH_PATH}
${dir}/bin)
endforeach(dir)
if(ANDROID)
set(${PREFIX}_LIB_SEARCH_PATH ${${PREFIX}_LIB_SEARCH_PATH} ${OGRE_DEPENDENCIES_DIR}/lib/${ANDROID_ABI})
endif()
set(${PREFIX}_FRAMEWORK_SEARCH_PATH ${${PREFIX}_PREFIX_PATH})
endmacro(create_search_paths)
# clear cache variables if a certain variable changed
macro(clear_if_changed TESTVAR)
# test against internal check variable
# HACK: Apparently, adding a variable to the cache cleans up the list
# a bit. We need to also remove any empty strings from the list, but
# at the same time ensure that we are actually dealing with a list.
list(APPEND ${TESTVAR} "")
list(REMOVE_ITEM ${TESTVAR} "")
if (NOT "${${TESTVAR}}" STREQUAL "${${TESTVAR}_INT_CHECK}")
message(STATUS "${TESTVAR} changed.")
foreach(var ${ARGN})
set(${var} "NOTFOUND" CACHE STRING "x" FORCE)
endforeach(var)
endif ()
set(${TESTVAR}_INT_CHECK ${${TESTVAR}} CACHE INTERNAL "x" FORCE)
endmacro(clear_if_changed)
# Try to get some hints from pkg-config, if available
macro(use_pkgconfig PREFIX PKGNAME)
if(NOT ANDROID)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(${PREFIX} ${PKGNAME})
endif ()
endif()
endmacro (use_pkgconfig)
# Couple a set of release AND debug libraries (or frameworks)
macro(make_library_set PREFIX)
if (${PREFIX}_FWK)
set(${PREFIX} ${${PREFIX}_FWK})
elseif (${PREFIX}_REL AND ${PREFIX}_DBG)
set(${PREFIX} optimized ${${PREFIX}_REL} debug ${${PREFIX}_DBG})
elseif (${PREFIX}_REL)
set(${PREFIX} ${${PREFIX}_REL})
elseif (${PREFIX}_DBG)
set(${PREFIX} ${${PREFIX}_DBG})
endif ()
endmacro(make_library_set)
# Generate debug names from given release names
macro(get_debug_names PREFIX)
foreach(i ${${PREFIX}})
set(${PREFIX}_DBG ${${PREFIX}_DBG} ${i}d ${i}D ${i}_d ${i}_D ${i}_debug)
endforeach(i)
endmacro(get_debug_names)
# Add the parent dir from DIR to VAR
macro(add_parent_dir VAR DIR)
get_filename_component(${DIR}_TEMP "${${DIR}}/.." ABSOLUTE)
set(${VAR} ${${VAR}} ${${DIR}_TEMP})
endmacro(add_parent_dir)
# Do the final processing for the package find.
macro(findpkg_finish PREFIX)
# skip if already processed during this run
if (NOT ${PREFIX}_FOUND)
if (${PREFIX}_INCLUDE_DIR AND ${PREFIX}_LIBRARY)
set(${PREFIX}_FOUND TRUE)
set(${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIR})
set(${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARY})
if (NOT ${PREFIX}_FIND_QUIETLY)
message(STATUS "Found ${PREFIX}: ${${PREFIX}_LIBRARIES}")
endif ()
else ()
if (NOT ${PREFIX}_FIND_QUIETLY)
message(STATUS "Could not locate ${PREFIX}")
endif ()
if (${PREFIX}_FIND_REQUIRED)
message(FATAL_ERROR "Required library ${PREFIX} not found! Install the library (including dev packages) and try again. If the library is already installed, set the missing variables manually in cmake.")
endif ()
endif ()
mark_as_advanced(${PREFIX}_INCLUDE_DIR ${PREFIX}_LIBRARY ${PREFIX}_LIBRARY_REL ${PREFIX}_LIBRARY_DBG ${PREFIX}_LIBRARY_FWK)
endif ()
endmacro(findpkg_finish)
# Slightly customised framework finder
macro(findpkg_framework fwk)
if(APPLE)
set(${fwk}_FRAMEWORK_PATH
${${fwk}_FRAMEWORK_SEARCH_PATH}
${CMAKE_FRAMEWORK_PATH}
~/Library/Frameworks
/Library/Frameworks
/System/Library/Frameworks
/Network/Library/Frameworks
${CMAKE_CURRENT_SOURCE_DIR}/lib/macosx/Release
${CMAKE_CURRENT_SOURCE_DIR}/lib/macosx/Debug
)
# These could be arrays of paths, add each individually to the search paths
foreach(i ${OGRE_PREFIX_PATH})
set(${fwk}_FRAMEWORK_PATH ${${fwk}_FRAMEWORK_PATH} ${i}/lib/macosx/Release ${i}/lib/macosx/Debug)
endforeach(i)
foreach(i ${OGRE_PREFIX_BUILD})
set(${fwk}_FRAMEWORK_PATH ${${fwk}_FRAMEWORK_PATH} ${i}/lib/macosx/Release ${i}/lib/macosx/Debug)
endforeach(i)
foreach(dir ${${fwk}_FRAMEWORK_PATH})
set(fwkpath ${dir}/${fwk}.framework)
if(EXISTS ${fwkpath})
set(${fwk}_FRAMEWORK_INCLUDES ${${fwk}_FRAMEWORK_INCLUDES}
${fwkpath}/Headers ${fwkpath}/PrivateHeaders)
set(${fwk}_FRAMEWORK_PATH ${dir})
if (NOT ${fwk}_LIBRARY_FWK)
set(${fwk}_LIBRARY_FWK "-framework ${fwk}")
endif ()
endif(EXISTS ${fwkpath})
endforeach(dir)
endif(APPLE)
endmacro(findpkg_framework)

View File

@ -1,134 +0,0 @@
#-------------------------------------------------------------------
# This file is part of the CMake build system for OGRE
# (Object-oriented Graphics Rendering Engine)
# For the latest info, see http://www.ogre3d.org/
#
# The contents of this file are placed in the public domain. Feel
# free to make use of it in any way you like.
#-------------------------------------------------------------------
# - Try to find ThreadingBuildingBlocks libraries
# Once done, this will define
#
# TBB_FOUND - system has TBB
# TBB_INCLUDE_DIRS - the TBB include directories
# TBB_LIBRARIES - link these to use TBB
include(FindPkgMacros)
findpkg_begin(TBB)
# Get path, convert backslashes as ${ENV_${var}}
getenv_path(TBB_HOME)
getenv_path(TBB_ROOT)
getenv_path(TBB_BASE)
# construct search paths
set(TBB_PREFIX_PATH
${TBB_HOME} ${ENV_TBB_HOME}
${TBB_ROOT} ${ENV_TBB_ROOT}
${TBB_BASE} ${ENV_TBB_BASE}
)
# redo search if prefix path changed
clear_if_changed(TBB_PREFIX_PATH
TBB_LIBRARY_FWK
TBB_LIBRARY_REL
TBB_LIBRARY_DBG
TBB_INCLUDE_DIR
)
create_search_paths(TBB)
set(TBB_INC_SEARCH_PATH ${TBB_INC_SEARCH_PATH} ${TBB_PREFIX_PATH})
# For Windows, let's assume that the user might be using the precompiled
# TBB packages from the main website. These use a rather awkward directory
# structure (at least for automatically finding the right files) depending
# on platform and compiler, but we'll do our best to accommodate it.
# Not adding the same effort for the precompiled linux builds, though. Those
# have different versions for CC compiler versions and linux kernels which
# will never adequately match the user's setup, so there is no feasible way
# to detect the "best" version to use. The user will have to manually
# select the right files. (Chances are the distributions are shipping their
# custom version of tbb, anyway, so the problem is probably nonexistant.)
if (WIN32 AND MSVC)
set(COMPILER_PREFIX "vc7.1")
if (MSVC_VERSION EQUAL 1400)
set(COMPILER_PREFIX "vc8")
endif ()
if (MSVC_VERSION EQUAL 1500)
set(COMPILER_PREFIX "vc9")
endif ()
if (MSVC_VERSION EQUAL 1600)
set(COMPILER_PREFIX "vc10")
endif ()
if (MSVC_VERSION EQUAL 1700)
set(COMPILER_PREFIX "vc11")
endif ()
if (MSVC_VERSION EQUAL 1800)
set(COMPILER_PREFIX "vc12")
endif ()
if (MSVC_VERSION EQUAL 1900)
set(COMPILER_PREFIX "vc13")
endif ()
if (MSVC_VERSION EQUAL 1911)
set(COMPILER_PREFIX "vc14")
endif ()
# for each prefix path, add ia32/64\${COMPILER_PREFIX}\lib to the lib search path
foreach (dir ${TBB_PREFIX_PATH})
if (CMAKE_CL_64)
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/ia64/${COMPILER_PREFIX}/lib)
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/ia64/${COMPILER_PREFIX})
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/intel64/${COMPILER_PREFIX}/lib)
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/intel64/${COMPILER_PREFIX})
else ()
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/ia32/${COMPILER_PREFIX}/lib)
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/ia32/${COMPILER_PREFIX})
endif ()
endforeach ()
endif ()
foreach (dir ${TBB_PREFIX_PATH})
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/$ENV{TBB_ARCH_PLATFORM}/lib)
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/$ENV{TBB_ARCH_PLATFORM})
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib)
endforeach ()
set(TBB_LIBRARY_NAMES tbb)
get_debug_names(TBB_LIBRARY_NAMES)
# use_pkgconfig(TBB_PKGC TBB)
findpkg_framework(TBB)
find_path(TBB_INCLUDE_DIR NAMES tbb/tbb.h HINTS ${TBB_INC_SEARCH_PATH} ${TBB_PKGC_INCLUDE_DIRS})
find_library(TBB_LIBRARY_REL NAMES ${TBB_LIBRARY_NAMES} HINTS ${TBB_LIB_SEARCH_PATH} ${TBB_PKGC_LIBRARY_DIRS})
find_library(TBB_LIBRARY_DBG NAMES ${TBB_LIBRARY_NAMES_DBG} HINTS ${TBB_LIB_SEARCH_PATH} ${TBB_PKGC_LIBRARY_DIRS})
make_library_set(TBB_LIBRARY)
findpkg_finish(TBB)
if (NOT TBB_FOUND)
return()
endif ()
# Look for TBB's malloc package
findpkg_begin(TBB_MALLOC)
set(TBB_MALLOC_LIBRARY_NAMES tbbmalloc)
get_debug_names(TBB_MALLOC_LIBRARY_NAMES)
find_path(TBB_MALLOC_INCLUDE_DIR NAMES tbb/tbb.h HINTS ${TBB_INCLUDE_DIR} ${TBB_INC_SEARCH_PATH} ${TBB_PKGC_INCLUDE_DIRS} )
find_library(TBB_MALLOC_LIBRARY_REL NAMES ${TBB_MALLOC_LIBRARY_NAMES} HINTS ${TBB_LIB_SEARCH_PATH} ${TBB_PKGC_LIBRARY_DIRS} )
find_library(TBB_MALLOC_LIBRARY_DBG NAMES ${TBB_MALLOC_LIBRARY_NAMES_DBG} HINTS ${TBB_LIB_SEARCH_PATH} ${TBB_PKGC_LIBRARY_DIRS} )
make_library_set(TBB_MALLOC_LIBRARY)
findpkg_finish(TBB_MALLOC)
# Look for TBB's malloc proxy package
findpkg_begin(TBB_MALLOC_PROXY)
set(TBB_MALLOC_PROXY_LIBRARY_NAMES tbbmalloc_proxy)
get_debug_names(TBB_MALLOC_PROXY_LIBRARY_NAMES)
find_path(TBB_MALLOC_PROXY_INCLUDE_DIR NAMES tbb/tbbmalloc_proxy.h HINTS ${TBB_INCLUDE_DIR} ${TBB_INC_SEARCH_PATH} ${TBB_PKGC_INCLUDE_DIRS})
find_library(TBB_MALLOC_PROXY_LIBRARY_REL NAMES ${TBB_MALLOC_PROXY_LIBRARY_NAMES} HINTS ${TBB_LIB_SEARCH_PATH} ${TBB_PKGC_LIBRARY_DIRS})
find_library(TBB_MALLOC_PROXY_LIBRARY_DBG NAMES ${TBB_MALLOC_PROXY_LIBRARY_NAMES_DBG} HINTS ${TBB_LIB_SEARCH_PATH} ${TBB_PKGC_LIBRARY_DIRS})
make_library_set(TBB_MALLOC_PROXY_LIBRARY)
findpkg_finish(TBB_MALLOC_PROXY)

View File

@ -1,9 +0,0 @@
find_package(nlohmann_json CONFIG QUIET)
if(NOT nlohmann_json_FOUND)
#message(STATUS "NLOHMANN_JSON_PATH is ${NLOHMANN_JSON_PATH}")
find_path(NLOHMANN_INCLUDE_DIR nlohmann_json.hpp PATH ${NLOHMANN_JSON_PATH})
message(STATUS "nlohmann include dir: ${NLOHMANN_INCLUDE_DIR}")
add_library(nlohmann_json INTERFACE IMPORTED)
set_target_properties(nlohmann_json PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${NLOHMANN_INCLUDE_DIR})
endif()

View File

@ -32,142 +32,3 @@ function(get_version version_str)
set(MINOR_VERSION ${TMP_MINOR_VERSION} PARENT_SCOPE)
set(PATCH_VERSION ${TMP_PATCH_VERSION} PARENT_SCOPE)
endfunction()
function(is_dir_empty dir)
file(GLOB RESULT ${dir}/*)
list(LENGTH RESULT num_files)
if(num_files EQUAL 0)
set(dir_is_empty TRUE PARENT_SCOPE)
else()
set(dir_is_empty FALSE PARENT_SCOPE)
endif()
endfunction()
function(_get_library_source_code library repo_url version proof_of_existance)
is_dir_empty(${PROJECT_SOURCE_DIR}/src/third-party/headers/${library})
if(dir_is_empty)
find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
# if we have cloned the sources, the library is a submodule, so we need
# to initialize it
if(EXISTS "${PROJECT_SOURCE_DIR}/.gitmodules")
# Update library submodule as needed
message(STATUS "Submodule update")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive src/third-party/headers/${library}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init --recursive src/third-party/headers/${library} \
failed with ${GIT_SUBMOD_RESULT}, please checkout submodule ${library}")
endif()
else()
message(WARNING "Git checkout but ${PROJECT_SOURCE_DIR}/.gitmodules file not found!")
endif()
# Not comming from git, so probably: pip install https://...zip or similar.
# This time, we want to clone the library and change the latests stable release
elseif(GIT_FOUND)
execute_process(COMMAND ${GIT_EXECUTABLE} clone --branch ${version} ${repo_url} ${PROJECT_SOURCE_DIR}/src/third-party/headers/${library}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "git clone failed with ${GIT_SUBMOD_RESULT},\
please checkout ${library} manually from ${repo_url} and \
checkout latest stable relase")
endif()
# TODO: If there's no git, we have to get the library using other method (curl)
endif()
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/src/third-party/headers/${proof_of_existance}")
message(FATAL_ERROR "${library} doesn't exist! GIT_SUBMODULE was turned off or download failed.\
Please download ${library} library from ${repo_url} \
and checkout latest stable release")
endif()
else()
message(STATUS "${library} library source code already exists")
endif()
# TODO: We should be adding included directories to targets, and not globally
include_directories(SYSTEM ${PROJECT_SOURCE_DIR}/src/third-party/headers/${library})
endfunction()
function(get_muparserx_source_code)
_get_library_source_code(
muparserx
https://github.com/beltoforion/muparserx.git
v4.0.8
muparserx/CMakeLists.txt
)
endfunction()
function(get_thrust_source_code)
_get_library_source_code(
thrust
https://github.com/thrust/thrust.git
1.9.5
thrust/thrust/version.h
)
endfunction()
function(check_compiler_cpp11_abi)
# This is needed in case the compiler doesn't work with the new C++11 ABI,
# is the case of GCC in RHEL6 and RHEL7
# https://bugzilla.redhat.com/show_bug.cgi?id=1546704
# Consider also if -D_GLIBCXX_USE_CXX11_ABI has been passed as flag
string(REGEX MATCH "-D_GLIBCXX_USE_CXX11_ABI=[(A-z)|(a-z)|(0-9)]+" CUSTOM_PREP_FLAGS ${CMAKE_CXX_FLAGS})
# Preprocessor run to check if CXX11_ABI is set
execute_process(COMMAND echo "#include <string>" COMMAND ${CMAKE_CXX_COMPILER} ${CUSTOM_PREP_FLAGS} -x c++ -E -dM - COMMAND fgrep _GLIBCXX_USE_CXX11_ABI OUTPUT_VARIABLE CXX11_ABI_OUT OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REGEX REPLACE "#define _GLIBCXX_USE_CXX11_ABI " "" CXX11_ABI "${CXX11_ABI_OUT}")
set(CXX11_ABI ${CXX11_ABI} PARENT_SCOPE)
endfunction()
function(uncompress_muparsersx_lib)
if(MSVC)
set(PLATFORM "win64")
elseif(APPLE)
set(PLATFORM "macos")
elseif(UNIX)
check_compiler_cpp11_abi()
if(CXX11_ABI EQUAL "0")
set(MUPARSER_ABI_PREFIX oldabi_)
endif()
if(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64le")
set(MUPARSER_ARCH_POSTFIX ".ppc64le")
endif()
# Raspberry Pi (4)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "armv7l")
set(MUPARSER_ARCH_POSTFIX ".armv7l")
endif()
set(PLATFORM "linux")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} -E tar "xvfj" "${AER_SIMULATOR_CPP_SRC_DIR}/third-party/${PLATFORM}/lib/${MUPARSER_ABI_PREFIX}muparserx${MUPARSER_ARCH_POSTFIX}.7z"
WORKING_DIRECTORY "${AER_SIMULATOR_CPP_SRC_DIR}/third-party/${PLATFORM}/lib/")
set(MUPARSERX_LIB_PATH "${AER_SIMULATOR_CPP_SRC_DIR}/third-party/${PLATFORM}/lib" PARENT_SCOPE)
endfunction()
function(add_muparserx_lib)
message(STATUS "Looking for muparserx library...")
# Look first for already installed muparserx
find_package(muparserx QUIET)
if(muparserx_FOUND)
message(STATUS "Muparserx library version '${muparserx_VERSION}' found")
set(AER_LIBRARIES ${AER_LIBRARIES} PkgConfig::muparserx PARENT_SCOPE)
return()
endif()
message(STATUS "Muparserx library not found. Uncompressing muparserx static library...")
uncompress_muparsersx_lib()
find_library(MUPARSERX_LIB NAMES libmuparserx.a muparserx HINTS ${MUPARSERX_LIB_PATH})
if(${MUPARSERX_LIB} MATCHES "MUPARSERX_LIB-NOTFOUND")
message(FATAL_ERROR "No muparserx library found")
endif()
message(STATUS "Muparserx library found: ${MUPARSERX_LIB}")
get_muparserx_source_code()
# I keep this disabled on purpose, just in case I need to debug muparserx related problems
# file(GLOB MUPARSERX_SOURCES "${AER_SIMULATOR_CPP_SRC_DIR}/third-party/headers/muparserx/parser/*.cpp")
set(AER_LIBRARIES ${AER_LIBRARIES} ${MUPARSERX_LIB} PARENT_SCOPE)
endfunction()

610
cmake/conan.cmake Normal file
View File

@ -0,0 +1,610 @@
# The MIT License (MIT)
# Copyright (c) 2018 JFrog
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# This file comes from: https://github.com/conan-io/cmake-conan. Please refer
# to this repository for issues and documentation.
# Its purpose is to wrap and launch Conan C/C++ Package Manager when cmake is called.
# It will take CMake current settings (os, compiler, compiler version, architecture)
# and translate them to conan settings for installing and retrieving dependencies.
# It is intended to facilitate developers building projects that have conan dependencies,
# but it is only necessary on the end-user side. It is not necessary to create conan
# packages, in fact it shouldn't be use for that. Check the project documentation.
# version: 0.15.0
include(CMakeParseArguments)
function(_get_msvc_ide_version result)
set(${result} "" PARENT_SCOPE)
if(NOT MSVC_VERSION VERSION_LESS 1400 AND MSVC_VERSION VERSION_LESS 1500)
set(${result} 8 PARENT_SCOPE)
elseif(NOT MSVC_VERSION VERSION_LESS 1500 AND MSVC_VERSION VERSION_LESS 1600)
set(${result} 9 PARENT_SCOPE)
elseif(NOT MSVC_VERSION VERSION_LESS 1600 AND MSVC_VERSION VERSION_LESS 1700)
set(${result} 10 PARENT_SCOPE)
elseif(NOT MSVC_VERSION VERSION_LESS 1700 AND MSVC_VERSION VERSION_LESS 1800)
set(${result} 11 PARENT_SCOPE)
elseif(NOT MSVC_VERSION VERSION_LESS 1800 AND MSVC_VERSION VERSION_LESS 1900)
set(${result} 12 PARENT_SCOPE)
elseif(NOT MSVC_VERSION VERSION_LESS 1900 AND MSVC_VERSION VERSION_LESS 1910)
set(${result} 14 PARENT_SCOPE)
elseif(NOT MSVC_VERSION VERSION_LESS 1910 AND MSVC_VERSION VERSION_LESS 1920)
set(${result} 15 PARENT_SCOPE)
elseif(NOT MSVC_VERSION VERSION_LESS 1920 AND MSVC_VERSION VERSION_LESS 1930)
set(${result} 16 PARENT_SCOPE)
else()
message(FATAL_ERROR "Conan: Unknown MSVC compiler version [${MSVC_VERSION}]")
endif()
endfunction()
function(conan_cmake_settings result)
#message(STATUS "COMPILER " ${CMAKE_CXX_COMPILER})
#message(STATUS "COMPILER " ${CMAKE_CXX_COMPILER_ID})
#message(STATUS "VERSION " ${CMAKE_CXX_COMPILER_VERSION})
#message(STATUS "FLAGS " ${CMAKE_LANG_FLAGS})
#message(STATUS "LIB ARCH " ${CMAKE_CXX_LIBRARY_ARCHITECTURE})
#message(STATUS "BUILD TYPE " ${CMAKE_BUILD_TYPE})
#message(STATUS "GENERATOR " ${CMAKE_GENERATOR})
#message(STATUS "GENERATOR WIN64 " ${CMAKE_CL_64})
message(STATUS "Conan: Automatic detection of conan settings from cmake")
parse_arguments(${ARGV})
if(ARGUMENTS_BUILD_TYPE)
set(_CONAN_SETTING_BUILD_TYPE ${ARGUMENTS_BUILD_TYPE})
elseif(CMAKE_BUILD_TYPE)
set(_CONAN_SETTING_BUILD_TYPE ${CMAKE_BUILD_TYPE})
else()
message(FATAL_ERROR "Please specify in command line CMAKE_BUILD_TYPE (-DCMAKE_BUILD_TYPE=Release)")
endif()
string(TOUPPER ${_CONAN_SETTING_BUILD_TYPE} _CONAN_SETTING_BUILD_TYPE_UPPER)
if (_CONAN_SETTING_BUILD_TYPE_UPPER STREQUAL "DEBUG")
set(_CONAN_SETTING_BUILD_TYPE "Debug")
elseif(_CONAN_SETTING_BUILD_TYPE_UPPER STREQUAL "RELEASE")
set(_CONAN_SETTING_BUILD_TYPE "Release")
elseif(_CONAN_SETTING_BUILD_TYPE_UPPER STREQUAL "RELWITHDEBINFO")
set(_CONAN_SETTING_BUILD_TYPE "RelWithDebInfo")
elseif(_CONAN_SETTING_BUILD_TYPE_UPPER STREQUAL "MINSIZEREL")
set(_CONAN_SETTING_BUILD_TYPE "MinSizeRel")
endif()
if(ARGUMENTS_ARCH)
set(_CONAN_SETTING_ARCH ${ARGUMENTS_ARCH})
endif()
#handle -s os setting
if(CMAKE_SYSTEM_NAME)
#use default conan os setting if CMAKE_SYSTEM_NAME is not defined
set(CONAN_SYSTEM_NAME ${CMAKE_SYSTEM_NAME})
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
set(CONAN_SYSTEM_NAME Macos)
endif()
set(CONAN_SUPPORTED_PLATFORMS Windows Linux Macos Android iOS FreeBSD WindowsStore)
list (FIND CONAN_SUPPORTED_PLATFORMS "${CONAN_SYSTEM_NAME}" _index)
if (${_index} GREATER -1)
#check if the cmake system is a conan supported one
set(_CONAN_SETTING_OS ${CONAN_SYSTEM_NAME})
else()
message(FATAL_ERROR "cmake system ${CONAN_SYSTEM_NAME} is not supported by conan. Use one of ${CONAN_SUPPORTED_PLATFORMS}")
endif()
endif()
get_property(_languages GLOBAL PROPERTY ENABLED_LANGUAGES)
if (";${_languages};" MATCHES ";CXX;")
set(LANGUAGE CXX)
set(USING_CXX 1)
elseif (";${_languages};" MATCHES ";C;")
set(LANGUAGE C)
set(USING_CXX 0)
else ()
message(FATAL_ERROR "Conan: Neither C or C++ was detected as a language for the project. Unabled to detect compiler version.")
endif()
if (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL GNU)
# using GCC
# TODO: Handle other params
string(REPLACE "." ";" VERSION_LIST ${CMAKE_${LANGUAGE}_COMPILER_VERSION})
list(GET VERSION_LIST 0 MAJOR)
list(GET VERSION_LIST 1 MINOR)
set(COMPILER_VERSION ${MAJOR}.${MINOR})
if(${MAJOR} GREATER 4)
set(COMPILER_VERSION ${MAJOR})
endif()
set(_CONAN_SETTING_COMPILER gcc)
set(_CONAN_SETTING_COMPILER_VERSION ${COMPILER_VERSION})
if (USING_CXX)
conan_cmake_detect_unix_libcxx(_LIBCXX)
set(_CONAN_SETTING_COMPILER_LIBCXX ${_LIBCXX})
endif ()
elseif (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL AppleClang)
# using AppleClang
string(REPLACE "." ";" VERSION_LIST ${CMAKE_${LANGUAGE}_COMPILER_VERSION})
list(GET VERSION_LIST 0 MAJOR)
list(GET VERSION_LIST 1 MINOR)
set(_CONAN_SETTING_COMPILER apple-clang)
set(_CONAN_SETTING_COMPILER_VERSION ${MAJOR}.${MINOR})
if (USING_CXX)
conan_cmake_detect_unix_libcxx(_LIBCXX)
set(_CONAN_SETTING_COMPILER_LIBCXX ${_LIBCXX})
endif ()
elseif (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL Clang)
string(REPLACE "." ";" VERSION_LIST ${CMAKE_${LANGUAGE}_COMPILER_VERSION})
list(GET VERSION_LIST 0 MAJOR)
list(GET VERSION_LIST 1 MINOR)
set(_CONAN_SETTING_COMPILER clang)
set(_CONAN_SETTING_COMPILER_VERSION ${MAJOR}.${MINOR})
if(APPLE)
cmake_policy(GET CMP0025 APPLE_CLANG_POLICY)
if(NOT APPLE_CLANG_POLICY STREQUAL NEW)
message(STATUS "Conan: APPLE and Clang detected. Assuming apple-clang compiler. Set CMP0025 to avoid it")
set(_CONAN_SETTING_COMPILER apple-clang)
endif()
endif()
if(${_CONAN_SETTING_COMPILER} STREQUAL clang AND ${MAJOR} GREATER 7)
set(_CONAN_SETTING_COMPILER_VERSION ${MAJOR})
endif()
if (USING_CXX)
conan_cmake_detect_unix_libcxx(_LIBCXX)
set(_CONAN_SETTING_COMPILER_LIBCXX ${_LIBCXX})
endif ()
elseif(${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL MSVC)
set(_VISUAL "Visual Studio")
_get_msvc_ide_version(_VISUAL_VERSION)
if("${_VISUAL_VERSION}" STREQUAL "")
message(FATAL_ERROR "Conan: Visual Studio not recognized")
else()
set(_CONAN_SETTING_COMPILER ${_VISUAL})
set(_CONAN_SETTING_COMPILER_VERSION ${_VISUAL_VERSION})
endif()
if(NOT _CONAN_SETTING_ARCH)
if (MSVC_${LANGUAGE}_ARCHITECTURE_ID MATCHES "64")
set(_CONAN_SETTING_ARCH x86_64)
elseif (MSVC_${LANGUAGE}_ARCHITECTURE_ID MATCHES "^ARM")
message(STATUS "Conan: Using default ARM architecture from MSVC")
set(_CONAN_SETTING_ARCH armv6)
elseif (MSVC_${LANGUAGE}_ARCHITECTURE_ID MATCHES "86")
set(_CONAN_SETTING_ARCH x86)
else ()
message(FATAL_ERROR "Conan: Unknown MSVC architecture [${MSVC_${LANGUAGE}_ARCHITECTURE_ID}]")
endif()
endif()
conan_cmake_detect_vs_runtime(_vs_runtime)
message(STATUS "Conan: Detected VS runtime: ${_vs_runtime}")
set(_CONAN_SETTING_COMPILER_RUNTIME ${_vs_runtime})
if (CMAKE_GENERATOR_TOOLSET)
set(_CONAN_SETTING_COMPILER_TOOLSET ${CMAKE_VS_PLATFORM_TOOLSET})
elseif(CMAKE_VS_PLATFORM_TOOLSET AND (CMAKE_GENERATOR STREQUAL "Ninja"))
set(_CONAN_SETTING_COMPILER_TOOLSET ${CMAKE_VS_PLATFORM_TOOLSET})
endif()
else()
message(FATAL_ERROR "Conan: compiler setup not recognized")
endif()
# If profile is defined it is used
if(CMAKE_BUILD_TYPE STREQUAL "Debug" AND ARGUMENTS_DEBUG_PROFILE)
set(_APPLIED_PROFILES ${ARGUMENTS_DEBUG_PROFILE})
elseif(CMAKE_BUILD_TYPE STREQUAL "Release" AND ARGUMENTS_RELEASE_PROFILE)
set(_APPLIED_PROFILES ${ARGUMENTS_RELEASE_PROFILE})
elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo" AND ARGUMENTS_RELWITHDEBINFO_PROFILE)
set(_APPLIED_PROFILES ${ARGUMENTS_RELWITHDEBINFO_PROFILE})
elseif(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel" AND ARGUMENTS_MINSIZEREL_PROFILE)
set(_APPLIED_PROFILES ${ARGUMENTS_MINSIZEREL_PROFILE})
elseif(ARGUMENTS_PROFILE)
set(_APPLIED_PROFILES ${ARGUMENTS_PROFILE})
endif()
foreach(ARG ${_APPLIED_PROFILES})
set(_SETTINGS ${_SETTINGS} -pr=${ARG})
endforeach()
if(NOT _SETTINGS OR ARGUMENTS_PROFILE_AUTO STREQUAL "ALL")
set(ARGUMENTS_PROFILE_AUTO arch build_type compiler compiler.version
compiler.runtime compiler.libcxx compiler.toolset)
endif()
# Automatic from CMake
foreach(ARG ${ARGUMENTS_PROFILE_AUTO})
string(TOUPPER ${ARG} _arg_name)
string(REPLACE "." "_" _arg_name ${_arg_name})
if(_CONAN_SETTING_${_arg_name})
set(_SETTINGS ${_SETTINGS} -s ${ARG}=${_CONAN_SETTING_${_arg_name}})
endif()
endforeach()
foreach(ARG ${ARGUMENTS_SETTINGS})
set(_SETTINGS ${_SETTINGS} -s ${ARG})
endforeach()
message(STATUS "Conan: Settings= ${_SETTINGS}")
set(${result} ${_SETTINGS} PARENT_SCOPE)
endfunction()
function(conan_cmake_detect_unix_libcxx result)
# Take into account any -stdlib in compile options
get_directory_property(compile_options DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMPILE_OPTIONS)
# Take into account any _GLIBCXX_USE_CXX11_ABI in compile definitions
get_directory_property(defines DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMPILE_DEFINITIONS)
foreach(define ${defines})
if(define MATCHES "_GLIBCXX_USE_CXX11_ABI")
if(define MATCHES "^-D")
set(compile_options ${compile_options} "${define}")
else()
set(compile_options ${compile_options} "-D${define}")
endif()
endif()
endforeach()
execute_process(
COMMAND ${CMAKE_COMMAND} -E echo "#include <string>"
COMMAND ${CMAKE_CXX_COMPILER} -x c++ ${compile_options} -E -dM -
OUTPUT_VARIABLE string_defines
)
if(string_defines MATCHES "#define __GLIBCXX__")
# Allow -D_GLIBCXX_USE_CXX11_ABI=ON/OFF as argument to cmake
if(DEFINED _GLIBCXX_USE_CXX11_ABI)
if(_GLIBCXX_USE_CXX11_ABI)
set(${result} libstdc++11 PARENT_SCOPE)
return()
else()
set(${result} libstdc++ PARENT_SCOPE)
return()
endif()
endif()
if(string_defines MATCHES "#define _GLIBCXX_USE_CXX11_ABI 1\n")
set(${result} libstdc++11 PARENT_SCOPE)
else()
# Either the compiler is missing the define because it is old, and so
# it can't use the new abi, or the compiler was configured to use the
# old abi by the user or distro (e.g. devtoolset on RHEL/CentOS)
set(${result} libstdc++ PARENT_SCOPE)
endif()
else()
set(${result} libc++ PARENT_SCOPE)
endif()
endfunction()
function(conan_cmake_detect_vs_runtime result)
string(TOUPPER ${CMAKE_BUILD_TYPE} build_type)
set(variables CMAKE_CXX_FLAGS_${build_type} CMAKE_C_FLAGS_${build_type} CMAKE_CXX_FLAGS CMAKE_C_FLAGS)
foreach(variable ${variables})
if(NOT "${${variable}}" STREQUAL "")
string(REPLACE " " ";" flags ${${variable}})
foreach (flag ${flags})
if(${flag} STREQUAL "/MD" OR ${flag} STREQUAL "/MDd" OR ${flag} STREQUAL "/MT" OR ${flag} STREQUAL "/MTd")
string(SUBSTRING ${flag} 1 -1 runtime)
set(${result} ${runtime} PARENT_SCOPE)
return()
endif()
endforeach()
endif()
endforeach()
if(${build_type} STREQUAL "DEBUG")
set(${result} "MDd" PARENT_SCOPE)
else()
set(${result} "MD" PARENT_SCOPE)
endif()
endfunction()
macro(parse_arguments)
set(options BASIC_SETUP CMAKE_TARGETS UPDATE KEEP_RPATHS NO_LOAD NO_OUTPUT_DIRS OUTPUT_QUIET NO_IMPORTS SKIP_STD)
set(oneValueArgs CONANFILE ARCH BUILD_TYPE INSTALL_FOLDER CONAN_COMMAND)
set(multiValueArgs DEBUG_PROFILE RELEASE_PROFILE RELWITHDEBINFO_PROFILE MINSIZEREL_PROFILE
PROFILE REQUIRES OPTIONS IMPORTS SETTINGS BUILD ENV GENERATORS PROFILE_AUTO
INSTALL_ARGS CONFIGURATION_TYPES)
cmake_parse_arguments(ARGUMENTS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
endmacro()
function(conan_cmake_install)
# Calls "conan install"
# Argument BUILD is equivalant to --build={missing, PkgName,...} or
# --build when argument is 'BUILD all' (which builds all packages from source)
# Argument CONAN_COMMAND, to specify the conan path, e.g. in case of running from source
# cmake does not identify conan as command, even if it is +x and it is in the path
parse_arguments(${ARGV})
if(CONAN_CMAKE_MULTI)
set(ARGUMENTS_GENERATORS ${ARGUMENTS_GENERATORS} cmake_multi)
else()
set(ARGUMENTS_GENERATORS ${ARGUMENTS_GENERATORS} cmake)
endif()
set(CONAN_BUILD_POLICY "")
foreach(ARG ${ARGUMENTS_BUILD})
if(${ARG} STREQUAL "all")
set(CONAN_BUILD_POLICY ${CONAN_BUILD_POLICY} --build)
break()
else()
set(CONAN_BUILD_POLICY ${CONAN_BUILD_POLICY} --build=${ARG})
endif()
endforeach()
if(ARGUMENTS_CONAN_COMMAND)
set(CONAN_CMD ${ARGUMENTS_CONAN_COMMAND})
else()
conan_check(REQUIRED)
endif()
set(CONAN_OPTIONS "")
if(ARGUMENTS_CONANFILE)
set(CONANFILE ${CMAKE_CURRENT_SOURCE_DIR}/${ARGUMENTS_CONANFILE})
# A conan file has been specified - apply specified options as well if provided
foreach(ARG ${ARGUMENTS_OPTIONS})
set(CONAN_OPTIONS ${CONAN_OPTIONS} -o=${ARG})
endforeach()
else()
set(CONANFILE ".")
endif()
if(ARGUMENTS_UPDATE)
set(CONAN_INSTALL_UPDATE --update)
endif()
if(ARGUMENTS_NO_IMPORTS)
set(CONAN_INSTALL_NO_IMPORTS --no-imports)
endif()
set(CONAN_INSTALL_FOLDER "")
if(ARGUMENTS_INSTALL_FOLDER)
set(CONAN_INSTALL_FOLDER -if=${ARGUMENTS_INSTALL_FOLDER})
endif()
foreach(ARG ${ARGUMENTS_GENERATORS})
set(CONAN_GENERATORS ${CONAN_GENERATORS} -g=${ARG})
endforeach()
foreach(ARG ${ARGUMENTS_ENV})
set(CONAN_ENV_VARS ${CONAN_ENV_VARS} -e=${ARG})
endforeach()
set(conan_args install ${CONANFILE} ${settings} ${CONAN_ENV_VARS} ${CONAN_GENERATORS} ${CONAN_BUILD_POLICY} ${CONAN_INSTALL_UPDATE} ${CONAN_INSTALL_NO_IMPORTS} ${CONAN_OPTIONS} ${CONAN_INSTALL_FOLDER} ${ARGUMENTS_INSTALL_ARGS})
string (REPLACE ";" " " _conan_args "${conan_args}")
message(STATUS "Conan executing: ${CONAN_CMD} ${_conan_args}")
if(ARGUMENTS_OUTPUT_QUIET)
execute_process(COMMAND ${CONAN_CMD} ${conan_args}
RESULT_VARIABLE return_code
OUTPUT_VARIABLE conan_output
ERROR_VARIABLE conan_output
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
else()
execute_process(COMMAND ${CONAN_CMD} ${conan_args}
RESULT_VARIABLE return_code
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endif()
if(NOT "${return_code}" STREQUAL "0")
message(FATAL_ERROR "Conan install failed='${return_code}'")
endif()
endfunction()
function(conan_cmake_setup_conanfile)
parse_arguments(${ARGV})
if(ARGUMENTS_CONANFILE)
get_filename_component(_CONANFILE_NAME ${ARGUMENTS_CONANFILE} NAME)
# configure_file will make sure cmake re-runs when conanfile is updated
configure_file(${ARGUMENTS_CONANFILE} ${CMAKE_CURRENT_BINARY_DIR}/${_CONANFILE_NAME}.junk COPYONLY)
file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/${_CONANFILE_NAME}.junk)
else()
conan_cmake_generate_conanfile(${ARGV})
endif()
endfunction()
function(conan_cmake_generate_conanfile)
# Generate, writing in disk a conanfile.txt with the requires, options, and imports
# specified as arguments
# This will be considered as temporary file, generated in CMAKE_CURRENT_BINARY_DIR)
parse_arguments(${ARGV})
set(_FN "${CMAKE_CURRENT_BINARY_DIR}/conanfile.txt")
file(WRITE ${_FN} "[generators]\ncmake\n\n[requires]\n")
foreach(ARG ${ARGUMENTS_REQUIRES})
file(APPEND ${_FN} ${ARG} "\n")
endforeach()
file(APPEND ${_FN} ${ARG} "\n[options]\n")
foreach(ARG ${ARGUMENTS_OPTIONS})
file(APPEND ${_FN} ${ARG} "\n")
endforeach()
file(APPEND ${_FN} ${ARG} "\n[imports]\n")
foreach(ARG ${ARGUMENTS_IMPORTS})
file(APPEND ${_FN} ${ARG} "\n")
endforeach()
endfunction()
macro(conan_load_buildinfo)
if(CONAN_CMAKE_MULTI)
set(_CONANBUILDINFO conanbuildinfo_multi.cmake)
else()
set(_CONANBUILDINFO conanbuildinfo.cmake)
endif()
if(ARGUMENTS_INSTALL_FOLDER)
set(_CONANBUILDINFOFOLDER ${ARGUMENTS_INSTALL_FOLDER})
else()
set(_CONANBUILDINFOFOLDER ${CMAKE_CURRENT_BINARY_DIR})
endif()
# Checks for the existence of conanbuildinfo.cmake, and loads it
# important that it is macro, so variables defined at parent scope
if(EXISTS "${_CONANBUILDINFOFOLDER}/${_CONANBUILDINFO}")
message(STATUS "Conan: Loading ${_CONANBUILDINFO}")
include(${_CONANBUILDINFOFOLDER}/${_CONANBUILDINFO})
else()
message(FATAL_ERROR "${_CONANBUILDINFO} doesn't exist in ${CMAKE_CURRENT_BINARY_DIR}")
endif()
endmacro()
macro(conan_cmake_run)
parse_arguments(${ARGV})
if(ARGUMENTS_CONFIGURATION_TYPES AND NOT CMAKE_CONFIGURATION_TYPES)
message(WARNING "CONFIGURATION_TYPES should only be specified for multi-configuration generators")
elseif(ARGUMENTS_CONFIGURATION_TYPES AND ARGUMENTS_BUILD_TYPE)
message(WARNING "CONFIGURATION_TYPES and BUILD_TYPE arguments should not be defined at the same time.")
endif()
if(CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE AND NOT CONAN_EXPORTED
AND NOT ARGUMENTS_BUILD_TYPE)
set(CONAN_CMAKE_MULTI ON)
if (NOT ARGUMENTS_CONFIGURATION_TYPES)
set(ARGUMENTS_CONFIGURATION_TYPES "Release;Debug")
endif()
message(STATUS "Conan: Using cmake-multi generator")
else()
set(CONAN_CMAKE_MULTI OFF)
endif()
if(NOT CONAN_EXPORTED)
conan_cmake_setup_conanfile(${ARGV})
if(CONAN_CMAKE_MULTI)
foreach(CMAKE_BUILD_TYPE ${ARGUMENTS_CONFIGURATION_TYPES})
set(ENV{CONAN_IMPORT_PATH} ${CMAKE_BUILD_TYPE})
conan_cmake_settings(settings ${ARGV})
conan_cmake_install(SETTINGS ${settings} ${ARGV})
endforeach()
set(CMAKE_BUILD_TYPE)
else()
conan_cmake_settings(settings ${ARGV})
conan_cmake_install(SETTINGS ${settings} ${ARGV})
endif()
endif()
if (NOT ARGUMENTS_NO_LOAD)
conan_load_buildinfo()
endif()
if(ARGUMENTS_BASIC_SETUP)
foreach(_option CMAKE_TARGETS KEEP_RPATHS NO_OUTPUT_DIRS SKIP_STD)
if(ARGUMENTS_${_option})
if(${_option} STREQUAL "CMAKE_TARGETS")
list(APPEND _setup_options "TARGETS")
else()
list(APPEND _setup_options ${_option})
endif()
endif()
endforeach()
conan_basic_setup(${_setup_options})
endif()
endmacro()
macro(conan_check)
# Checks conan availability in PATH
# Arguments REQUIRED and VERSION are optional
# Example usage:
# conan_check(VERSION 1.0.0 REQUIRED)
message(STATUS "Conan: checking conan executable")
set(options REQUIRED)
set(oneValueArgs VERSION)
cmake_parse_arguments(CONAN "${options}" "${oneValueArgs}" "" ${ARGN})
find_program(CONAN_CMD conan)
if(NOT CONAN_CMD AND CONAN_REQUIRED)
message(FATAL_ERROR "Conan executable not found!")
endif()
message(STATUS "Conan: Found program ${CONAN_CMD}")
execute_process(COMMAND ${CONAN_CMD} --version
OUTPUT_VARIABLE CONAN_VERSION_OUTPUT
ERROR_VARIABLE CONAN_VERSION_OUTPUT)
message(STATUS "Conan: Version found ${CONAN_VERSION_OUTPUT}")
if(DEFINED CONAN_VERSION)
string(REGEX MATCH ".*Conan version ([0-9]+\.[0-9]+\.[0-9]+)" FOO
"${CONAN_VERSION_OUTPUT}")
if(${CMAKE_MATCH_1} VERSION_LESS ${CONAN_VERSION})
message(FATAL_ERROR "Conan outdated. Installed: ${CMAKE_MATCH_1}, \
required: ${CONAN_VERSION}. Consider updating via 'pip \
install conan==${CONAN_VERSION}'.")
endif()
endif()
endmacro()
function(conan_add_remote)
# Adds a remote
# Arguments URL and NAME are required, INDEX and COMMAND are optional
# Example usage:
# conan_add_remote(NAME bincrafters INDEX 1
# URL https://api.bintray.com/conan/bincrafters/public-conan)
set(oneValueArgs URL NAME INDEX COMMAND)
cmake_parse_arguments(CONAN "" "${oneValueArgs}" "" ${ARGN})
if(DEFINED CONAN_INDEX)
set(CONAN_INDEX_ARG "-i ${CONAN_INDEX}")
endif()
if(CONAN_COMMAND)
set(CONAN_CMD ${CONAN_COMMAND})
else()
conan_check(REQUIRED)
endif()
message(STATUS "Conan: Adding ${CONAN_NAME} remote repository (${CONAN_URL})")
execute_process(COMMAND ${CONAN_CMD} remote add ${CONAN_NAME} ${CONAN_URL}
${CONAN_INDEX_ARG} -f)
endfunction()
macro(conan_config_install)
# install a full configuration from a local or remote zip file
# Argument ITEM is required, arguments TYPE, SOURCE, TARGET and VERIFY_SSL are optional
# Example usage:
# conan_config_install(ITEM https://github.com/conan-io/cmake-conan.git
# TYPE git SOURCE source-folder TARGET target-folder VERIFY_SSL false)
set(oneValueArgs ITEM TYPE SOURCE TARGET VERIFY_SSL)
set(multiValueArgs ARGS)
cmake_parse_arguments(CONAN "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
set(CONAN_CONFIG_INSTALL_ARGS "")
find_program(CONAN_CMD conan)
if(NOT CONAN_CMD AND CONAN_REQUIRED)
message(FATAL_ERROR "Conan executable not found!")
endif()
if(DEFINED CONAN_VERIFY_SSL)
set(CONAN_CONFIG_INSTALL_ARGS "${CONAN_CONFIG_INSTALL_ARGS} --verify-ssl ${CONAN_VERIFY_SSL}")
endif()
if(DEFINED CONAN_TYPE)
set(CONAN_CONFIG_INSTALL_ARGS "${CONAN_CONFIG_INSTALL_ARGS} --type ${CONAN_TYPE}")
endif()
if(DEFINED CONAN_ARGS)
set(CONAN_CONFIG_INSTALL_ARGS "${CONAN_CONFIG_INSTALL_ARGS} --args \"${CONAN_ARGS}\"")
endif()
if(DEFINED CONAN_SOURCE)
set(CONAN_CONFIG_INSTALL_ARGS "${CONAN_CONFIG_INSTALL_ARGS} --source-folder ${CONAN_SOURCE}")
endif()
if(DEFINED CONAN_TARGET)
set(CONAN_CONFIG_INSTALL_ARGS "${CONAN_CONFIG_INSTALL_ARGS} --target-folder ${CONAN_TARGET}")
endif()
message(STATUS "Conan: Installing config from ${CONAN_ITEM}")
execute_process(COMMAND ${CONAN_CMD} config install ${CONAN_CONFIG_INSTALL_ARGS} ${CONAN_ITEM})
endmacro()

38
cmake/conan_utils.cmake Normal file
View File

@ -0,0 +1,38 @@
include(conan)
macro(setup_conan)
# Right now every dependency shall be static
set(CONAN_OPTIONS ${CONAN_OPTIONS} "*:shared=False")
set(REQUIREMENTS nlohmann_json/3.7.3 spdlog/1.5.0)
if(APPLE AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(REQUIREMENTS ${REQUIREMENTS} llvm-openmp/8.0.1)
if(SKBUILD)
set(CONAN_OPTIONS ${CONAN_OPTIONS} "llvm-openmp:shared=True")
endif()
endif()
if(SKBUILD)
set(REQUIREMENTS ${REQUIREMENTS} muparserx/4.0.8)
if(NOT MSVC)
set(CONAN_OPTIONS ${CONAN_OPTIONS} "muparserx:fPIC=True")
endif()
endif()
if(AER_THRUST_BACKEND AND NOT AER_THRUST_BACKEND STREQUAL "CUDA")
set(REQUIREMENTS ${REQUIREMENTS} thrust/1.9.5)
string(TOLOWER ${AER_THRUST_BACKEND} THRUST_BACKEND)
set(CONAN_OPTIONS ${CONAN_OPTIONS} "thrust:device_system=${THRUST_BACKEND}")
endif()
if(NOT BLAS_LIB_PATH)
set(REQUIREMENTS ${REQUIREMENTS} openblas/0.3.7)
endif()
if(BUILD_TESTS)
set(REQUIREMENTS ${REQUIREMENTS} catch2/2.12.1)
endif()
conan_cmake_run(REQUIRES ${REQUIREMENTS} OPTIONS ${CONAN_OPTIONS} BASIC_SETUP CMAKE_TARGETS KEEP_RPATHS BUILD missing)
endmacro()

View File

@ -1,2 +1,3 @@
pylint==2.4.4
astroid==2.3.3
six>1.10,<=1.14

View File

@ -1,2 +1,2 @@
[build-system]
requires = ["setuptools", "wheel", "scikit-build", "cmake!=3.17.1,!=3.17.0", "ninja", "pybind11>2.4"]
requires = ["setuptools", "wheel", "conan>=1.22.2", "scikit-build", "cmake!=3.17.1,!=3.17.0", "ninja", "pybind11>2.4"]

View File

@ -20,5 +20,5 @@ install(TARGETS controller_wrappers LIBRARY DESTINATION qiskit/providers/aer/bac
# Install redistributable dependencies
if(APPLE)
install(FILES "${AER_SIMULATOR_CPP_SRC_DIR}/third-party/macos/lib/libomp.dylib" DESTINATION qiskit/providers/aer/backends)
install(FILES "${CONAN_LIB_DIRS_LLVM-OPENMP}/libomp.dylib" DESTINATION qiskit/providers/aer/backends)
endif()

View File

@ -1,4 +1,5 @@
cmake!=3.17.1,!=3.17.0
conan>=1.22.2
scikit-build
cython
asv

View File

@ -9,6 +9,12 @@ import subprocess
import sys
import inspect
try:
from conans import client
except ImportError:
subprocess.call([sys.executable, '-m', 'pip', 'install', 'conan'])
from conans import client
try:
from skbuild import setup
except ImportError:
@ -35,7 +41,8 @@ requirements = [
setup_requirements = requirements + [
'scikit-build',
'cmake!=3.17,!=3.17.0'
'cmake!=3.17,!=3.17.0',
'conan>=1.22.2'
]
if not hasattr(setuptools,

View File

@ -25,7 +25,7 @@
#include <iostream>
#include <type_traits>
#include <nlohmann_json.hpp>
#include <nlohmann/json.hpp>
#include "framework/matrix.hpp"
namespace nl = nlohmann;

View File

@ -38,7 +38,7 @@
#include <pybind11/complex.h>
#include <pybind11/numpy.h>
#include <nlohmann_json.hpp>
#include <nlohmann/json.hpp>
#include "framework/json.hpp"
namespace py = pybind11;

View File

@ -331,4 +331,4 @@ void populate_hooks(void * handle){
}
}
#endif
#endif

View File

@ -20,7 +20,7 @@
#include <complex>
#include <string>
#include <numpy/arrayobject.h>
#include <muparserx/parser/mpParser.h>
#include <muparserx/mpParser.h>
struct ParserValues {
ParserValues(std::unique_ptr<mup::ParserX> parser, const std::string& expr):

View File

@ -18,6 +18,7 @@
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <math.h>

View File

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2013-2018 Niels Lohmann
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,178 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS

@ -1 +0,0 @@
Subproject commit 08cbfc3e9087e8fceafc85c8fdb7e034e1c35943

File diff suppressed because it is too large Load Diff

@ -1 +0,0 @@
Subproject commit aded199441e022f7fb89d51c1b2804ebc448c1af

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,174 +0,0 @@
==============================================================================
The software contained in this directory tree is dual licensed under both the
University of Illinois "BSD-Like" license and the MIT license. As a user of
this code you may choose to use it under either license. As a contributor,
you agree to allow your code to be used under both. The full text of the
relevant licenses is included below.
In addition, a license agreement from the copyright/patent holders of the
software contained in this directory tree is included below.
==============================================================================
University of Illinois/NCSA
Open Source License
Copyright (c) 1997-2016 Intel Corporation
All rights reserved.
Developed by:
OpenMP Runtime Team
Intel Corporation
http://www.openmprtl.org
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal with
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimers.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimers in the
documentation and/or other materials provided with the distribution.
* Neither the names of Intel Corporation OpenMP Runtime Team nor the
names of its contributors may be used to endorse or promote products
derived from this Software without specific prior written permission.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
SOFTWARE.
==============================================================================
Copyright (c) 1997-2016 Intel Corporation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
==============================================================================
Intel Corporation
Software Grant License Agreement ("Agreement")
Except for the license granted herein to you, Intel Corporation ("Intel") reserves
all right, title, and interest in and to the Software (defined below).
Definition
"Software" means the code and documentation as well as any original work of
authorship, including any modifications or additions to an existing work, that
is intentionally submitted by Intel to llvm.org (http://llvm.org) ("LLVM") for
inclusion in, or documentation of, any of the products owned or managed by LLVM
(the "Work"). For the purposes of this definition, "submitted" means any form of
electronic, verbal, or written communication sent to LLVM or its
representatives, including but not limited to communication on electronic
mailing lists, source code control systems, and issue tracking systems that are
managed by, or on behalf of, LLVM for the purpose of discussing and improving
the Work, but excluding communication that is conspicuously marked otherwise.
1. Grant of Copyright License. Subject to the terms and conditions of this
Agreement, Intel hereby grants to you and to recipients of the Software
distributed by LLVM a perpetual, worldwide, non-exclusive, no-charge,
royalty-free, irrevocable copyright license to reproduce, prepare derivative
works of, publicly display, publicly perform, sublicense, and distribute the
Software and such derivative works.
2. Grant of Patent License. Subject to the terms and conditions of this
Agreement, Intel hereby grants you and to recipients of the Software
distributed by LLVM a perpetual, worldwide, non-exclusive, no-charge,
royalty-free, irrevocable (except as stated in this section) patent license
to make, have made, use, offer to sell, sell, import, and otherwise transfer
the Work, where such license applies only to those patent claims licensable
by Intel that are necessarily infringed by Intel's Software alone or by
combination of the Software with the Work to which such Software was
submitted. If any entity institutes patent litigation against Intel or any
other entity (including a cross-claim or counterclaim in a lawsuit) alleging
that Intel's Software, or the Work to which Intel has contributed constitutes
direct or contributory patent infringement, then any patent licenses granted
to that entity under this Agreement for the Software or Work shall terminate
as of the date such litigation is filed.
Unless required by applicable law or agreed to in writing, the software is
provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
either express or implied, including, without limitation, any warranties or
conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE.
==============================================================================
ARM Limited
Software Grant License Agreement ("Agreement")
Except for the license granted herein to you, ARM Limited ("ARM") reserves all
right, title, and interest in and to the Software (defined below).
Definition
"Software" means the code and documentation as well as any original work of
authorship, including any modifications or additions to an existing work, that
is intentionally submitted by ARM to llvm.org (http://llvm.org) ("LLVM") for
inclusion in, or documentation of, any of the products owned or managed by LLVM
(the "Work"). For the purposes of this definition, "submitted" means any form of
electronic, verbal, or written communication sent to LLVM or its
representatives, including but not limited to communication on electronic
mailing lists, source code control systems, and issue tracking systems that are
managed by, or on behalf of, LLVM for the purpose of discussing and improving
the Work, but excluding communication that is conspicuously marked otherwise.
1. Grant of Copyright License. Subject to the terms and conditions of this
Agreement, ARM hereby grants to you and to recipients of the Software
distributed by LLVM a perpetual, worldwide, non-exclusive, no-charge,
royalty-free, irrevocable copyright license to reproduce, prepare derivative
works of, publicly display, publicly perform, sublicense, and distribute the
Software and such derivative works.
2. Grant of Patent License. Subject to the terms and conditions of this
Agreement, ARM hereby grants you and to recipients of the Software
distributed by LLVM a perpetual, worldwide, non-exclusive, no-charge,
royalty-free, irrevocable (except as stated in this section) patent license
to make, have made, use, offer to sell, sell, import, and otherwise transfer
the Work, where such license applies only to those patent claims licensable
by ARM that are necessarily infringed by ARM's Software alone or by
combination of the Software with the Work to which such Software was
submitted. If any entity institutes patent litigation against ARM or any
other entity (including a cross-claim or counterclaim in a lawsuit) alleging
that ARM's Software, or the Work to which ARM has contributed constitutes
direct or contributory patent infringement, then any patent licenses granted
to that entity under this Agreement for the Software or Work shall terminate
as of the date such litigation is filed.
Unless required by applicable law or agreed to in writing, the software is
provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
either express or implied, including, without limitation, any warranties or
conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE.
==============================================================================

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,215 +0,0 @@
/*
* include/50/omp.h.var
*/
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.txt for details.
//
//===----------------------------------------------------------------------===//
#ifndef __OMP_H
# define __OMP_H
# define KMP_VERSION_MAJOR 5
# define KMP_VERSION_MINOR 0
# define KMP_VERSION_BUILD 20140926
# define KMP_BUILD_DATE "No_Timestamp"
# ifdef __cplusplus
extern "C" {
# endif
# if defined(_WIN32)
# define __KAI_KMPC_CONVENTION __cdecl
# else
# define __KAI_KMPC_CONVENTION
# endif
/* schedule kind constants */
typedef enum omp_sched_t {
omp_sched_static = 1,
omp_sched_dynamic = 2,
omp_sched_guided = 3,
omp_sched_auto = 4
} omp_sched_t;
/* set API functions */
extern void __KAI_KMPC_CONVENTION omp_set_num_threads (int);
extern void __KAI_KMPC_CONVENTION omp_set_dynamic (int);
extern void __KAI_KMPC_CONVENTION omp_set_nested (int);
extern void __KAI_KMPC_CONVENTION omp_set_max_active_levels (int);
extern void __KAI_KMPC_CONVENTION omp_set_schedule (omp_sched_t, int);
/* query API functions */
extern int __KAI_KMPC_CONVENTION omp_get_num_threads (void);
extern int __KAI_KMPC_CONVENTION omp_get_dynamic (void);
extern int __KAI_KMPC_CONVENTION omp_get_nested (void);
extern int __KAI_KMPC_CONVENTION omp_get_max_threads (void);
extern int __KAI_KMPC_CONVENTION omp_get_thread_num (void);
extern int __KAI_KMPC_CONVENTION omp_get_num_procs (void);
extern int __KAI_KMPC_CONVENTION omp_in_parallel (void);
extern int __KAI_KMPC_CONVENTION omp_in_final (void);
extern int __KAI_KMPC_CONVENTION omp_get_active_level (void);
extern int __KAI_KMPC_CONVENTION omp_get_level (void);
extern int __KAI_KMPC_CONVENTION omp_get_ancestor_thread_num (int);
extern int __KAI_KMPC_CONVENTION omp_get_team_size (int);
extern int __KAI_KMPC_CONVENTION omp_get_thread_limit (void);
extern int __KAI_KMPC_CONVENTION omp_get_max_active_levels (void);
extern void __KAI_KMPC_CONVENTION omp_get_schedule (omp_sched_t *, int *);
extern int __KAI_KMPC_CONVENTION omp_get_max_task_priority (void);
/* lock API functions */
typedef struct omp_lock_t {
void * _lk;
} omp_lock_t;
extern void __KAI_KMPC_CONVENTION omp_init_lock (omp_lock_t *);
extern void __KAI_KMPC_CONVENTION omp_set_lock (omp_lock_t *);
extern void __KAI_KMPC_CONVENTION omp_unset_lock (omp_lock_t *);
extern void __KAI_KMPC_CONVENTION omp_destroy_lock (omp_lock_t *);
extern int __KAI_KMPC_CONVENTION omp_test_lock (omp_lock_t *);
/* nested lock API functions */
typedef struct omp_nest_lock_t {
void * _lk;
} omp_nest_lock_t;
extern void __KAI_KMPC_CONVENTION omp_init_nest_lock (omp_nest_lock_t *);
extern void __KAI_KMPC_CONVENTION omp_set_nest_lock (omp_nest_lock_t *);
extern void __KAI_KMPC_CONVENTION omp_unset_nest_lock (omp_nest_lock_t *);
extern void __KAI_KMPC_CONVENTION omp_destroy_nest_lock (omp_nest_lock_t *);
extern int __KAI_KMPC_CONVENTION omp_test_nest_lock (omp_nest_lock_t *);
/* lock hint type for dynamic user lock */
typedef enum omp_lock_hint_t {
omp_lock_hint_none = 0,
omp_lock_hint_uncontended = 1,
omp_lock_hint_contended = (1<<1 ),
omp_lock_hint_nonspeculative = (1<<2 ),
omp_lock_hint_speculative = (1<<3 ),
kmp_lock_hint_hle = (1<<16),
kmp_lock_hint_rtm = (1<<17),
kmp_lock_hint_adaptive = (1<<18)
} omp_lock_hint_t;
/* hinted lock initializers */
extern void __KAI_KMPC_CONVENTION omp_init_lock_with_hint(omp_lock_t *, omp_lock_hint_t);
extern void __KAI_KMPC_CONVENTION omp_init_nest_lock_with_hint(omp_nest_lock_t *, omp_lock_hint_t);
/* time API functions */
extern double __KAI_KMPC_CONVENTION omp_get_wtime (void);
extern double __KAI_KMPC_CONVENTION omp_get_wtick (void);
/* OpenMP 4.0 */
extern int __KAI_KMPC_CONVENTION omp_get_default_device (void);
extern void __KAI_KMPC_CONVENTION omp_set_default_device (int);
extern int __KAI_KMPC_CONVENTION omp_is_initial_device (void);
extern int __KAI_KMPC_CONVENTION omp_get_num_devices (void);
extern int __KAI_KMPC_CONVENTION omp_get_num_teams (void);
extern int __KAI_KMPC_CONVENTION omp_get_team_num (void);
extern int __KAI_KMPC_CONVENTION omp_get_cancellation (void);
# include <stdlib.h>
/* OpenMP 4.5 */
extern int __KAI_KMPC_CONVENTION omp_get_initial_device (void);
extern void* __KAI_KMPC_CONVENTION omp_target_alloc(size_t, int);
extern void __KAI_KMPC_CONVENTION omp_target_free(void *, int);
extern int __KAI_KMPC_CONVENTION omp_target_is_present(void *, int);
extern int __KAI_KMPC_CONVENTION omp_target_memcpy(void *, void *, size_t, size_t, size_t, int, int);
extern int __KAI_KMPC_CONVENTION omp_target_memcpy_rect(void *, void *, size_t, int, const size_t *,
const size_t *, const size_t *, const size_t *, const size_t *, int, int);
extern int __KAI_KMPC_CONVENTION omp_target_associate_ptr(void *, void *, size_t, size_t, int);
extern int __KAI_KMPC_CONVENTION omp_target_disassociate_ptr(void *, int);
/* kmp API functions */
extern int __KAI_KMPC_CONVENTION kmp_get_stacksize (void);
extern void __KAI_KMPC_CONVENTION kmp_set_stacksize (int);
extern size_t __KAI_KMPC_CONVENTION kmp_get_stacksize_s (void);
extern void __KAI_KMPC_CONVENTION kmp_set_stacksize_s (size_t);
extern int __KAI_KMPC_CONVENTION kmp_get_blocktime (void);
extern int __KAI_KMPC_CONVENTION kmp_get_library (void);
extern void __KAI_KMPC_CONVENTION kmp_set_blocktime (int);
extern void __KAI_KMPC_CONVENTION kmp_set_library (int);
extern void __KAI_KMPC_CONVENTION kmp_set_library_serial (void);
extern void __KAI_KMPC_CONVENTION kmp_set_library_turnaround (void);
extern void __KAI_KMPC_CONVENTION kmp_set_library_throughput (void);
extern void __KAI_KMPC_CONVENTION kmp_set_defaults (char const *);
extern void __KAI_KMPC_CONVENTION kmp_set_disp_num_buffers (int);
/* Intel affinity API */
typedef void * kmp_affinity_mask_t;
extern int __KAI_KMPC_CONVENTION kmp_set_affinity (kmp_affinity_mask_t *);
extern int __KAI_KMPC_CONVENTION kmp_get_affinity (kmp_affinity_mask_t *);
extern int __KAI_KMPC_CONVENTION kmp_get_affinity_max_proc (void);
extern void __KAI_KMPC_CONVENTION kmp_create_affinity_mask (kmp_affinity_mask_t *);
extern void __KAI_KMPC_CONVENTION kmp_destroy_affinity_mask (kmp_affinity_mask_t *);
extern int __KAI_KMPC_CONVENTION kmp_set_affinity_mask_proc (int, kmp_affinity_mask_t *);
extern int __KAI_KMPC_CONVENTION kmp_unset_affinity_mask_proc (int, kmp_affinity_mask_t *);
extern int __KAI_KMPC_CONVENTION kmp_get_affinity_mask_proc (int, kmp_affinity_mask_t *);
/* OpenMP 4.0 affinity API */
typedef enum omp_proc_bind_t {
omp_proc_bind_false = 0,
omp_proc_bind_true = 1,
omp_proc_bind_master = 2,
omp_proc_bind_close = 3,
omp_proc_bind_spread = 4
} omp_proc_bind_t;
extern omp_proc_bind_t __KAI_KMPC_CONVENTION omp_get_proc_bind (void);
/* OpenMP 4.5 affinity API */
extern int __KAI_KMPC_CONVENTION omp_get_num_places (void);
extern int __KAI_KMPC_CONVENTION omp_get_place_num_procs (int);
extern void __KAI_KMPC_CONVENTION omp_get_place_proc_ids (int, int *);
extern int __KAI_KMPC_CONVENTION omp_get_place_num (void);
extern int __KAI_KMPC_CONVENTION omp_get_partition_num_places (void);
extern void __KAI_KMPC_CONVENTION omp_get_partition_place_nums (int *);
extern void * __KAI_KMPC_CONVENTION kmp_malloc (size_t);
extern void * __KAI_KMPC_CONVENTION kmp_aligned_malloc (size_t, size_t);
extern void * __KAI_KMPC_CONVENTION kmp_calloc (size_t, size_t);
extern void * __KAI_KMPC_CONVENTION kmp_realloc (void *, size_t);
extern void __KAI_KMPC_CONVENTION kmp_free (void *);
extern void __KAI_KMPC_CONVENTION kmp_set_warnings_on(void);
extern void __KAI_KMPC_CONVENTION kmp_set_warnings_off(void);
/* OpenMP 5.0 Tool Control */
typedef enum omp_control_tool_result_t {
omp_control_tool_notool = -2,
omp_control_tool_nocallback = -1,
omp_control_tool_success = 0,
omp_control_tool_ignored = 1
} omp_control_tool_result_t;
typedef enum omp_control_tool_t {
omp_control_tool_start = 1,
omp_control_tool_pause = 2,
omp_control_tool_flush = 3,
omp_control_tool_end = 4
} omp_control_tool_t;
extern int __KAI_KMPC_CONVENTION omp_control_tool(int, int, void*);
# undef __KAI_KMPC_CONVENTION
/* Warning:
The following typedefs are not standard, deprecated and will be removed in a future release.
*/
typedef int omp_int_t;
typedef double omp_wtime_t;
# ifdef __cplusplus
}
# endif
#endif /* __OMP_H */

View File

@ -1,29 +0,0 @@
Copyright (c) 2011-2014, The OpenBLAS Project
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. Neither the name of the OpenBLAS project nor the names of
its contributors may be used to endorse or promote products
derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Binary file not shown.

Binary file not shown.

View File

@ -1,6 +1,3 @@
set(Catch2_PATH "third-party/")
find_package(Catch2 REQUIRED)
add_executable(test_snapshot "src/test_snapshot.cpp")
set_target_properties(test_snapshot PROPERTIES
LINKER_LANGUAGE CXX
@ -9,7 +6,7 @@ target_include_directories(test_snapshot
PRIVATE ${AER_SIMULATOR_CPP_SRC_DIR}
PRIVATE ${AER_SIMULATOR_CPP_EXTERNAL_LIBS})
target_link_libraries(test_snapshot
PRIVATE Catch2::Catch
PRIVATE CONAN_PKG::catch2
PRIVATE ${AER_LIBRARIES})
add_test(test_snapshot test_snapshot)
@ -22,7 +19,7 @@ target_include_directories(test_snapshot_bdd
PRIVATE ${AER_SIMULATOR_CPP_SRC_DIR}
PRIVATE ${AER_SIMULATOR_CPP_EXTERNAL_LIBS})
target_link_libraries(test_snapshot_bdd
PRIVATE Catch2::Catch
PRIVATE CONAN_PKG::catch2
PRIVATE ${AER_LIBRARIES})
add_test(test_snapshot_bdd test_snapshot_bdd)
@ -34,7 +31,7 @@ target_include_directories(test_utils
PRIVATE ${AER_SIMULATOR_CPP_SRC_DIR}
PRIVATE ${AER_SIMULATOR_CPP_EXTERNAL_LIBS})
target_link_libraries(test_utils
PRIVATE Catch2::Catch
PRIVATE CONAN_PKG::catch2
PRIVATE ${AER_LIBRARIES})
add_test(test_utils test_utils)
@ -42,4 +39,4 @@ add_test(test_utils test_utils)
add_custom_target(build_tests
test_snapshot
test_snapshot_bdd
test_utils)
test_utils)

View File

@ -1,6 +1,6 @@
#define CATCH_CONFIG_MAIN
#include <map>
#include <catch.hpp>
#include <catch2/catch.hpp>
#include <controllers/qasm_controller.hpp>

View File

@ -1,6 +1,6 @@
#define CATCH_CONFIG_MAIN
#include <map>
#include <catch.hpp>
#include <catch2/catch.hpp>
#include <controllers/qasm_controller.hpp>

View File

@ -1,6 +1,6 @@
#define CATCH_CONFIG_MAIN
#include <map>
#include <catch.hpp>
#include <catch2/catch.hpp>
#include <cmath>
#include <limits>
#include "framework/linalg/almost_equal.hpp"

View File

@ -29,7 +29,7 @@ class QasmAlgorithmTests:
# ---------------------------------------------------------------------
def test_grovers_default_basis_gates(self):
"""Test grovers circuits compiling to backend default basis_gates."""
shots = 2000
shots = 4000
circuits = ref_algorithms.grovers_circuit(
final_measure=True, allow_sampling=True)
targets = ref_algorithms.grovers_counts(shots)
@ -40,7 +40,7 @@ class QasmAlgorithmTests:
def test_teleport_default_basis_gates(self):
"""Test teleport circuits compiling to backend default basis_gates."""
shots = 2000
shots = 4000
circuits = ref_algorithms.teleport_circuit()
targets = ref_algorithms.teleport_counts(shots)
job = execute(circuits, self.SIMULATOR, shots=shots)
@ -60,7 +60,7 @@ class QasmAlgorithmTestsWaltzBasis:
# ---------------------------------------------------------------------
def test_grovers_waltz_basis_gates(self):
"""Test grovers gate circuits compiling to u1,u2,u3,cx"""
shots = 2000
shots = 4000
circuits = ref_algorithms.grovers_circuit(
final_measure=True, allow_sampling=True)
targets = ref_algorithms.grovers_counts(shots)
@ -76,7 +76,7 @@ class QasmAlgorithmTestsWaltzBasis:
def test_teleport_waltz_basis_gates(self):
"""Test teleport gate circuits compiling to u1,u2,u3,cx"""
shots = 2000
shots = 4000
circuits = ref_algorithms.teleport_circuit()
targets = ref_algorithms.teleport_counts(shots)
job = execute(
@ -100,7 +100,7 @@ class QasmAlgorithmTestsMinimalBasis:
# ---------------------------------------------------------------------
def test_grovers_minimal_basis_gates(self):
"""Test grovers circuits compiling to u3,cx"""
shots = 2000
shots = 4000
circuits = ref_algorithms.grovers_circuit(
final_measure=True, allow_sampling=True)
targets = ref_algorithms.grovers_counts(shots)
@ -112,7 +112,7 @@ class QasmAlgorithmTestsMinimalBasis:
def test_teleport_minimal_basis_gates(self):
"""Test teleport gate circuits compiling to u3,cx"""
shots = 2000
shots = 4000
circuits = ref_algorithms.teleport_circuit()
targets = ref_algorithms.teleport_counts(shots)
job = execute(

View File

@ -41,7 +41,7 @@ class QasmCliffordTests:
def test_h_gate_nondeterministic_default_basis_gates(self):
"""Test h-gate circuits compiling to backend default basis_gates."""
shots = 2000
shots = 4000
circuits = ref_1q_clifford.h_gate_circuits_nondeterministic(
final_measure=True)
targets = ref_1q_clifford.h_gate_counts_nondeterministic(shots)
@ -108,7 +108,7 @@ class QasmCliffordTests:
def test_s_gate_nondeterministic_default_basis_gates(self):
"""Test s-gate circuits compiling to backend default basis_gates."""
shots = 2000
shots = 4000
circuits = ref_1q_clifford.s_gate_circuits_nondeterministic(
final_measure=True)
targets = ref_1q_clifford.s_gate_counts_nondeterministic(shots)
@ -140,7 +140,7 @@ class QasmCliffordTests:
self.compare_counts(result, circuits, targets, delta=0)
def test_sdg_gate_nondeterministic_default_basis_gates(self):
shots = 2000
shots = 4000
"""Test sdg-gate circuits compiling to backend default basis_gates."""
circuits = ref_1q_clifford.sdg_gate_circuits_nondeterministic(
final_measure=True)
@ -166,7 +166,7 @@ class QasmCliffordTests:
def test_cx_gate_nondeterministic_default_basis_gates(self):
"""Test cx-gate circuits compiling to backend default basis_gates."""
shots = 2000
shots = 4000
circuits = ref_2q_clifford.cx_gate_circuits_nondeterministic(
final_measure=True)
targets = ref_2q_clifford.cx_gate_counts_nondeterministic(shots)
@ -191,7 +191,7 @@ class QasmCliffordTests:
def test_cz_gate_nondeterministic_default_basis_gates(self):
"""Test cz-gate circuits compiling to backend default basis_gates."""
shots = 2000
shots = 4000
circuits = ref_2q_clifford.cz_gate_circuits_nondeterministic(
final_measure=True)
targets = ref_2q_clifford.cz_gate_counts_nondeterministic(shots)
@ -216,7 +216,7 @@ class QasmCliffordTests:
def test_swap_gate_nondeterministic_default_basis_gates(self):
"""Test swap-gate circuits compiling to backend default basis_gates."""
shots = 2000
shots = 4000
circuits = ref_2q_clifford.swap_gate_circuits_nondeterministic(
final_measure=True)
targets = ref_2q_clifford.swap_gate_counts_nondeterministic(shots)
@ -252,7 +252,7 @@ class QasmCliffordTestsWaltzBasis:
def test_h_gate_nondeterministic_waltz_basis_gates(self):
"""Test h-gate gate circuits compiling to u1,u2,u3,cx"""
shots = 2000
shots = 4000
circuits = ref_1q_clifford.h_gate_circuits_nondeterministic(
final_measure=True)
targets = ref_1q_clifford.h_gate_counts_nondeterministic(shots)
@ -363,7 +363,7 @@ class QasmCliffordTestsWaltzBasis:
def test_s_gate_nondeterministic_waltz_basis_gates(self):
"""Test s-gate gate circuits compiling to u1,u2,u3,cx"""
shots = 2000
shots = 4000
circuits = ref_1q_clifford.s_gate_circuits_nondeterministic(
final_measure=True)
targets = ref_1q_clifford.s_gate_counts_nondeterministic(shots)
@ -396,7 +396,7 @@ class QasmCliffordTestsWaltzBasis:
def test_sdg_gate_nondeterministic_waltz_basis_gates(self):
"""Test sdg-gate gate circuits compiling to u1,u2,u3,cx"""
shots = 2000
shots = 4000
circuits = ref_1q_clifford.sdg_gate_circuits_nondeterministic(
final_measure=True)
targets = ref_1q_clifford.sdg_gate_counts_nondeterministic(shots)
@ -429,7 +429,7 @@ class QasmCliffordTestsWaltzBasis:
def test_cx_gate_nondeterministic_waltz_basis_gates(self):
"""Test cx-gate gate circuits compiling to u1,u2,u3,cx"""
shots = 2000
shots = 4000
circuits = ref_2q_clifford.cx_gate_circuits_nondeterministic(
final_measure=True)
targets = ref_2q_clifford.cx_gate_counts_nondeterministic(shots)
@ -462,7 +462,7 @@ class QasmCliffordTestsWaltzBasis:
def test_cz_gate_nondeterministic_waltz_basis_gates(self):
"""Test cz-gate gate circuits compiling to u1,u2,u3,cx"""
shots = 2000
shots = 4000
circuits = ref_2q_clifford.cz_gate_circuits_nondeterministic(
final_measure=True)
targets = ref_2q_clifford.cz_gate_counts_nondeterministic(shots)
@ -495,7 +495,7 @@ class QasmCliffordTestsWaltzBasis:
def test_swap_gate_nondeterministic_waltz_basis_gates(self):
"""Test swap-gate gate circuits compiling to u1,u2,u3,cx"""
shots = 2000
shots = 4000
circuits = ref_2q_clifford.swap_gate_circuits_nondeterministic(
final_measure=True)
targets = ref_2q_clifford.swap_gate_counts_nondeterministic(shots)
@ -533,7 +533,7 @@ class QasmCliffordTestsMinimalBasis:
def test_h_gate_nondeterministic_minimal_basis_gates(self):
"""Test h-gate gate circuits compiling to u3,cx"""
shots = 2000
shots = 4000
circuits = ref_1q_clifford.h_gate_circuits_nondeterministic(
final_measure=True)
targets = ref_1q_clifford.h_gate_counts_nondeterministic(shots)
@ -608,7 +608,7 @@ class QasmCliffordTestsMinimalBasis:
def test_s_gate_nondeterministic_minimal_basis_gates(self):
"""Test s-gate gate circuits compiling to u3,cx"""
shots = 2000
shots = 4000
circuits = ref_1q_clifford.s_gate_circuits_nondeterministic(
final_measure=True)
targets = ref_1q_clifford.s_gate_counts_nondeterministic(shots)
@ -635,7 +635,7 @@ class QasmCliffordTestsMinimalBasis:
def test_sdg_gate_nondeterministic_minimal_basis_gates(self):
"""Test sdg-gate gate circuits compiling to u3,cx"""
shots = 2000
shots = 4000
circuits = ref_1q_clifford.sdg_gate_circuits_nondeterministic(
final_measure=True)
targets = ref_1q_clifford.sdg_gate_counts_nondeterministic(shots)
@ -662,7 +662,7 @@ class QasmCliffordTestsMinimalBasis:
def test_cx_gate_nondeterministic_minimal_basis_gates(self):
"""Test cx-gate gate circuits compiling to u3,cx"""
shots = 2000
shots = 4000
circuits = ref_2q_clifford.cx_gate_circuits_nondeterministic(
final_measure=True)
targets = ref_2q_clifford.cx_gate_counts_nondeterministic(shots)
@ -689,7 +689,7 @@ class QasmCliffordTestsMinimalBasis:
def test_cz_gate_nondeterministic_minimal_basis_gates(self):
"""Test cz-gate gate circuits compiling to u3,cx"""
shots = 2000
shots = 4000
circuits = ref_2q_clifford.cz_gate_circuits_nondeterministic(
final_measure=True)
targets = ref_2q_clifford.cz_gate_counts_nondeterministic(shots)
@ -716,7 +716,7 @@ class QasmCliffordTestsMinimalBasis:
def test_swap_gate_nondeterministic_minimal_basis_gates(self):
"""Test swap-gate gate circuits compiling to u3,cx"""
shots = 2000
shots = 4000
circuits = ref_2q_clifford.swap_gate_circuits_nondeterministic(
final_measure=True)
targets = ref_2q_clifford.swap_gate_counts_nondeterministic(shots)
@ -742,7 +742,7 @@ class QasmCliffordTestsMinimalBasis:
def test_multiplexer_cx_gate_nondeterministic_default_basis_gates(self):
"""Test cx-gate circuits compiling to backend default basis_gates."""
shots = 2000
shots = 4000
circuits = ref_2q_clifford.multiplexer_cx_gate_circuits_nondeterministic(
final_measure=True)
targets = ref_2q_clifford.multiplexer_cx_gate_counts_nondeterministic(shots)

View File

@ -72,7 +72,7 @@ class QasmInitializeTests:
"""Test QasmSimulator initialize"""
# For statevector output we can combine deterministic and non-deterministic
# count output circuits
shots = 2000
shots = 4000
circuits = ref_initialize.initialize_circuits_1(final_measure=True)
targets = ref_initialize.initialize_counts_1(shots)
qobj = assemble(circuits, self.SIMULATOR, shots=shots)
@ -85,7 +85,7 @@ class QasmInitializeTests:
"""Test QasmSimulator initializes"""
# For statevector output we can combine deterministic and non-deterministic
# count output circuits
shots = 2000
shots = 4000
circuits = ref_initialize.initialize_circuits_2(final_measure=True)
targets = ref_initialize.initialize_counts_2(shots)
qobj = assemble(circuits, self.SIMULATOR, shots=shots)
@ -96,7 +96,7 @@ class QasmInitializeTests:
def test_initialize_sampling_opt(self):
"""Test sampling optimization"""
shots = 2000
shots = 4000
circuits = ref_initialize.initialize_sampling_optimization()
targets = ref_initialize.initialize_counts_sampling_optimization(shots)
qobj = assemble(circuits, self.SIMULATOR, shots=shots)

View File

@ -61,7 +61,7 @@ class QasmMeasureTests:
def test_measure_nondeterministic_with_sampling(self):
"""Test QasmSimulator measure with non-deterministic counts with sampling"""
shots = 2000
shots = 4000
circuits = ref_measure.measure_circuits_nondeterministic(
allow_sampling=True)
targets = ref_measure.measure_counts_nondeterministic(shots)
@ -77,7 +77,7 @@ class QasmMeasureTests:
def test_measure_nondeterministic_without_sampling(self):
"""Test QasmSimulator measure with nin-deterministic counts without sampling"""
shots = 2000
shots = 4000
circuits = ref_measure.measure_circuits_nondeterministic(
allow_sampling=False)
targets = ref_measure.measure_counts_nondeterministic(shots)
@ -172,7 +172,7 @@ class QasmMultiQubitMeasureTests:
def test_measure_nondeterministic_multi_qubit_with_sampling(self):
"""Test QasmSimulator measure with non-deterministic counts"""
shots = 2000
shots = 4000
circuits = ref_measure.multiqubit_measure_circuits_nondeterministic(
allow_sampling=True)
targets = ref_measure.multiqubit_measure_counts_nondeterministic(shots)
@ -185,7 +185,7 @@ class QasmMultiQubitMeasureTests:
def test_measure_nondeterministic_multi_qubit_without_sampling(self):
"""Test QasmSimulator measure with non-deterministic counts"""
shots = 2000
shots = 4000
circuits = ref_measure.multiqubit_measure_circuits_nondeterministic(
allow_sampling=False)
targets = ref_measure.multiqubit_measure_counts_nondeterministic(shots)

View File

@ -32,7 +32,7 @@ class QasmReadoutNoiseTests:
"""Test simulation with classical readout error noise model."""
# For statevector output we can combine deterministic and non-deterministic
# count output circuits
shots = 2000
shots = 4000
circuits = ref_readout_noise.readout_error_circuits()
noise_models = ref_readout_noise.readout_error_noise_models()
targets = ref_readout_noise.readout_error_counts(shots)
@ -56,7 +56,7 @@ class QasmPauliNoiseTests:
def test_pauli_gate_noise(self):
"""Test simulation with Pauli gate error noise model."""
shots = 2000
shots = 4000
circuits = ref_pauli_noise.pauli_gate_error_circuits()
noise_models = ref_pauli_noise.pauli_gate_error_noise_models()
targets = ref_pauli_noise.pauli_gate_error_counts(shots)
@ -73,7 +73,7 @@ class QasmPauliNoiseTests:
def test_pauli_reset_noise(self):
"""Test simulation with Pauli reset error noise model."""
shots = 2000
shots = 4000
circuits = ref_pauli_noise.pauli_reset_error_circuits()
noise_models = ref_pauli_noise.pauli_reset_error_noise_models()
targets = ref_pauli_noise.pauli_reset_error_counts(shots)
@ -90,7 +90,7 @@ class QasmPauliNoiseTests:
def test_pauli_measure_noise(self):
"""Test simulation with Pauli measure error noise model."""
shots = 2000
shots = 4000
circuits = ref_pauli_noise.pauli_measure_error_circuits()
noise_models = ref_pauli_noise.pauli_measure_error_noise_models()
targets = ref_pauli_noise.pauli_measure_error_counts(shots)
@ -114,7 +114,7 @@ class QasmResetNoiseTests:
def test_reset_gate_noise(self):
"""Test simulation with reset gate error noise model."""
shots = 2000
shots = 4000
circuits = ref_reset_noise.reset_gate_error_circuits()
noise_models = ref_reset_noise.reset_gate_error_noise_models()
targets = ref_reset_noise.reset_gate_error_counts(shots)
@ -138,7 +138,7 @@ class QasmKrausNoiseTests:
def test_kraus_gate_noise(self):
"""Test simulation with Kraus gate error noise model."""
shots = 2000
shots = 4000
circuits = ref_kraus_noise.kraus_gate_error_circuits()
noise_models = ref_kraus_noise.kraus_gate_error_noise_models()
targets = ref_kraus_noise.kraus_gate_error_counts(shots)

View File

@ -40,7 +40,7 @@ class QasmNonCliffordTests:
def test_t_gate_nondeterministic_default_basis_gates(self):
"""Test t-gate circuits compiling to backend default basis_gates."""
shots = 2000
shots = 4000
circuits = ref_non_clifford.t_gate_circuits_nondeterministic(
final_measure=True)
targets = ref_non_clifford.t_gate_counts_nondeterministic(shots)
@ -65,7 +65,7 @@ class QasmNonCliffordTests:
def test_tdg_gate_nondeterministic_default_basis_gates(self):
"""Test tdg-gate circuits compiling to backend default basis_gates."""
shots = 2000
shots = 4000
circuits = ref_non_clifford.tdg_gate_circuits_nondeterministic(
final_measure=True)
targets = ref_non_clifford.tdg_gate_counts_nondeterministic(shots)
@ -90,7 +90,7 @@ class QasmNonCliffordTests:
def test_ccx_gate_nondeterministic_default_basis_gates(self):
"""Test ccx-gate circuits compiling to backend default basis_gates."""
shots = 2000
shots = 4000
circuits = ref_non_clifford.ccx_gate_circuits_nondeterministic(
final_measure=True)
targets = ref_non_clifford.ccx_gate_counts_nondeterministic(shots)
@ -113,7 +113,7 @@ class QasmNonCliffordTests:
self.compare_counts(result, circuits, targets, delta=0)
def test_cswap_gate_nondeterministic_default_basis_gates(self):
shots = 2000
shots = 4000
circuits = ref_non_clifford.cswap_gate_circuits_nondeterministic(
final_measure=True)
targets = ref_non_clifford.cswap_gate_counts_nondeterministic(shots)
@ -127,7 +127,7 @@ class QasmNonCliffordTests:
# ---------------------------------------------------------------------
def test_cu1_gate_nondeterministic_default_basis_gates(self):
"""Test cu1-gate gate circuits compiling to default basis."""
shots = 2000
shots = 4000
circuits = ref_non_clifford.cu1_gate_circuits_nondeterministic(
final_measure=True)
targets = ref_non_clifford.cu1_gate_counts_nondeterministic(shots)
@ -176,7 +176,7 @@ class QasmNonCliffordTestsWaltzBasis:
def test_t_gate_nondeterministic_waltz_basis_gates(self):
"""Test t-gate gate circuits compiling to u1,u2,u3,cx"""
shots = 2000
shots = 4000
circuits = ref_non_clifford.t_gate_circuits_nondeterministic(
final_measure=True)
targets = ref_non_clifford.t_gate_counts_nondeterministic(shots)
@ -207,7 +207,7 @@ class QasmNonCliffordTestsWaltzBasis:
def test_tdg_gate_nondeterministic_waltz_basis_gates(self):
"""Test tdg-gate gate circuits compiling to u1,u2,u3,cx"""
shots = 2000
shots = 4000
circuits = ref_non_clifford.tdg_gate_circuits_nondeterministic(
final_measure=True)
targets = ref_non_clifford.tdg_gate_counts_nondeterministic(shots)
@ -238,7 +238,7 @@ class QasmNonCliffordTestsWaltzBasis:
def test_ccx_gate_nondeterministic_waltz_basis_gates(self):
"""Test ccx-gate gate circuits compiling to u1,u2,u3,cx"""
shots = 2000
shots = 4000
circuits = ref_non_clifford.ccx_gate_circuits_nondeterministic(
final_measure=True)
targets = ref_non_clifford.ccx_gate_counts_nondeterministic(shots)
@ -269,7 +269,7 @@ class QasmNonCliffordTestsWaltzBasis:
def test_cswap_gate_nondeterministic_waltz_basis_gates(self):
"""Test cswap-gate gate circuits compiling to u1,u2,u3,cx"""
shots = 2000
shots = 4000
circuits = ref_non_clifford.cswap_gate_circuits_nondeterministic(
final_measure=True)
targets = ref_non_clifford.cswap_gate_counts_nondeterministic(shots)
@ -286,7 +286,7 @@ class QasmNonCliffordTestsWaltzBasis:
# ---------------------------------------------------------------------
def test_cu1_gate_nondeterministic_waltz_basis_gates(self):
"""Test cu1-gate gate circuits compiling to u1,u2,u3,cx"""
shots = 2000
shots = 4000
circuits = ref_non_clifford.cu1_gate_circuits_nondeterministic(
final_measure=True)
targets = ref_non_clifford.cu1_gate_counts_nondeterministic(shots)
@ -341,7 +341,7 @@ class QasmNonCliffordTestsMinimalBasis:
def test_t_gate_nondeterministic_minimal_basis_gates(self):
"""Test t-gate gate circuits compiling to u3,cx"""
shots = 2000
shots = 4000
circuits = ref_non_clifford.t_gate_circuits_nondeterministic(
final_measure=True)
targets = ref_non_clifford.t_gate_counts_nondeterministic(shots)
@ -372,7 +372,7 @@ class QasmNonCliffordTestsMinimalBasis:
def test_tdg_gate_nondeterministic_minimal_basis_gates(self):
"""Test tdg-gate gate circuits compiling to u3,cx"""
shots = 2000
shots = 4000
circuits = ref_non_clifford.tdg_gate_circuits_nondeterministic(
final_measure=True)
targets = ref_non_clifford.tdg_gate_counts_nondeterministic(shots)
@ -403,7 +403,7 @@ class QasmNonCliffordTestsMinimalBasis:
def test_ccx_gate_nondeterministic_minimal_basis_gates(self):
"""Test ccx-gate gate circuits compiling to u3,cx"""
shots = 2000
shots = 4000
circuits = ref_non_clifford.ccx_gate_circuits_nondeterministic(
final_measure=True)
targets = ref_non_clifford.ccx_gate_counts_nondeterministic(shots)
@ -420,7 +420,7 @@ class QasmNonCliffordTestsMinimalBasis:
# ---------------------------------------------------------------------
def test_cu1_gate_nondeterministic_minimal_basis_gates(self):
"""Test cu1-gate gate circuits compiling to u3,cx"""
shots = 2000
shots = 4000
circuits = ref_non_clifford.cu1_gate_circuits_nondeterministic(
final_measure=True)
targets = ref_non_clifford.cu1_gate_counts_nondeterministic(shots)
@ -449,7 +449,7 @@ class QasmNonCliffordTestsMinimalBasis:
def test_multiplexer_cxx_gate_nondeterministic_default_basis_gates(self):
"""Test ccx-gate gate circuits """
shots = 2000
shots = 4000
circuits = ref_non_clifford.multiplexer_ccx_gate_circuits_nondeterministic(
final_measure=True)
targets = ref_non_clifford.multiplexer_ccx_gate_counts_nondeterministic(
@ -478,7 +478,7 @@ class QasmNonCliffordTestsMinimalBasis:
def test_cswap_gate_nondeterministic_minimal_basis_gates(self):
"""Test cswap-gate gate circuits compiling to u3,cx"""
shots = 2000
shots = 4000
circuits = ref_non_clifford.cswap_gate_circuits_nondeterministic(
final_measure=True)
targets = ref_non_clifford.cswap_gate_counts_nondeterministic(shots)

View File

@ -44,7 +44,7 @@ class QasmResetTests:
"""Test QasmSimulator reset with for circuits with non-deterministic counts"""
# For statevector output we can combine deterministic and non-deterministic
# count output circuits
shots = 2000
shots = 4000
circuits = ref_reset.reset_circuits_nondeterministic(
final_measure=True)
targets = ref_reset.reset_counts_nondeterministic(shots)
@ -56,7 +56,7 @@ class QasmResetTests:
def test_reset_sampling_opt(self):
"""Test sampling optimization"""
shots = 2000
shots = 4000
circuits = ref_reset.reset_circuits_sampling_optimization()
targets = ref_reset.reset_counts_sampling_optimization(shots)
qobj = assemble(circuits, self.SIMULATOR, shots=shots)

View File

@ -44,7 +44,7 @@ class QasmUnitaryGateTests:
def test_random_unitary_gate(self):
"""Test simulation with random unitary gate circuit instructions."""
shots = 2000
shots = 4000
circuits = ref_unitary_gate.unitary_random_gate_circuits_nondeterministic(final_measure=True)
targets = ref_unitary_gate.unitary_random_gate_counts_nondeterministic(shots)
result = execute(circuits, self.SIMULATOR, shots=shots).result()

View File

@ -64,7 +64,7 @@ class TestQasmExtendedStabilizerSimulator(common.QiskitAerTestCase):
"""Test ExtendedStabilizer reset with for circuits with non-deterministic counts"""
# For statevector output we can combine deterministic and non-deterministic
# count output circuits
shots = 2000
shots = 4000
circuits = ref_reset.reset_circuits_nondeterministic(
final_measure=True)
qobj = assemble(circuits, QasmSimulator(), shots=shots)
@ -103,7 +103,7 @@ class TestQasmExtendedStabilizerSimulator(common.QiskitAerTestCase):
def test_measure_nondeterministic_with_sampling(self):
"""Test CHimulator measure with non-deterministic counts with sampling"""
shots = 2000
shots = 4000
circuits = ref_measure.measure_circuits_nondeterministic(
allow_sampling=True)
qobj = assemble(circuits, QasmSimulator(), shots=shots)
@ -115,7 +115,7 @@ class TestQasmExtendedStabilizerSimulator(common.QiskitAerTestCase):
def test_measure_nondeterministic_without_sampling(self):
"""Test CHimulator measure with non-deterministic counts without sampling"""
shots = 2000
shots = 4000
circuits = ref_measure.measure_circuits_nondeterministic(
allow_sampling=False)
qobj = assemble(circuits, QasmSimulator(), shots=shots)
@ -154,7 +154,7 @@ class TestQasmExtendedStabilizerSimulator(common.QiskitAerTestCase):
def test_measure_nondeterministic_multi_qubit_with_sampling(self):
"""Test CHimulator reset with non-deterministic counts"""
shots = 2000
shots = 4000
circuits = ref_measure.multiqubit_measure_circuits_nondeterministic(
allow_sampling=True)
targets = ref_measure.multiqubit_measure_counts_nondeterministic(shots)
@ -166,7 +166,7 @@ class TestQasmExtendedStabilizerSimulator(common.QiskitAerTestCase):
def test_measure_nondeterministic_multi_qubit_without_sampling(self):
"""Test CHimulator reset with non-deterministic counts"""
shots = 2000
shots = 4000
circuits = ref_measure.multiqubit_measure_circuits_nondeterministic(
allow_sampling=False)
targets = ref_measure.multiqubit_measure_counts_nondeterministic(shots)
@ -220,7 +220,7 @@ class TestQasmExtendedStabilizerSimulator(common.QiskitAerTestCase):
def test_h_gate_nondeterministic_default_basis_gates(self):
"""Test h-gate circuits compiling to backend default basis_gates."""
shots = 2000
shots = 4000
circuits = ref_1q_clifford.h_gate_circuits_nondeterministic(
final_measure=True)
qobj = assemble(circuits, QasmSimulator(), shots=shots)
@ -292,7 +292,7 @@ class TestQasmExtendedStabilizerSimulator(common.QiskitAerTestCase):
def test_s_gate_nondeterministic_default_basis_gates(self):
"""Test s-gate circuits compiling to backend default basis_gates."""
shots = 2000
shots = 4000
circuits = ref_1q_clifford.s_gate_circuits_nondeterministic(
final_measure=True)
qobj = assemble(circuits, QasmSimulator(), shots=shots)
@ -318,7 +318,7 @@ class TestQasmExtendedStabilizerSimulator(common.QiskitAerTestCase):
self.compare_counts(result, circuits, targets, delta=0)
def test_sdg_gate_nondeterministic_default_basis_gates(self):
shots = 2000
shots = 4000
"""Test sdg-gate circuits compiling to backend default basis_gates."""
circuits = ref_1q_clifford.sdg_gate_circuits_nondeterministic(
final_measure=True)
@ -346,7 +346,7 @@ class TestQasmExtendedStabilizerSimulator(common.QiskitAerTestCase):
def test_cx_gate_nondeterministic_default_basis_gates(self):
"""Test cx-gate circuits compiling to backend default basis_gates."""
shots = 2000
shots = 4000
circuits = ref_2q_clifford.cx_gate_circuits_nondeterministic(
final_measure=True)
qobj = assemble(circuits, QasmSimulator(), shots=shots)
@ -373,7 +373,7 @@ class TestQasmExtendedStabilizerSimulator(common.QiskitAerTestCase):
def test_cz_gate_nondeterministic_default_basis_gates(self):
"""Test cz-gate circuits compiling to backend default basis_gates."""
shots = 2000
shots = 4000
circuits = ref_2q_clifford.cz_gate_circuits_nondeterministic(
final_measure=True)
qobj = assemble(circuits, QasmSimulator(), shots=shots)
@ -400,7 +400,7 @@ class TestQasmExtendedStabilizerSimulator(common.QiskitAerTestCase):
def test_swap_gate_nondeterministic_default_basis_gates(self):
"""Test swap-gate circuits compiling to backend default basis_gates."""
shots = 2000
shots = 4000
circuits = ref_2q_clifford.swap_gate_circuits_nondeterministic(
final_measure=True)
qobj = assemble(circuits, QasmSimulator(), shots=shots)

View File

@ -45,7 +45,7 @@ class TestNoise(common.QiskitAerTestCase):
circuit.i(qr)
circuit.barrier(qr)
circuit.measure(qr, cr)
shots = 2000
shots = 4000
backend = QasmSimulator()
# test noise model
error = amplitude_damping_error(0.75, 0.25)

View File

@ -1,23 +0,0 @@
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

File diff suppressed because it is too large Load Diff

View File

@ -435,7 +435,7 @@ def model_and_pi_schedule():
if __name__ == '__main__':
# Run qasm simulator
shots = 2000
shots = 4000
circuits = grovers_circuit(final_measure=True, allow_sampling=True)
targets = [{'0x0': 5 * shots / 8, '0x1': shots / 8,
'0x2': shots / 8, '0x3': shots / 8}]