From f70d7514ccd61326853b5e8742572a61218ab88a Mon Sep 17 00:00:00 2001 From: Juan Gomez Date: Wed, 5 Sep 2018 16:03:32 +0200 Subject: [PATCH] * Better integration with OpenMP on different versions of CMake * Static building for BLAS --- CMakeLists.txt | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eca34ca1a..4cda5beda 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -121,8 +121,12 @@ if(NOT "${OpenMP_FOUND}" OR NOT "${OpenMP_CXX_FOUND}") include_directories("${BREW_LIBOMP_PREFIX}/include") message(STATUS "Using Homebrew libomp from ${BREW_LIBOMP_PREFIX}") - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") - set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") + # Create OpenMP::OpenMP_CXX target + add_library(OpenMP::OpenMP_CXX INTERFACE IMPORTED) + set_property(TARGET OpenMP::OpenMP_CXX PROPERTY + INTERFACE_LINK_LIBRARIES "${OpenMP_omp_LIBRARY}") message(STATUS "OpenMP found!") endif() else() @@ -135,6 +139,11 @@ endif() set(NLOHMANN_JSON_PATH ${AER_SIMULATOR_CPP_EXTERNAL_LIBS}) find_package(nlohmann_json REQUIRED) +if(STATIC_LINKING) + message(STATUS "Setting BLA_STATIC") + set(BLA_STATIC TRUE) + find_package(Threads) +endif() message(STATUS "Lookgin for OpenBLAS library...") set(BLA_VENDOR "OpenBLAS") find_package(BLAS QUIET) @@ -144,6 +153,12 @@ if(NOT BLAS_FOUND) find_package(BLAS REQUIRED) endif() +# Set dependent libraries +set(LIBRARIES + OpenMP::OpenMP_CXX + ${BLAS_LIBRARIES} + nlohmann_json + Threads::Threads) # Linter # This will add the linter as part of the compiling build target @@ -152,6 +167,7 @@ include(Linter) # Linking # Set dependent libraries set(AER_LIBRARIES + ${OpenMP_omp_LIBRARY} ${BLAS_LIBRARIES} nlohmann_json)