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

🚸 Building Shared Libraries #538

Closed
wants to merge 16 commits into from
Closed
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
4 changes: 0 additions & 4 deletions cmake/CompilerOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ function(enable_project_options target_name)

option(BINDINGS "Configure for building Python bindings")
if(BINDINGS)
check_cxx_compiler_flag(-fvisibility=hidden HAS_VISIBILITY_HIDDEN)
if(HAS_VISIBILITY_HIDDEN)
target_compile_options(${target_name} INTERFACE -fvisibility=hidden)
endif()
include(CheckPIESupported)
check_pie_supported()
set_target_properties(${target_name} PROPERTIES INTERFACE_POSITION_INDEPENDENT_CODE ON)
Expand Down
5 changes: 5 additions & 0 deletions cmake/StandardProjectSettings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,8 @@ if(DEPLOY)
"10.15"
CACHE STRING "" FORCE)
endif()

# On Windows, export all symbols by default
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS
ON
CACHE BOOL "Export all symbols on Windows")
7 changes: 4 additions & 3 deletions include/mqt-core/dd/RealNumber.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "dd/DDDefinitions.hpp"
#include "mqt_core_export.h"

#include <istream>
#include <limits>
Expand Down Expand Up @@ -230,11 +231,11 @@ struct RealNumber {
namespace constants {
// NOLINTBEGIN(cppcoreguidelines-avoid-non-const-global-variables)
/// The constant zero.
extern RealNumber zero;
MQT_CORE_EXPORT extern RealNumber zero;
/// The constant one.
extern RealNumber one;
MQT_CORE_EXPORT extern RealNumber one;
/// The constant sqrt(2)/2 = 1/sqrt(2).
extern RealNumber sqrt2over2;
MQT_CORE_EXPORT extern RealNumber sqrt2over2;
// NOLINTEND(cppcoreguidelines-avoid-non-const-global-variables)

/**
Expand Down
48 changes: 0 additions & 48 deletions include/mqt-core/python/qiskit/QuantumCircuit.hpp

This file was deleted.

12 changes: 9 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ build-dir = "build/{wheel_tag}"
# Explicitly set the package directory
wheel.packages = ["src/mqt"]

install.components = ["mqt-core_Python"]

metadata.version.provider = "scikit_build_core.metadata.setuptools_scm"
sdist.include = ["src/mqt/core/_version.py"]
sdist.exclude = [
Expand All @@ -114,12 +112,20 @@ git-only = [
[tool.scikit-build.cmake.define]
BUILD_MQT_CORE_BINDINGS = "ON"
BUILD_MQT_CORE_TESTS = "OFF"
BUILD_SHARED_LIBS = "ON"


[tool.setuptools_scm]
write_to = "src/mqt/core/_version.py"


[tool.check-wheel-contents]
ignore = [
"W002",
"W004",
]


[tool.pytest.ini_options]
minversion = "7.0"
addopts = ["-ra", "--strict-markers", "--strict-config"]
Expand Down Expand Up @@ -285,5 +291,5 @@ environment = { MACOSX_DEPLOYMENT_TARGET = "10.15" }

[tool.cibuildwheel.windows]
before-build = "pip install delvewheel"
repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel}"
repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel} --namespace-pkg mqt"
environment = { CMAKE_GENERATOR = "Ninja" }
23 changes: 0 additions & 23 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -160,29 +160,6 @@ add_subdirectory(ecc)
# add NA library
add_subdirectory(na)

# ** Note ** The following target will soon be removed from the project. All top-level projects
# should switch to using the mqt-core Python package.
if(BINDINGS AND NOT TARGET mqt-core-python)
# add Python interface library
add_library(
${MQT_CORE_TARGET_NAME}-python ${MQT_CORE_INCLUDE_BUILD_DIR}/python/qiskit/QuantumCircuit.hpp
python/qiskit/QuantumCircuit.cpp)

# link with main project library and pybind11 libraries
target_link_libraries(${MQT_CORE_TARGET_NAME}-python PUBLIC MQT::Core pybind11::pybind11)
target_link_libraries(${MQT_CORE_TARGET_NAME}-python PRIVATE MQT::ProjectOptions
MQT::ProjectWarnings)

# add MQT alias
add_library(MQT::CorePython ALIAS ${MQT_CORE_TARGET_NAME}-python)
set_target_properties(
${MQT_CORE_TARGET_NAME}-python
PROPERTIES VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
EXPORT_NAME CorePython)
list(APPEND MQT_CORE_TARGETS ${MQT_CORE_TARGET_NAME}-python)
endif()

if(BUILD_MQT_CORE_BINDINGS)
add_subdirectory(python)
endif()
Expand Down
11 changes: 11 additions & 0 deletions src/mqt/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

from __future__ import annotations

import sys

# under Windows, make sure to add the appropriate DLL directory to the PATH
if sys.platform == "win32":
import os
import sysconfig
from pathlib import Path

bin_dir = Path(sysconfig.get_paths()["purelib"]) / "mqt" / "core" / "bin"
os.add_dll_directory(str(bin_dir))

from ._core import Permutation, QuantumComputation
from ._version import version as __version__
from ._version import version_tuple as version_info
Expand Down
Loading