Commit 36b97845 authored by Amir Ebrahimi's avatar Amir Ebrahimi
Browse files

Add basic support for argparse

parent ca1f9205
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -49,6 +49,24 @@ if(GIT_FOUND)
  message( STATUS "QCOR Version / HEAD commit hash: ${QCOR_BUILD_VERSION}")
endif()

if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git" AND NOT EXISTS "${CMAKE_SOURCE_DIR}/tpls/argparse/CMakeLists.txt")
    # Update submodules as needed
    option(GIT_SUBMODULE "Check submodules during build" ON)
    if(GIT_SUBMODULE)
        message(STATUS "Submodule update")
        execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
                        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 failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
        endif()
    endif()
endif()

if(NOT EXISTS "${CMAKE_SOURCE_DIR}/tpls/argparse/CMakeLists.txt")
    message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
endif()

find_package(XACC REQUIRED)
find_package(Clang 10.0.0 REQUIRED)

@@ -56,6 +74,7 @@ configure_file("${CMAKE_SOURCE_DIR}/cmake/qcor_config.hpp.in"
               "${CMAKE_BINARY_DIR}/qcor_config.hpp")
install (FILES ${CMAKE_BINARY_DIR}/qcor_config.hpp DESTINATION include/qcor)

add_subdirectory(tpls)
add_subdirectory(handlers)
add_subdirectory(runtime)
add_subdirectory(tools)
+2 −2
Original line number Diff line number Diff line
@@ -4,9 +4,9 @@ file(GLOB SRC *.cpp)

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

target_include_directories(${LIBRARY_NAME} PUBLIC . ${CMAKE_BINARY_DIR} ${XACC_ROOT}/include/eigen)
target_include_directories(${LIBRARY_NAME} PUBLIC . ${CMAKE_BINARY_DIR} ${XACC_ROOT}/include/eigen ${XACC_ROOT}/include/argparse)

target_link_libraries(${LIBRARY_NAME} PUBLIC xacc::xacc xacc::quantum_gate xacc::pauli)
target_link_libraries(${LIBRARY_NAME} PUBLIC xacc::xacc xacc::quantum_gate xacc::pauli argparse::argparse)

if(APPLE)
  set_target_properties(${LIBRARY_NAME}
+5 −1
Original line number Diff line number Diff line
#pragma once

#include <argparse.hpp>
#include <Eigen/Dense>
#include <functional>
#include <future>
@@ -21,7 +22,10 @@ namespace constants {
static constexpr double pi = 3.141592653589793238;
}

// Typedefs mapping xacc types to qcor types
// Expose argparse
using ArgumentParser = argparse::ArgumentParser;

// Typedefs mapping xacc/Eigen types to qcor types
using CompositeInstruction = xacc::CompositeInstruction;
using HeterogeneousMap = xacc::HeterogeneousMap;
using IRTransformation = xacc::IRTransformation;
+2 −1
Original line number Diff line number Diff line
@@ -54,7 +54,8 @@ std::unique_ptr<clang::CodeGenAction> emit_llvm_ir(
  std::vector<std::string> base_includes{
      "-I@XACC_ROOT@/include/xacc", "-I@XACC_ROOT@/include/pybind11/include",
      "-I@CMAKE_INSTALL_PREFIX@/include/qcor",
      "-I@XACC_ROOT@/include/quantum/gate", "-I@XACC_ROOT@/include/eigen"
      "-I@XACC_ROOT@/include/quantum/gate", "-I@XACC_ROOT@/include/eigen",
      "-I@XACC_ROOT@/include/argparse"
      };
  for (auto extra : extra_headers) {
    base_includes.push_back(extra);
+1 −1
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ def main(argv=None):
    if '@CMAKE_SYSTEM_NAME@' != 'Darwin':
        baseLibs += ['-lqir-qrt']
        
    baseIncludes = ['-I', '@XACC_ROOT@/include/xacc', '-I', '@CMAKE_INSTALL_PREFIX@/include/qcor', '-I', '@XACC_ROOT@/include/quantum/gate', '-I', '@XACC_ROOT@/include/eigen']
    baseIncludes = ['-I', '@XACC_ROOT@/include/xacc', '-I', '@CMAKE_INSTALL_PREFIX@/include/qcor', '-I', '@XACC_ROOT@/include/quantum/gate', '-I', '@XACC_ROOT@/include/eigen', '-I', '@XACC_ROOT@/include/argparse']
    defaultFlags = ['-std=c++17', '-fplugin=@CMAKE_INSTALL_PREFIX@/clang-plugins/libqcor-syntax-handler@CMAKE_SHARED_LIBRARY_SUFFIX@']

    extra_headers = '@QCOR_EXTRA_HEADERS@'.replace('"','')
Loading