mirror of https://github.com/intel/intel-qs.git
Solve compilation issues
In particular, a few source files where not included in the static library 'intel_qs'. The static-library name was reverted from iqs to the original intel_qs. Unit test based on googletest is added to the new cmake process.
This commit is contained in:
parent
543b94d0ed
commit
0044b6a49a
118
CMakeLists.txt
118
CMakeLists.txt
|
@ -1,4 +1,4 @@
|
|||
cmake_minimum_required(VERSION 3.10)
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
|
||||
################################################################################
|
||||
# Define our package information.
|
||||
|
@ -14,7 +14,7 @@ set(PACKAGE_DESCRIPTION
|
|||
set(PACKAGE_AUTHOR "Intel Corporation")
|
||||
set(PACKAGE_AUTHOR_EMAIL "AQUA, QAPG and IAGS Groups at Intel Corporation")
|
||||
|
||||
project(IQS)
|
||||
project(intel_qs CXX)
|
||||
|
||||
# Out-of-source builds only
|
||||
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
|
||||
|
@ -62,8 +62,6 @@ if(IqsMPI)
|
|||
|
||||
if(IqsUtest)
|
||||
message(STATUS "UnitTest tested for compatibility with MPI.")
|
||||
# message(STATUS "UnitTest not compatible with MPI: disabled.")
|
||||
# set(IqsUtest OFF)
|
||||
endif()
|
||||
|
||||
find_package(MPI REQUIRED)
|
||||
|
@ -163,9 +161,9 @@ if (IqsMKL)
|
|||
endif()
|
||||
endif() # for the MKL configuration
|
||||
|
||||
############################################################################
|
||||
# Ad-hoc modifications to include the libraries needed by VSL random number generators.
|
||||
############################################################################
|
||||
############################################################################
|
||||
# Ad-hoc modifications to include the libraries needed by VSL random number generators.
|
||||
############################################################################
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
||||
# Ad-hoc modifications to compile and link with g++.
|
||||
|
@ -241,8 +239,6 @@ add_compile_definitions(USE_MM_MALLOC)
|
|||
# List the object files that will be contained in the statically linked
|
||||
# library archive. Also, place the archive in the lib subdir.
|
||||
################################################################################
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY lib)
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY lib)
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
|
@ -250,40 +246,6 @@ if(BuildExamples)
|
|||
add_subdirectory(examples)
|
||||
endif()
|
||||
|
||||
|
||||
#include_directories(${PROJECT_SOURCE_DIR}/include)
|
||||
|
||||
#add_library(intel_qs SHARED
|
||||
# src/interface_api_memory.cpp
|
||||
# src/interface_api_qasm.cpp
|
||||
# src/interface_api_qubitid.cpp
|
||||
# src/interface_api_version.cpp
|
||||
# src/highperfkernels.cpp
|
||||
# src/qureg_apply1qubitgate.cpp
|
||||
# src/qureg_apply2qubitgate.cpp
|
||||
# src/qureg_applyctrl1qubitgate.cpp
|
||||
# src/qureg_applydiag.cpp
|
||||
# src/qureg_applyswap.cpp
|
||||
# src/qureg_applytoffoli.cpp
|
||||
# src/qureg_expectval.cpp
|
||||
# src/qureg_fusion.cpp
|
||||
# src/qureg_init.cpp
|
||||
# src/qureg_measure.cpp
|
||||
# src/qureg_noisysimul.cpp
|
||||
# src/qureg_permute.cpp
|
||||
# src/qureg_utils.cpp
|
||||
# src/qureg_version.cpp
|
||||
# src/mpi_env.cpp
|
||||
# src/mpi_exception.cpp
|
||||
# src/utils.cpp
|
||||
# src/rng_utils.cpp
|
||||
#)
|
||||
|
||||
#set_target_properties(intel_qs PROPERTIES POSITION_INDEPENDENT_CODE 1)
|
||||
|
||||
|
||||
#target_include_directories(intel_qs INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
|
||||
|
||||
# INFO: when below flag is defined, checks of the form "assert(condition)" are skipped.
|
||||
#target_compile_definitions(intel_qs NDEBUG)
|
||||
|
||||
|
@ -322,24 +284,6 @@ endif()
|
|||
# add_executable(get_started_with_noisy_IQS.exe tutorials/get_started_with_noisy_IQS.cpp)
|
||||
# target_link_libraries(get_started_with_noisy_IQS.exe intel_qs)
|
||||
|
||||
# add_executable(benchgates.exe examples/benchgates.cpp)
|
||||
# target_link_libraries(benchgates.exe intel_qs)
|
||||
|
||||
# add_executable(quantum_fourier_transform.exe examples/quantum_fourier_transform.cpp)
|
||||
# target_link_libraries(quantum_fourier_transform.exe intel_qs)
|
||||
|
||||
# add_executable(expect_value_test.exe examples/expect_value_test.cpp)
|
||||
# target_link_libraries(expect_value_test.exe intel_qs)
|
||||
|
||||
# add_executable(heisenberg_dynamics.exe examples/heisenberg_dynamics.cpp)
|
||||
# target_link_libraries(heisenberg_dynamics.exe intel_qs)
|
||||
|
||||
# add_executable(noisy_circuit_test.exe examples/noisy_circuit_test.cpp)
|
||||
# target_link_libraries(noisy_circuit_test.exe intel_qs)
|
||||
|
||||
# add_executable(test_of_custom_gates.exe examples/test_of_custom_gates.cpp)
|
||||
# target_link_libraries(test_of_custom_gates.exe intel_qs)
|
||||
|
||||
# add_executable(basic_code_for_scaling.exe benchmarks/basic_code_for_scaling.cpp)
|
||||
# target_link_libraries(basic_code_for_scaling.exe intel_qs)
|
||||
#endif()
|
||||
|
@ -359,55 +303,15 @@ endif()
|
|||
# https://github.com/google/googletest/blob/master/googletest/README.md
|
||||
################################################################################
|
||||
|
||||
# Only download GoogleTest if asked to do so for unit testing purposes.
|
||||
#if (IqsUtest)
|
||||
|
||||
# Download and unpack googletest at configure time
|
||||
# configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt)
|
||||
# execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
|
||||
# RESULT_VARIABLE result
|
||||
# WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
|
||||
# if(result)
|
||||
# message(FATAL_ERROR "CMake step for googletest failed: ${result}")
|
||||
# endif()
|
||||
# execute_process(COMMAND ${CMAKE_COMMAND} --build .
|
||||
# RESULT_VARIABLE result
|
||||
# WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
|
||||
# if(result)
|
||||
# message(FATAL_ERROR "Build step for googletest failed: ${result}")
|
||||
# endif()
|
||||
|
||||
# Prevent overriding the parent project's compiler/linker
|
||||
# settings on Windows
|
||||
# set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
||||
|
||||
# Add googletest directly to our build. This defines
|
||||
# the gtest and gtest_main targets.
|
||||
# add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src
|
||||
# ${CMAKE_CURRENT_BINARY_DIR}/googletest-build
|
||||
# EXCLUDE_FROM_ALL)
|
||||
|
||||
# The gtest/gtest_main targets carry header search path
|
||||
# dependencies automatically when using CMake 2.8.11 or
|
||||
# later. Otherwise we have to add them here ourselves.
|
||||
# if (CMAKE_VERSION VERSION_LESS 2.8.11)
|
||||
# include_directories("${gtest_SOURCE_DIR}/include")
|
||||
# endif()
|
||||
|
||||
#endif()
|
||||
|
||||
# Now simply link against gtest or gtest_main as needed. Eg
|
||||
if (NOT IqsUtest)
|
||||
message(STATUS "Unit test: disabled.")
|
||||
# Add the unit test contained in /unit_test
|
||||
# If required, googletest framework is downloaded and configured.
|
||||
if (IqsUtest)
|
||||
message(STATUS "Unit test : enabled.")
|
||||
add_subdirectory(unit_test)
|
||||
else()
|
||||
message(STATUS "Unit test: enabled.")
|
||||
add_executable(utest unit_test/suite_of_tests.cpp
|
||||
src/qaoa_features.cpp)
|
||||
target_link_libraries(utest gtest_main intel_qs)
|
||||
#add_test(NAME utest_test COMMAND utest)
|
||||
message(STATUS "Unit test : disabled.")
|
||||
endif()
|
||||
|
||||
|
||||
################################################################################
|
||||
# If without MPI, build the Python library for the IQS wrapper.
|
||||
################################################################################
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
cmake_minimum_required(VERSION 3.12)
|
||||
project(iqs-examples)
|
||||
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||
|
||||
add_executable(benchgates.exe benchgates.cpp)
|
||||
include_directories(/home/fbaruffa/intel-qs/include)
|
||||
target_link_libraries(benchgates.exe iqs)
|
||||
target_link_libraries(benchgates.exe PRIVATE intel_qs)
|
||||
|
||||
#add_executable(quantum_fourier_transform.exe quantum_fourier_transform.cpp)
|
||||
#target_link_libraries(quantum_fourier_transform.exe iqs)
|
||||
|
@ -20,5 +18,9 @@ target_link_libraries(benchgates.exe iqs)
|
|||
#add_executable(test_of_custom_gates.exe test_of_custom_gates.cpp)
|
||||
#target_link_libraries(test_of_custom_gates.exe iqs)
|
||||
|
||||
set_target_properties( benchgates.exe
|
||||
PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin"
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
cmake_minimum_required(VERSION 3.12)
|
||||
project(iqs)
|
||||
|
||||
################################################################################
|
||||
# Set some compiler options related to C++.
|
||||
################################################################################
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
set(IQS_FILES
|
||||
interface_api_memory.cpp
|
||||
interface_api_qasm.cpp
|
||||
|
@ -27,14 +21,24 @@ set(IQS_FILES
|
|||
qureg_noisysimul.cpp
|
||||
qureg_permute.cpp
|
||||
qureg_utils.cpp
|
||||
qureg_version.cpp
|
||||
mpi_env.cpp
|
||||
mpi_exception.cpp
|
||||
utils.cpp
|
||||
rng_utils.cpp
|
||||
CACHE INTERNAL "" FORCE)
|
||||
|
||||
add_library(iqs SHARED ${IQS_FILES})
|
||||
add_library(iqstatic STATIC ${IQS_FILES})
|
||||
set_target_properties(iqs PROPERTIES POSITION_INDEPENDENT_CODE 1)
|
||||
|
||||
|
||||
|
||||
#add_library(iqs_shared SHARED ${IQS_FILES})
|
||||
#target_include_directories(iqs_shared PUBLIC ../include)
|
||||
|
||||
add_library(intel_qs STATIC ${IQS_FILES})
|
||||
target_include_directories(intel_qs PUBLIC ../include)
|
||||
|
||||
target_include_directories(intel_qs INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>)
|
||||
|
||||
set_target_properties(intel_qs
|
||||
PROPERTIES
|
||||
ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib"
|
||||
LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib"
|
||||
POSITION_INDEPENDENT_CODE 1
|
||||
)
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
include_directories(../include)
|
||||
|
||||
# Build the suite of unit-tests for the project.
|
||||
# Approach suggested in:
|
||||
# https://github.com/google/googletest/blob/master/googletest/README.md
|
||||
|
||||
# Download and unpack googletest at configure time.
|
||||
configure_file(../cmake/gtest.cmake.in googletest-download/CMakeLists.txt)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
|
||||
RESULT_VARIABLE result
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
|
||||
if(result)
|
||||
message(FATAL_ERROR "CMake step for googletest failed: ${result}")
|
||||
endif()
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} --build .
|
||||
RESULT_VARIABLE result
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
|
||||
if(result)
|
||||
message(FATAL_ERROR "Build step for googletest failed: ${result}")
|
||||
endif()
|
||||
|
||||
# Prevent overriding the parent project's compiler/linker settings on Windows.
|
||||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
||||
|
||||
# Add googletest directly to our build. This defines the gtest and gtest_main targets.
|
||||
add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src
|
||||
${CMAKE_CURRENT_BINARY_DIR}/googletest-build
|
||||
EXCLUDE_FROM_ALL)
|
||||
|
||||
################################################################################
|
||||
|
||||
# Link against gtest or gtest_main as needed.
|
||||
add_executable(utest suite_of_tests.cpp
|
||||
../src/qaoa_features.cpp)
|
||||
target_include_directories(utest PRIVATE include)
|
||||
target_link_libraries(utest PRIVATE intel_qs gtest_main)
|
||||
|
||||
set_target_properties( utest
|
||||
PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin"
|
||||
)
|
||||
|
||||
################################################################################
|
Loading…
Reference in New Issue