Skip to content
Open
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ clients compiled against a different minor or major version.

## [Unreleased]

### Changed

- 🚸 Export _all_ device headers (incl. `constants.h`) as part of device implementations such that they do not need to link against the header-only QDMI library anymore ([#325]) ([\@ystade])

## [1.2.1] - 2025-12-22

_If you are upgrading: please see [`UPGRADING.md`](UPGRADING.md#121)._
Expand Down Expand Up @@ -112,6 +116,7 @@ changelogs._

<!-- PR links -->

[#325]: https://github.com/Munich-Quantum-Software-Stack/QDMI/pull/325
[#285]: https://github.com/Munich-Quantum-Software-Stack/QDMI/pull/285
[#275]: https://github.com/Munich-Quantum-Software-Stack/QDMI/pull/275
[#274]: https://github.com/Munich-Quantum-Software-Stack/QDMI/pull/274
Expand Down
30 changes: 18 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ set(PROJECT_VERSION_FULL "${PROJECT_VERSION}${PROJECT_VERSION_PRERELEASE}")
# enable organization of targets into folders
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

include(CMakeDependentOption)

# Set a default build type if none was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Release' as none was specified.")
Expand All @@ -52,14 +54,9 @@ option(
"Use an installed version of QDMI to build examples, templates, and tests"
OFF)

if(USE_INSTALLED_QDMI)
set(QDMI_INSTALL
OFF
CACHE BOOL "Generate installation instructions for QDMI" FORCE)
else()
option(QDMI_INSTALL "Generate installation instructions for QDMI"
${QDMI_MASTER_PROJECT})
endif()
cmake_dependent_option(
QDMI_INSTALL "Generate installation instructions for QDMI"
${QDMI_MASTER_PROJECT} "NOT USE_INSTALLED_QDMI" OFF)
option(BUILD_QDMI_TESTS "Also build tests for the QDMI project"
${QDMI_MASTER_PROJECT})
option(BUILD_QDMI_EXAMPLES "Also build examples for the QDMI project"
Expand Down Expand Up @@ -134,9 +131,13 @@ if(NOT USE_INSTALLED_QDMI)
# enable coverage collection options
option(ENABLE_COVERAGE "Enable coverage reporting" FALSE)
if(ENABLE_COVERAGE)
target_compile_options(qdmi INTERFACE --coverage -fprofile-arcs
-ftest-coverage -O0)
target_link_libraries(qdmi INTERFACE gcov --coverage)
add_library(qdmi_coverage_flags INTERFACE)
target_compile_options(
qdmi_coverage_flags INTERFACE --coverage -fprofile-arcs -ftest-coverage
-O0)
target_link_libraries(qdmi_coverage_flags INTERFACE gcov --coverage)
add_library(qdmi::qdmi_coverage_flags ALIAS qdmi_coverage_flags)
target_link_libraries(qdmi INTERFACE qdmi::qdmi_coverage_flags)
endif()

# set the version of the library
Expand Down Expand Up @@ -198,11 +199,16 @@ if(QDMI_INSTALL)
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
DESTINATION ${QDMI_CONFIG_INSTALL_DIR})

set(QDMI_INSTALL_TARGETS ${QDMI_INSTALL_TARGETS} qdmi qdmi_project_warnings)
if(ENABLE_COVERAGE)
set(QDMI_INSTALL_TARGETS ${QDMI_INSTALL_TARGETS} qdmi_coverage_flags)
endif()

# FILE_SET should be aligned with LIBRARY and ARCHIVE, so we turn cmake-format
# off
# cmake-format: off
install(
TARGETS qdmi qdmi_project_warnings
TARGETS ${QDMI_INSTALL_TARGETS}
EXPORT ${PROJECT_NAME}-targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT ${PROJECT_NAME}_Runtime
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
Expand Down
6 changes: 3 additions & 3 deletions cmake/PrefixHandling.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ function(generate_prefixed_qdmi_headers prefix)
endif()

# Get the list of all QDMI device headers.
file(GLOB_RECURSE QDMI_DEVICE_HEADERS ${QDMI_INCLUDE_DIR}/qdmi/device.h
${QDMI_INCLUDE_DIR}/qdmi/types.h)
file(GLOB_RECURSE QDMI_DEVICE_HEADERS ${QDMI_INCLUDE_DIR}/qdmi/constants.h
${QDMI_INCLUDE_DIR}/qdmi/device.h ${QDMI_INCLUDE_DIR}/qdmi/types.h)

# Determine the correct CMake directory for prefix_defs.txt
set(QDMI_PREFIX_DIR "${QDMI_CMAKE_DIR}")
Expand All @@ -55,7 +55,7 @@ function(generate_prefixed_qdmi_headers prefix)
# Replace the include for the device header with the prefixed version.
string(
REGEX
REPLACE "#include (\"|<)qdmi/(device|types).h(\"|>)"
REPLACE "#include (\"|<)qdmi/(constants|device|types).h(\"|>)"
"#include \\1${QDMI_prefix}_qdmi/\\2.h\\3" header_content
"${header_content}")
# Replace the prefix definitions.
Expand Down
5 changes: 4 additions & 1 deletion examples/device/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ enable_language(CXX)
# change. Hence, in the test you have to adopt the name of the shared library
# accordingly.
add_library(cxx_device SHARED device.cpp)
target_link_libraries(cxx_device PRIVATE qdmi::qdmi qdmi::qdmi_project_warnings)
target_link_libraries(cxx_device PRIVATE qdmi::qdmi_project_warnings)
if(ENABLE_COVERAGE)
target_link_libraries(cxx_device PRIVATE qdmi::qdmi_coverage_flags)
endif()
generate_prefixed_qdmi_headers("CXX")
target_include_directories(cxx_device
PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include)
Expand Down
Loading