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

🩹 make GMP dependency opt-in instead of used-if-found #608

Merged
merged 1 commit into from
May 23, 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
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
needs: change-detection
if: fromJSON(needs.change-detection.outputs.run-cpp-tests)
uses: cda-tum/mqt-workflows/.github/workflows/[email protected]
with:
cmake-args-macos: -DMQT_CORE_WITH_GMP=ON
secrets:
token: ${{ secrets.CODECOV_TOKEN }}

Expand Down
5 changes: 2 additions & 3 deletions cmake/mqt-core-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")

include(CMakeFindDependencyMacro)
find_dependency(nlohmann_json)
option(MQT_CORE_ZX_WITH_GMP "Library is configured to use GMP for ZX calculations"
@MQT_CORE_ZX_WITH_GMP@)
if(MQT_CORE_ZX_WITH_GMP)
option(MQT_CORE_WITH_GMP "Library is configured to use GMP" @MQT_CORE_WITH_GMP@)
if(MQT_CORE_WITH_GMP)
find_dependency(GMP)
endif()

Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ if(MQT_CORE_INSTALL)
configure_package_config_file(
${MQT_CORE_CMAKE_CONFIG_TEMPLATE} ${MQT_CORE_CMAKE_PROJECT_CONFIG_FILE}
INSTALL_DESTINATION ${MQT_CORE_CONFIG_INSTALL_DIR}
PATH_VARS MQT_CORE_ZX_WITH_GMP
PATH_VARS MQT_CORE_WITH_GMP
NO_SET_AND_CHECK_MACRO NO_CHECK_REQUIRED_COMPONENTS_MACRO)
write_basic_package_version_file(
${MQT_CORE_CMAKE_VERSION_CONFIG_FILE}
Expand Down
13 changes: 4 additions & 9 deletions src/zx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,13 @@ if(NOT TARGET ${MQT_CORE_TARGET_NAME}-zx)
target_link_libraries(${MQT_CORE_TARGET_NAME}-zx PUBLIC MQT::Core MQT::Multiprecision)
target_link_libraries(${MQT_CORE_TARGET_NAME}-zx PRIVATE MQT::ProjectOptions MQT::ProjectWarnings)

find_package(GMP)
if(NOT GMP_FOUND)
message(NOTICE "Did not find GMP. Using Boost multiprecision library instead.")
endif()
# # link to GMP libraries if present
if(GMP_FOUND)
option(MQT_CORE_WITH_GMP "Whether to use GMP for multiprecision arithmetic" OFF)
if(MQT_CORE_WITH_GMP)
find_package(GMP REQUIRED)
# link to GMP libraries if present
target_compile_definitions(${MQT_CORE_TARGET_NAME}-zx PUBLIC GMP)
target_link_libraries(${MQT_CORE_TARGET_NAME}-zx PUBLIC GMP::gmp GMP::gmpxx)
endif()
set(MQT_CORE_ZX_WITH_GMP
${GMP_FOUND}
CACHE BOOL "Whether to use GMP for multiprecision arithmetic")

# add MQT alias
add_library(MQT::CoreZX ALIAS ${MQT_CORE_TARGET_NAME}-zx)
Expand Down
Loading