Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

♻️ replace MQT Core Submodule with FetchContent #275

Merged
merged 4 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/update-mqt-core.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
with:
update-to-head: ${{ github.event.inputs.update-to-head == 'true' }}
4 changes: 0 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
[submodule "cpp/mqt-core"]
path = cpp/mqt-core
url = https://github.com/cda-tum/mqt-core.git
branch = main
15 changes: 1 addition & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 33 additions & 0 deletions cmake/ExternalDependencies.cmake
Original file line number Diff line number Diff line change
@@ -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})
2 changes: 1 addition & 1 deletion cpp/module/QDDVer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <iostream>
#include <memory>
Expand Down
2 changes: 1 addition & 1 deletion cpp/module/QDDVis.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <iostream>
#include <memory>
Expand Down
1 change: 0 additions & 1 deletion cpp/mqt-core
Submodule mqt-core deleted from aa3b3b