From 06b6e51b0296faea35d3297cecc5eb360e980b95 Mon Sep 17 00:00:00 2001 From: Jake Arkinstall <65358059+jake-arkinstall@users.noreply.github.com> Date: Tue, 13 Aug 2024 15:21:11 +0100 Subject: [PATCH] re-added gmp as a direct dependency to TKET --- nix-support/tket.nix | 2 +- tket/CMakeLists.txt | 9 +++++++++ tket/cmake/tketConfig.cmake.in | 7 ++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/nix-support/tket.nix b/nix-support/tket.nix index 70d9c68a89..ac39d3c6be 100644 --- a/nix-support/tket.nix +++ b/nix-support/tket.nix @@ -19,7 +19,7 @@ in { tket = super.stdenv.mkDerivation { name = "tket"; inherit src; - nativeBuildInputs = [ super.cmake ]; + nativeBuildInputs = [ super.cmake super.pkg-config ]; propagatedBuildInputs = super.tklibs ++ (with super; [ boost symengine eigen nlohmann_json ]); # TODO: add rapidcheck once nixpkgs packaging is correctly implemented. diff --git a/tket/CMakeLists.txt b/tket/CMakeLists.txt index 958d95dda7..43fdf48173 100644 --- a/tket/CMakeLists.txt +++ b/tket/CMakeLists.txt @@ -21,6 +21,11 @@ cmake_policy(SET CMP0022 NEW) list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake) find_package(Boost CONFIG REQUIRED) +find_package(gmp CONFIG) +if (NOT gmp_FOUND) + find_package(PkgConfig REQUIRED) + pkg_search_module(gmp REQUIRED IMPORTED_TARGET gmp) +endif() find_package(SymEngine CONFIG REQUIRED) find_package(Eigen3 CONFIG REQUIRED) find_package(nlohmann_json CONFIG REQUIRED) @@ -107,6 +112,9 @@ ENDIF() if (NOT TARGET symengine::symengine) add_library(symengine::symengine ALIAS symengine) endif() +if (NOT TARGET gmp::gmp) + add_library(gmp::gmp ALIAS PkgConfig::gmp) +endif() target_include_directories(tket PUBLIC $ @@ -120,6 +128,7 @@ target_link_libraries(tket PUBLIC tkassert::tkassert) target_link_libraries(tket PUBLIC tkrng::tkrng) target_link_libraries(tket PUBLIC tktokenswap::tktokenswap) target_link_libraries(tket PRIVATE tkwsm::tkwsm) +target_link_libraries(tket PRIVATE gmp::gmp) IF(APPLE) target_link_libraries(tket PRIVATE "-flat_namespace") ENDIF() diff --git a/tket/cmake/tketConfig.cmake.in b/tket/cmake/tketConfig.cmake.in index 0939348878..0997fe7f3c 100644 --- a/tket/cmake/tketConfig.cmake.in +++ b/tket/cmake/tketConfig.cmake.in @@ -4,6 +4,11 @@ get_filename_component(TKET_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) include(CMakeFindDependencyMacro) find_package(Boost CONFIG REQUIRED) +find_package(gmp CONFIG) +if (NOT gmp_FOUND) + find_package(PkgConfig REQUIRED) + pkg_search_module(gmp REQUIRED IMPORTED_TARGET gmp) +endif() find_package(SymEngine CONFIG REQUIRED) find_package(Eigen3 CONFIG REQUIRED) find_package(nlohmann_json CONFIG REQUIRED) @@ -16,4 +21,4 @@ if(NOT TARGET tket::tket) include("${TKET_CMAKE_DIR}/tketTargets.cmake") endif() -set(TKET_lIBRARIES tket::tket) +set(TKET_LIBRARIES tket::tket)