Commit 0cdc0854 authored by Mccaskey, Alex's avatar Mccaskey, Alex

Starting on new ExternalProject_add based build, with CppMicroServices integrated

parent 25f234ac
......@@ -28,10 +28,10 @@
# Initial API and implementation - Alex McCaskey
#
#**********************************************************************************/
project(XACC CXX)
cmake_minimum_required(VERSION 2.8)
set(CMAKE_DISABLE_IN_SOURCE_BUILDS ON)
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
project(xacc LANGUAGES CXX)
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
#set(CMAKE_DISABLE_IN_SOURCE_BUILDS ON)
#set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 14)
message(STATUS "C++ version ${CXX_STANDARD} configured.")
......@@ -40,16 +40,31 @@ 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")
include(tests)
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set (CMAKE_INSTALL_PREFIX "/usr/local/xacc" CACHE PATH "default install path" FORCE )
endif()
find_package(CppMicroServices NO_MODULE REQUIRED)
get_filename_component(CppMicroServices_BASE_DIR ${CppMicroServices_RUNTIME_LIBRARY_DIRS} DIRECTORY)
#find_package(CppMicroServices NO_MODULE REQUIRED)
#get_filename_component(CppMicroServices_BASE_DIR ${CppMicroServices_RUNTIME_LIBRARY_DIRS} DIRECTORY)
#set(CppMicroServices_INCLUDE_DIR ${CppMicroServices_BASE_DIR}/include/cppmicroservices3)
#set(CppMicroServices_LIBRARY_DIR ${CppMicroServices_BASE_DIR}/lib)
# Setup Doxygen
find_package(Doxygen)
if(DOXYGEN_FOUND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.cmake ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
add_custom_target(doc ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Generating API documentation with Doxygen"
VERBATIM)
endif(DOXYGEN_FOUND)
include(ExternalProject)
set(STAGED_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/stage${CMAKE_INSTALL_PREFIX})
add_subdirectory(tpls)
set(CppMicroServices_BASE_DIR ${CMAKE_BINARY_DIR}/cppus_install/usr/local)
set(CppMicroServices_INCLUDE_DIR ${CppMicroServices_BASE_DIR}/include/cppmicroservices3)
set(CppMicroServices_LIBRARY_DIR ${CppMicroServices_BASE_DIR}/lib)
......@@ -57,14 +72,15 @@ set(CppMicroServices_LIBRARY_DIR ${CppMicroServices_BASE_DIR}/lib)
find_package(MPI)
if (MPI_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DXACC_HAS_MPI")
# We require Boost with MPI
find_package(Boost COMPONENTS mpi system program_options filesystem REQUIRED)
find_package(Boost COMPONENTS mpi system program_options filesystem chrono thread REQUIRED)
include_directories(${MPI_INCLUDE_PATH})
else()
message(STATUS "MPI Not Found.")
# We require Boost without MPI
find_package(Boost COMPONENTS system program_options filesystem REQUIRED)
find_package(Boost COMPONENTS system program_options filesystem chrono thread REQUIRED)
endif()
# Look for OpenMP, add it we find it
......@@ -73,37 +89,54 @@ if (OPENMP_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
# Setup Doxygen
find_package(Doxygen)
if(DOXYGEN_FOUND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.cmake ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
add_custom_target(doc ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Generating API documentation with Doxygen"
VERBATIM)
endif(DOXYGEN_FOUND)
ExternalProject_Add(xacc-core
DEPENDS cppmicroservices
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/xacc
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DXACC_ROOT=${CMAKE_CURRENT_SOURCE_DIR}
-DCPPUS_INCLUDE_DIR=${CppMicroServices_INCLUDE_DIR}
-DCPPUS_LIBRARY_DIR=${CppMicroServices_LIBRARY_DIR}
-DBoost_INCLUDE_DIRS=${BOOST_INCLUDE_DIRS}
-DBoost_LIBRARIES=${Boost_LIBRARIES}
-DMPI_INCLUDE_PATH=${MPI_INCLUDE_PATH}
CMAKE_CACHE_ARGS -DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH}
BUILD_ALWAYS 1
INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install DESTDIR=${CMAKE_BINARY_DIR}/stage
TEST_BEFORE_INSTALL 1
)
set(XACC_BASE_DIR ${CMAKE_BINARY_DIR}/stage${CMAKE_INSTALL_PREFIX})
set(XACC_INCLUDE_DIR ${XACC_BASE_DIR}/include/xacc)
set(XACC_LIBRARY_DIR ${XACC_BASE_DIR}/lib)
# 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/xacc)
# Include dirs that everyone will use
include_directories(${CMAKE_BINARY_DIR})
include_directories(${MPI_INCLUDE_PATH})
include_directories(${Boost_INCLUDE_DIRS})
include_directories(${CMAKE_SOURCE_DIR}/tpls/spdlog)
include_directories(${CppMicroServices_INCLUDE_DIR})
include_directories("${CMAKE_SOURCE_DIR}/xacc")
include_directories("${CMAKE_SOURCE_DIR}/xacc/ir")
include_directories("${CMAKE_SOURCE_DIR}/xacc/compiler")
include_directories("${CMAKE_SOURCE_DIR}/xacc/program")
include_directories("${CMAKE_SOURCE_DIR}/xacc/accelerator")
include_directories("${CMAKE_SOURCE_DIR}/xacc/utils")
# Add subdirectories
add_subdirectory(xacc)
add_subdirectory(quantum)
add_subdirectory(impls)
add_subdirectory(tools)
string (REPLACE ";" " " XACC_Boost_LIBRARIES "${Boost_LIBRARIES}")
ExternalProject_Add(xacc-quantum
DEPENDS xacc-core
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/quantum
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DXACC_ROOT=${CMAKE_CURRENT_SOURCE_DIR}
-DCPPUS_INCLUDE_DIR=${CppMicroServices_INCLUDE_DIR}
-DCPPUS_LIBRARY_DIR=${CppMicroServices_LIBRARY_DIR}
-DXACC_INCLUDE_DIR=${XACC_INCLUDE_DIR}
-DXACC_LIBRARY_DIR=${XACC_LIBRARY_DIR}
-DBoost_INCLUDE_DIRS=${BOOST_INCLUDE_DIRS}
-DXACC_Boost_LIBRARIES=${XACC_Boost_LIBRARIES}
-DMPI_INCLUDE_PATH=${MPI_INCLUDE_PATH}
CMAKE_CACHE_ARGS -DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH}
BUILD_ALWAYS 1
INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install DESTDIR=${CMAKE_BINARY_DIR}/stage
TEST_AFTER_INSTALL 1
)
# Install the config file for external projects to use
# This is cool, users just add find_package(XACC REQUIRED) to
......@@ -112,3 +145,8 @@ add_subdirectory(tools)
configure_file("${CMAKE_SOURCE_DIR}/cmake/xacc-config.cmake.in" "${CMAKE_BINARY_DIR}/xacc-config.cmake")
install(FILES "${CMAKE_BINARY_DIR}/xacc-config.cmake" DESTINATION .)
INSTALL( DIRECTORY "${CMAKE_SOURCE_DIR}/tpls/spdlog" DESTINATION include )
install( DIRECTORY "${CMAKE_BINARY_DIR}/cppus_install/usr/local/bin/" DESTINATION bin)
install( DIRECTORY "${CMAKE_BINARY_DIR}/cppus_install/usr/local/include/" DESTINATION include)
install( DIRECTORY "${CMAKE_BINARY_DIR}/cppus_install/usr/local/lib/" DESTINATION lib/cppmicroservices)
install( DIRECTORY "${CMAKE_BINARY_DIR}/cppus_install/usr/local/share/" DESTINATION share)
install( DIRECTORY "${CMAKE_BINARY_DIR}/stage/usr/local/xacc/" DESTINATION .)
set (XACC_ROOT "@CMAKE_INSTALL_PREFIX@")
set (XACC_INCLUDE_DIRS "@CppMicroServices_INCLUDE_DIR@;@CMAKE_INSTALL_PREFIX@/include;@CMAKE_INSTALL_PREFIX@/include/xacc;@CMAKE_INSTALL_PREFIX@/include/quantum/gate;@CMAKE_INSTALL_PREFIX@/include/quantum/aqc;@CMAKE_INSTALL_PREFIX@/include/spdlog")
set (XACC_LIBRARY_DIR "@CMAKE_INSTALL_PREFIX@/lib")
set (XACC_LIBRARY_DIRS "@CMAKE_INSTALL_PREFIX@/lib;@CppMicroServices_LIBRARY_DIR@")
set (XACC_LIBRARIES "@CMAKE_INSTALL_PREFIX@/lib/libxacc.so;@CMAKE_INSTALL_PREFIX@/lib/libxacc-quantum-gate.so;@CMAKE_INSTALL_PREFIX@/lib/libxacc-quantum-aqc.so;CppMicroServices")
find_package(CppMicroServices NO_MODULE REQUIRED)
\ No newline at end of file
set (XACC_INCLUDE_DIRS "@CMAKE_INSTALL_PREFIX@/include/cppmicroservices3;@CMAKE_INSTALL_PREFIX@/include/xacc;@CMAKE_INSTALL_PREFIX@/include/quantum/gate;@CMAKE_INSTALL_PREFIX@/include/quantum/aqc;@CMAKE_INSTALL_PREFIX@/include/spdlog")
set (XACC_LIBRARY_DIRS "@CMAKE_INSTALL_PREFIX@/lib;@CMAKE_INSTALL_PREFIX@/lib/cppmicroservices")
set (XACC_LIBRARIES "xacc;CppMicroServicesd")
#@CMAKE_INSTALL_PREFIX@/lib/libxacc.so;@CMAKE_INSTALL_PREFIX@/lib/libxacc-quantum-gate.so;@CMAKE_INSTALL_PREFIX@/lib/libxacc-quantum-aqc.so;CppMicroServicesd")
#find_package(CppMicroServices NO_MODULE REQUIRED)
......@@ -2,5 +2,6 @@
#define XACC_CONFIG_HPP
#define XACC_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}"
#define XACC_BUILD_DIR "${CMAKE_BINARY_DIR}"
#endif
......@@ -28,7 +28,34 @@
# Initial API and implementation - Alex McCaskey
#
#**********************************************************************************/
include_directories(${CMAKE_SOURCE_DIR}/tpls/rapidjson/include)
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
project(xacc-quantum LANGUAGES CXX)
set(CMAKE_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 14)
message(STATUS "C++ version ${CXX_STANDARD} configured.")
set(CppMicroServices_DIR "${CPPUS_LIBRARY_DIR}/../share/cppmicroservices3/cmake")
# Modify our CMAKE_MODULE_PATH
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${XACC_ROOT}/cmake/Modules")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CppMicroServices_DIR}")
include(tests)
include(CppMicroServicesConfig)
include_directories(${XACC_INCLUDE_DIR})
include_directories(${XACC_ROOT}/tpls/rapidjson/include)
include_directories(${Boost_INCLUDE_DIRS})
include_directories(${XACC_ROOT}/tpls/spdlog)
include_directories(${XACC_ROOT}/tpls/eigen)
include_directories(${CPPUS_INCLUDE_DIR})
include_directories(${MPI_INCLUDE_PATH})
include_directories(${CMAKE_BINARY_DIR})
link_directories(${XACC_LIBRARY_DIR})
link_directories(${CPPUS_LIBRARY_DIR})
string (REPLACE " " ";" Boost_LIBRARIES "${XACC_Boost_LIBRARIES}")
add_subdirectory(gate)
add_subdirectory(aqc)
......@@ -29,6 +29,6 @@
#
#**********************************************************************************/
# Gather tests
file (GLOB test_files tests/*.cpp)
add_tests("${test_files}" "${CMAKE_CURRENT_SOURCE_DIR}" "${Boost_LIBRARIES};xacc-quantum-gate;xacc")
#file (GLOB test_files tests/*.cpp)
#add_tests("${test_files}" "${CMAKE_CURRENT_SOURCE_DIR}" "${Boost_LIBRARIES};xacc-quantum-gate;xacc")
......@@ -151,7 +151,9 @@ public:
};
BOOST_AUTO_TEST_CASE(checkSimple) {
xacc::Initialize();
auto testPath = std::string(XACC_BUILD_DIR) + std::string("/stage/usr/local/xacc/lib/libxacc-quantum-gate.so");
xacc::Initialize(std::vector<std::string>{"--load",testPath});
const std::string src("module teleport (qbit qreg[3]) {\n"
" cbit creg[2];\n"
" // Init qubit 0 to 1\n"
......
ExternalProject_Add(cppmicroservices
GIT_REPOSITORY https://github.com/cppmicroservices/cppmicroservices
GIT_TAG v3.1.0
CMAKE_ARGS -DCMAKE_CXX_FLAGS='-Wimplicit-fallthrough=0'
INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install DESTDIR=${CMAKE_BINARY_DIR}/cppus_install
)
......@@ -28,15 +28,43 @@
# Initial API and implementation - Alex McCaskey
#
#**********************************************************************************/
set (PACKAGE_NAME "XACC Specification")
set (PACKAGE_DESCIPTION "The XACC Programming Framework")
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
project(xacc-core LANGUAGES CXX)
set(CMAKE_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 14)
message(STATUS "C++ version ${CXX_STANDARD} configured.")
# Modify our CMAKE_MODULE_PATH
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${XACC_ROOT}/cmake/Modules")
include(tests)
include_directories(${Boost_INCLUDE_DIRS})
include_directories(${XACC_ROOT}/tpls/spdlog)
include_directories(${CPPUS_INCLUDE_DIR})
include_directories(${MPI_INCLUDE_PATH})
include_directories("${CMAKE_SOURCE_DIR}")
include_directories("${CMAKE_SOURCE_DIR}/ir")
include_directories("${CMAKE_SOURCE_DIR}/compiler")
include_directories("${CMAKE_SOURCE_DIR}/program")
include_directories("${CMAKE_SOURCE_DIR}/accelerator")
include_directories("${CMAKE_SOURCE_DIR}/utils")
include_directories(${CMAKE_BINARY_DIR})
# Create a xacc config header file
configure_file("${XACC_ROOT}/cmake/xacc_config.hpp.in" "${CMAKE_BINARY_DIR}/xacc_config.hpp")
install(FILES "${CMAKE_BINARY_DIR}/xacc_config.hpp" DESTINATION include/xacc)
#set (PACKAGE_NAME "XACC Specification")
#set (PACKAGE_DESCIPTION "The XACC Programming Framework")
set (LIBRARY_NAME xacc)
file (GLOB HEADERS program/*.hpp XACC.hpp ir/*.hpp program/*.hpp compiler/*.hpp accelerator/*.hpp utils/*.hpp)
file (GLOB HEADERS XACC.hpp ir/*.hpp program/*.hpp compiler/*.hpp accelerator/*.hpp utils/*.hpp)
file (GLOB SRC *.cpp utils/*.cpp)
link_directories(${CPPUS_LIBRARY_DIR})
add_library(${LIBRARY_NAME} SHARED ${SRC})
target_link_libraries(${LIBRARY_NAME} ${Boost_LIBRARIES} ${MPI_LIBRARIES} CppMicroServices)
target_link_libraries(${LIBRARY_NAME} ${Boost_LIBRARIES} CppMicroServicesd)
# Get the test files
file(GLOB test_files utils/tests/*Tester.cpp)
......
......@@ -72,10 +72,6 @@ void Initialize(int argc, char** argv) {
// Check that we have some
auto s = serviceRegistry->getServices<Compiler>().size();
auto a = serviceRegistry->getServices<Accelerator>().size();
if (s == 0)
XACCError("There are no Compiler instances available. Exiting.");
if (a == 0)
XACCError("There are no Accelerator instances available. Exiting.");
XACCInfo(
"[xacc::compiler] XACC has " + std::to_string(s) + " Compiler"
......
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