diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d9a6827ca1..a6f3cc4d9d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,7 +33,7 @@ jobs: include: - runs-on: ubuntu-24.04 compiler: gcc - preset: debug + preset: debug-shared run-on-draft: true setup-mlir: true - runs-on: ubuntu-24.04 diff --git a/CMakeLists.txt b/CMakeLists.txt index 72c9cf6c27..f931b97259 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,7 +115,6 @@ if(MQT_CORE_INSTALL) set(CMAKE_INSTALL_RPATH ${BASEPOINT} ${BASEPOINT}/${CMAKE_INSTALL_LIBDIR} ${BASEPOINT}/../${CMAKE_INSTALL_LIBDIR}) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) - set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) endif() # add main library code diff --git a/CMakePresets.json b/CMakePresets.json index 49abb92583..0f72e68ae6 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -61,6 +61,15 @@ "LLVM_ENABLE_ASSERTIONS": "ON" } }, + { + "name": "debug-shared", + "inherits": "debug", + "displayName": "Debug config with shared Core libraries", + "cacheVariables": { + "BUILD_SHARED_LIBS": "ON", + "BUILD_MQT_CORE_SHARED_LIBS": "ON" + } + }, { "name": "debug-no-mlir", "inherits": "base-unix-no-mlir", @@ -144,6 +153,10 @@ "name": "debug", "configurePreset": "debug" }, + { + "name": "debug-shared", + "configurePreset": "debug-shared" + }, { "name": "debug-no-mlir", "configurePreset": "debug-no-mlir" @@ -197,6 +210,11 @@ "inherits": "base", "configurePreset": "debug" }, + { + "name": "debug-shared", + "inherits": "base", + "configurePreset": "debug-shared" + }, { "name": "debug-no-mlir", "inherits": "base", diff --git a/cmake/ExternalDependencies.cmake b/cmake/ExternalDependencies.cmake index 7861f92550..2e075a3760 100644 --- a/cmake/ExternalDependencies.cmake +++ b/cmake/ExternalDependencies.cmake @@ -28,6 +28,8 @@ if(BUILD_MQT_CORE_MLIR) GIT_REPOSITORY https://github.com/unitaryfoundation/jeff-mlir.git GIT_TAG 7e11628de13d87798474386721c08f218b5f277e) function(_mqt_core_make_jeff_available) + # Embed jeff and its dependencies in the compiler's consumers, like our own compiler libraries. + set(BUILD_SHARED_LIBS OFF) # Cap'n Proto, which is fetched transitively by jeff-mlir, uses the generic BUILD_TESTING option # and defines a global `check` target when it is enabled. Do not let an embedding project's test # setting leak into this third-party dependency. diff --git a/docs/installation.md b/docs/installation.md index 5878f1a628..8207f61238 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -230,6 +230,12 @@ cmake --build build cmake --install build ``` +Set `BUILD_MQT_CORE_SHARED_LIBS=ON` to build the public Core libraries as shared +libraries. This option defaults to `BUILD_SHARED_LIBS`. Internal compiler +libraries and the bundled jeff dependencies remain static and are linked into +their consumers; they are not an installed compiler SDK. QDMI device libraries +are always shared so the driver can load them at runtime. + Then, in your project's {code}`CMakeLists.txt`, use {code}`find_package()` to locate the installed library: diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt index be72105fc1..0b58f3b987 100644 --- a/mlir/CMakeLists.txt +++ b/mlir/CMakeLists.txt @@ -6,6 +6,10 @@ # # Licensed under the MIT License +# Compiler libraries are private implementation details of the tools, bindings, and QDMI device. +# Embed them in those consumers instead of creating unexported shared-library dependencies. +set(BUILD_SHARED_LIBS OFF) + if(MSVC) add_compile_definitions(_SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING) endif() diff --git a/src/qdmi/driver/CMakeLists.txt b/src/qdmi/driver/CMakeLists.txt index d865043c8e..d445e6209c 100644 --- a/src/qdmi/driver/CMakeLists.txt +++ b/src/qdmi/driver/CMakeLists.txt @@ -12,6 +12,10 @@ if(NOT TARGET ${TARGET_NAME}) # Add driver library add_mqt_core_library(${TARGET_NAME} ALIAS_NAME QDMIDriver) + # A shared driver discovers device manifests beside its own library. + set_target_properties(${TARGET_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY + "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}") + # Add sources to target target_sources(${TARGET_NAME} PRIVATE DeviceRegistry.cpp Driver.cpp)