Commit 75169e22 authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

Setting up CMake build to add xacc-config.cmake to install prefix, enabling...

Setting up CMake build to add xacc-config.cmake to install prefix, enabling apps building off XACC to easily integrate into cmake builds
parent 9ade561a
......@@ -40,6 +40,7 @@ message(STATUS "C++ version ${CXX_STANDARD} configured.")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# Modify our CMAKE_MODULE_PATH
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules")
if (EXISTS ${CMAKE_SOURCE_DIR}/tpls/fire)
message(STATUS "Fire found in tpls")
......@@ -53,7 +54,7 @@ find_package(MPI REQUIRED)
# We require Boost
find_package(Boost COMPONENTS system program_options filesystem REQUIRED)
# Look for OpenMP
# Look for OpenMP, add it we find it
find_package(OpenMP)
if (OPENMP_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
......@@ -61,7 +62,7 @@ endif()
# Create a xacc config header file
configure_file("${CMAKE_SOURCE_DIR}/cmake/xacc_config.hpp.in" "${CMAKE_BINARY_DIR}/xacc_config.hpp")
install(FILES "${CMAKE_BINARY_DIR}/xacc_config.hpp" DESTINATION include)
install(FILES "${CMAKE_BINARY_DIR}/xacc_config.hpp" DESTINATION include/xacc)
# Include dirs that everyone will use
include_directories(${CMAKE_BINARY_DIR})
......@@ -82,3 +83,10 @@ add_subdirectory(quantum)
add_subdirectory(impls)
add_subdirectory(tools)
add_subdirectory(examples)
# Install the config file for external projects to use
# This is cool, users just add find_package(XACC REQUIRED) to
# their CMake builds, and pass -DXACC_DIR=/path/to/install/xacc
# and CMake loads include paths, libs, etc
install(FILES cmake/xacc-config.cmake DESTINATION .)
get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
set (XACC_ROOT "${SELF_DIR}")
set (XACC_INCLUDE_DIRS "${SELF_DIR}/include;${SELF_DIR}/include/xacc;${SELF_DIR}/include/quantum/gate;${SELF_DIR}/include/quantum/aqc")
set (XACC_LIBRARY_DIR "${SELF_DIR}/lib")
set (XACC_LIBRARIES "${SELF_DIR}/lib/libxacc-gate-ir.so")
\ No newline at end of file
......@@ -51,7 +51,7 @@ if (OPENSSL_FOUND)
target_link_libraries(${LIBRARY_NAME} ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} xacc-gate-ir)
install(FILES ${HEADERS} DESTINATION include)
#install(FILES ${HEADERS} DESTINATION include)
install(TARGETS ${LIBRARY_NAME} DESTINATION lib)
# Gather tests
......
......@@ -58,7 +58,7 @@ if (CLANG_FOUND AND LLVM_FOUND)
add_library(${LIBRARY_NAME} SHARED ${SRC})
install(FILES ${HEADERS} DESTINATION include)
#install(FILES ${HEADERS} DESTINATION include)
install(TARGETS ${LIBRARY_NAME} DESTINATION lib)
link_directories(${CLANG_LIBRARY_DIRS} ${LLVM_LIBRARY_DIRS})
......
......@@ -48,7 +48,7 @@ add_library(${LIBRARY_NAME} SHARED ${SRC})
target_link_libraries(${LIBRARY_NAME} ${Boost_LIBRARIES} xacc-gate-ir)
install(FILES ${HEADERS} DESTINATION include)
#install(FILES ${HEADERS} DESTINATION include)
install(TARGETS ${LIBRARY_NAME} DESTINATION lib)
# Gather tests
......
......@@ -37,7 +37,7 @@ file (GLOB SRC *.cpp)
add_library(${LIBRARY_NAME} SHARED ${SRC})
install(FILES ${HEADERS} DESTINATION include)
install(FILES ${HEADERS} DESTINATION include/quantum/aqc)
install(TARGETS ${LIBRARY_NAME} DESTINATION lib)
# Gather tests
......
......@@ -40,7 +40,7 @@ file (GLOB SRC *.cpp instructions/*.cpp functions/*.cpp)
add_library(${LIBRARY_NAME} SHARED ${SRC})
install(FILES ${HEADERS} DESTINATION include)
install(FILES ${HEADERS} DESTINATION include/quantum/gate)
install(TARGETS ${LIBRARY_NAME} DESTINATION lib)
# Gather tests
......
......@@ -174,6 +174,7 @@ public:
subInstMap.insert(std::make_pair(function.getName(), function.nInstructions()));
currentFuncName = function.getName();
}
private:
void endFunction() {
......
......@@ -37,5 +37,5 @@ file (GLOB HEADERS *.hpp)
file (GLOB test_files tests/*.cpp)
add_tests("${test_files}" "${CMAKE_CURRENT_SOURCE_DIR}" "${Boost_LIBRARIES}")
install(FILES ${HEADERS} DESTINATION include)
install(FILES ${HEADERS} DESTINATION include/quantum/gate)
......@@ -40,4 +40,4 @@ file(GLOB test_files tests/*Tester.cpp)
# Add the tests
add_tests("${test_files}" "${CMAKE_CURRENT_SOURCE_DIR}" "${Boost_LIBRARIES}")
install(FILES ${HEADERS} DESTINATION include)
install(FILES ${HEADERS} DESTINATION include/xacc)
......@@ -76,7 +76,9 @@ public:
virtual void load(std::istream& inStream) = 0;
virtual void addKernel(std::shared_ptr<Function> kernel) = 0;
virtual std::shared_ptr<Function> getKernel(const std::string& name) = 0;
/**
* The destructor
*/
......
......@@ -192,7 +192,7 @@ public:
template<typename ... RuntimeArgs>
std::function<void(std::shared_ptr<AcceleratorBuffer>, RuntimeArgs...)> getKernel(
const std::string& kernelName) {
return [&](std::shared_ptr<AcceleratorBuffer> buffer, RuntimeArgs... args) {
return [=](std::shared_ptr<AcceleratorBuffer> buffer, RuntimeArgs... args) {
build("--compiler scaffold", args...);
auto fToExec = xaccIR->getKernel(kernelName);
accelerator->execute(buffer, fToExec);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment