From e6d24e50a9dac403df2a38aa9fde595615f2eb2f Mon Sep 17 00:00:00 2001 From: Lukas Burgholzer Date: Wed, 21 Aug 2024 08:48:02 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20replace=20MQT=20Core=20Sub?= =?UTF-8?q?module=20with=20FetchContent=20(#275)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR replaces the mqt-core submodule with a FetchContent directive, which should hopefully improve the stability of the library. It also updates mqt-core to its latest version and adapts to the respective changes. --- .github/workflows/update-mqt-core.yml | 26 +++++++++++++++++++++ .gitmodules | 4 ---- CMakeLists.txt | 15 +----------- Dockerfile | 2 +- cmake/ExternalDependencies.cmake | 33 +++++++++++++++++++++++++++ cpp/module/QDDVer.h | 2 +- cpp/module/QDDVis.h | 2 +- cpp/mqt-core | 1 - 8 files changed, 63 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/update-mqt-core.yml create mode 100644 cmake/ExternalDependencies.cmake delete mode 160000 cpp/mqt-core diff --git a/.github/workflows/update-mqt-core.yml b/.github/workflows/update-mqt-core.yml new file mode 100644 index 0000000..9951b38 --- /dev/null +++ b/.github/workflows/update-mqt-core.yml @@ -0,0 +1,26 @@ +name: Update MQT Core +on: + schedule: + # run once a month on the first day of the month at 00:00 UTC + - cron: "0 0 1 * *" + workflow_dispatch: + inputs: + update-to-head: + description: "Update to the latest commit on the default branch" + type: boolean + required: false + default: false + pull_request: + paths: + - .github/workflows/update-mqt-core.yml + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + update-mqt-core: + name: ⬆️ Update MQT Core + uses: cda-tum/mqt-workflows/.github/workflows/reusable-mqt-core-update.yml@v1.3 + with: + update-to-head: ${{ github.event.inputs.update-to-head == 'true' }} diff --git a/.gitmodules b/.gitmodules index fb94b0f..e69de29 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +0,0 @@ -[submodule "cpp/mqt-core"] - path = cpp/mqt-core - url = https://github.com/cda-tum/mqt-core.git - branch = main diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f61d94..dc46cf7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,26 +8,13 @@ project( DESCRIPTION "MQT DDVis - A Tool for Visualizing Decision Diagrams for Quantum Computing" LANGUAGES CXX) -# check whether the submodule ``modulename`` is correctly cloned in the ``/extern`` directory. -macro(CHECK_SUBMODULE_PRESENT modulename) - if(NOT EXISTS "${PROJECT_SOURCE_DIR}/cpp/${modulename}/CMakeLists.txt") - message( - FATAL_ERROR - "${modulename} submodule not cloned properly. \ - Please run `git submodule update --init --recursive` \ - from the main project directory") - endif() -endmacro() - # enable PIC generation set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "Build Position Independent Code") -check_submodule_present(mqt-core) # add submodule directory. this automatically adds the appropriate targets and include files -set(BUILD_MQT_CORE_TESTS OFF) -add_subdirectory(cpp/mqt-core) +include(cmake/ExternalDependencies.cmake) # create executable add_library(${PROJECT_NAME} SHARED cpp/module/module.cpp cpp/module/QDDVer.cpp cpp/module/QDDVer.h diff --git a/Dockerfile b/Dockerfile index c0d0e32..b3c7e30 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM node:20-alpine # Add gcc and cmake -RUN apk add build-base cmake ninja +RUN apk add build-base cmake ninja git # Set the working directory in the container to /app WORKDIR /app diff --git a/cmake/ExternalDependencies.cmake b/cmake/ExternalDependencies.cmake new file mode 100644 index 0000000..baf3a38 --- /dev/null +++ b/cmake/ExternalDependencies.cmake @@ -0,0 +1,33 @@ +# Declare all external dependencies and make sure that they are available. + +include(FetchContent) +set(FETCH_PACKAGES "") + +# cmake-format: off +set(MQT_CORE_VERSION 2.6.1 + CACHE STRING "MQT Core version") +set(MQT_CORE_REV "5be1c3ec4efb773d0330298621704e876afa7c16" + CACHE STRING "MQT Core identifier (tag, branch or commit hash)") +set(MQT_CORE_REPO_OWNER "cda-tum" + CACHE STRING "MQT Core repository owner (change when using a fork)") +# cmake-format: on +if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24) + FetchContent_Declare( + mqt-core + GIT_REPOSITORY https://github.com/${MQT_CORE_REPO_OWNER}/mqt-core.git + GIT_TAG ${MQT_CORE_REV} + FIND_PACKAGE_ARGS ${MQT_CORE_VERSION}) + list(APPEND FETCH_PACKAGES mqt-core) +else() + find_package(mqt-core ${MQT_CORE_VERSION} QUIET) + if(NOT mqt-core_FOUND) + FetchContent_Declare( + mqt-core + GIT_REPOSITORY https://github.com/${MQT_CORE_REPO_OWNER}/mqt-core.git + GIT_TAG ${MQT_CORE_REV}) + list(APPEND FETCH_PACKAGES mqt-core) + endif() +endif() + +# Make all declared dependencies available. +FetchContent_MakeAvailable(${FETCH_PACKAGES}) diff --git a/cpp/module/QDDVer.h b/cpp/module/QDDVer.h index 9624dcd..7c5bcaa 100644 --- a/cpp/module/QDDVer.h +++ b/cpp/module/QDDVer.h @@ -7,9 +7,9 @@ #ifndef QDD_VIS_QDDVER_H #define QDD_VIS_QDDVER_H -#include "QuantumComputation.hpp" #include "dd/Operations.hpp" #include "dd/Package.hpp" +#include "ir/QuantumComputation.hpp" #include #include diff --git a/cpp/module/QDDVis.h b/cpp/module/QDDVis.h index 0990072..25c5c72 100644 --- a/cpp/module/QDDVis.h +++ b/cpp/module/QDDVis.h @@ -7,9 +7,9 @@ #ifndef QDDVIS_H #define QDDVIS_H -#include "QuantumComputation.hpp" #include "dd/Operations.hpp" #include "dd/Package.hpp" +#include "ir/QuantumComputation.hpp" #include #include diff --git a/cpp/mqt-core b/cpp/mqt-core deleted file mode 160000 index aa3b3bd..0000000 --- a/cpp/mqt-core +++ /dev/null @@ -1 +0,0 @@ -Subproject commit aa3b3bd3b07e43d6421b7c0d741b5755938c6e9d