From 06c18a04195b892e18c4c523257f02236b52c9b2 Mon Sep 17 00:00:00 2001 From: Victor Villar <59838221+vvilpas@users.noreply.github.com> Date: Wed, 22 Jul 2020 15:19:52 +0200 Subject: [PATCH] Add BLAS_LIB_PATH as ENV var (#822) * AER_BLAS_LIB_PATH as env var * Update contributing guide --- CMakeLists.txt | 8 ++++++-- CONTRIBUTING.md | 12 +++++++----- cmake/conan_utils.cmake | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 922ea095f..5ca15da18 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,10 @@ project(qasm_simulator VERSION ${VERSION_NUM} LANGUAGES CXX C) list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) list(APPEND CMAKE_PREFIX_PATH ${CMAKE_SOURCE_DIR}/cmake) +if(NOT DEFINED AER_BLAS_LIB_PATH AND DEFINED ENV{AER_BLAS_LIB_PATH}) + set(AER_BLAS_LIB_PATH $ENV{AER_BLAS_LIB_PATH}) +endif() + # Warning: Because of a bug on CMake's FindBLAS or (it's not clear whoes fault is) # libopenblas.a for Ubuntu (maybe others) we need to copy the file: # cmake/FindBLAS.cmake.fix-static-linking, to the directory were CMake Modules are @@ -157,8 +161,8 @@ if(STATIC_LINKING) set(BLA_STATIC TRUE) endif() -if(BLAS_LIB_PATH) - find_BLAS_in_specific_path(${BLAS_LIB_PATH}) +if(AER_BLAS_LIB_PATH) + find_BLAS_in_specific_path(${AER_BLAS_LIB_PATH}) else() set(BLAS_LIBRARIES CONAN_PKG::openblas) endif() diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e75bbb66f..57bec62eb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -369,7 +369,7 @@ Because the standalone version of `Aer` doesn't need Python at all, the build sy based on CMake, just like most of other C++ projects. So in order to pass all the different options we have on `Aer` to CMake we use it's native mechanism: - qiskit-aer/out$ cmake -DCMAKE_CXX_COMPILER=g++-9 -DBLAS_LIB_PATH=/path/to/my/blas .. + qiskit-aer/out$ cmake -DCMAKE_CXX_COMPILER=g++-9 -DAER_BLAS_LIB_PATH=/path/to/my/blas .. ### macOS @@ -457,7 +457,7 @@ Because the standalone version of `Aer` doesn't need Python at all, the build sy based on CMake, just like most of other C++ projects. So in order to pass all the different options we have on `Aer` to CMake we use it's native mechanism: - qiskit-aer/out$ cmake -DCMAKE_CXX_COMPILER=g++-9 -DBLAS_LIB_PATH=/path/to/my/blas .. + qiskit-aer/out$ cmake -DCMAKE_CXX_COMPILER=g++-9 -DAER_BLAS_LIB_PATH=/path/to/my/blas .. @@ -552,7 +552,7 @@ Because the standalone version of `Aer` doesn't need Python at all, the build sy based on CMake, just like most of other C++ projects. So in order to pass all the different options we have on `Aer` to CMake we use it's native mechanism: - (QiskitDevEnv) qiskit-aer\out> cmake -G "Visual Studio 15 2017" -DBLAS_LIB_PATH=c:\path\to\my\blas .. + (QiskitDevEnv) qiskit-aer\out> cmake -G "Visual Studio 15 2017" -DAER_BLAS_LIB_PATH=c:\path\to\my\blas .. ### Building with GPU support @@ -622,14 +622,16 @@ These are the flags: Default: No value. Example: ``python ./setup.py bdist_wheel -- -DUSER_LIB_PATH=C:\path\to\openblas\libopenblas.so`` -* BLAS_LIB_PATH +* AER_BLAS_LIB_PATH Tells CMake the directory to look for the BLAS library instead of the usual paths. If no BLAS library is found under that directory, CMake will raise an error and stop. + + It can also be set as an ENV variable with the same name, although the flag takes precedence. Values: An absolute path. Default: No value. - Example: ``python ./setup.py bdist_wheel -- -DBLAS_LIB_PATH=/path/to/look/for/blas/`` + Example: ``python ./setup.py bdist_wheel -- -DAER_BLAS_LIB_PATH=/path/to/look/for/blas/`` * BUILD_TESTS diff --git a/cmake/conan_utils.cmake b/cmake/conan_utils.cmake index d5bc302d9..13391900b 100644 --- a/cmake/conan_utils.cmake +++ b/cmake/conan_utils.cmake @@ -26,7 +26,7 @@ macro(setup_conan) set(CONAN_OPTIONS ${CONAN_OPTIONS} "thrust:device_system=${THRUST_BACKEND}") endif() - if(NOT BLAS_LIB_PATH) + if(NOT AER_BLAS_LIB_PATH) set(REQUIREMENTS ${REQUIREMENTS} openblas/0.3.7) endif()