From dee17b8b942896c51ea8ca216b2648294e7a9738 Mon Sep 17 00:00:00 2001 From: burgholzer Date: Tue, 6 Feb 2024 10:21:16 +0100 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=A9=B9=20protect=20`=5Fcore`=20target?= =?UTF-8?q?=20definition?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/python/CMakeLists.txt | 64 ++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt index 875419898..a6c0b51db 100644 --- a/src/python/CMakeLists.txt +++ b/src/python/CMakeLists.txt @@ -1,32 +1,34 @@ -pybind11_add_module( - # Name of the extension - _core - # Prefer thin LTO if available - THIN_LTO - # Optimize the bindings for size - OPT_SIZE - # Source code goes here - ${MQT_CORE_INCLUDE_BUILD_DIR}/python/pybind11.hpp - module.cpp - register_operations.cpp - register_permutation.cpp - register_symbolic.cpp - register_quantum_computation.cpp - operations/register_optype.cpp - operations/register_control.cpp - operations/register_operation.cpp - operations/register_standard_operation.cpp - operations/register_classic_controlled_operation.cpp - operations/register_compound_operation.cpp - operations/register_non_unitary_operation.cpp - operations/register_symbolic_operation.cpp - symbolic/register_variable.cpp - symbolic/register_term.cpp - symbolic/register_expression.cpp) -target_link_libraries(_core PRIVATE MQT::Core MQT::ProjectOptions MQT::ProjectWarnings) +if(NOT TARGET _core) + pybind11_add_module( + # Name of the extension + _core + # Prefer thin LTO if available + THIN_LTO + # Optimize the bindings for size + OPT_SIZE + # Source code goes here + ${MQT_CORE_INCLUDE_BUILD_DIR}/python/pybind11.hpp + module.cpp + register_operations.cpp + register_permutation.cpp + register_symbolic.cpp + register_quantum_computation.cpp + operations/register_optype.cpp + operations/register_control.cpp + operations/register_operation.cpp + operations/register_standard_operation.cpp + operations/register_classic_controlled_operation.cpp + operations/register_compound_operation.cpp + operations/register_non_unitary_operation.cpp + operations/register_symbolic_operation.cpp + symbolic/register_variable.cpp + symbolic/register_term.cpp + symbolic/register_expression.cpp) + target_link_libraries(_core PRIVATE MQT::Core MQT::ProjectOptions MQT::ProjectWarnings) -# Install directive for scikit-build-core -install( - TARGETS _core - DESTINATION . - COMPONENT MQTCorePythonModule) + # Install directive for scikit-build-core + install( + TARGETS _core + DESTINATION . + COMPONENT MQTCorePythonModule) +endif() From ffe1c66759b80e971c74afe3fee0dfa260b48b1b Mon Sep 17 00:00:00 2001 From: burgholzer Date: Tue, 6 Feb 2024 23:15:36 +0100 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=94=A7=20explicitly=20remove=20transi?= =?UTF-8?q?tive=20includes=20for=20libc++?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmake/CompilerOptions.cmake | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmake/CompilerOptions.cmake b/cmake/CompilerOptions.cmake index 47630ecd2..0c31747b1 100644 --- a/cmake/CompilerOptions.cmake +++ b/cmake/CompilerOptions.cmake @@ -61,4 +61,11 @@ function(enable_project_options target_name) check_pie_supported() set_target_properties(${target_name} PROPERTIES INTERFACE_POSITION_INDEPENDENT_CODE ON) endif() + + # add a compile definition for _LIBCPP_REMOVE_TRANSITIVE_INCLUDES to remove transitive includes + # from libc++ headers. This is useful to avoid including system headers that are not needed and + # that may conflict with other headers. This is only supported by libc++. + if(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") + target_compile_definitions(${target_name} INTERFACE _LIBCPP_REMOVE_TRANSITIVE_INCLUDES) + endif() endfunction() From ade870e1ca61af2694299c547f8323ffe153c40d Mon Sep 17 00:00:00 2001 From: burgholzer Date: Wed, 7 Feb 2024 00:09:10 +0100 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=8E=A8=20explicitly=20use=20`std::`?= =?UTF-8?q?=20prefix=20for=20math=20methods?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/parsers/qasm3_parser/passes/ConstEvalPass.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/parsers/qasm3_parser/passes/ConstEvalPass.cpp b/src/parsers/qasm3_parser/passes/ConstEvalPass.cpp index 69177a03b..c3e2d4338 100644 --- a/src/parsers/qasm3_parser/passes/ConstEvalPass.cpp +++ b/src/parsers/qasm3_parser/passes/ConstEvalPass.cpp @@ -226,7 +226,7 @@ ConstEvalValue ConstEvalPass::evalFloatExpression(BinaryExpression::Op op, switch (op) { case BinaryExpression::Power: - result.value = pow(lhs, rhs); + result.value = std::pow(lhs, rhs); break; case BinaryExpression::Add: result.value = lhs + rhs; @@ -411,42 +411,42 @@ std::optional ConstEvalPass::visitUnaryExpression( return std::nullopt; case UnaryExpression::Sin: if (val->type == ConstEvalValue::Type::ConstFloat) { - val->value = sin(std::get<1>(val->value)); + val->value = std::sin(std::get<1>(val->value)); } else { return std::nullopt; } break; case UnaryExpression::Cos: if (val->type == ConstEvalValue::Type::ConstFloat) { - val->value = cos(std::get<1>(val->value)); + val->value = std::cos(std::get<1>(val->value)); } else { return std::nullopt; } break; case UnaryExpression::Tan: if (val->type == ConstEvalValue::Type::ConstFloat) { - val->value = tan(std::get<1>(val->value)); + val->value = std::tan(std::get<1>(val->value)); } else { return std::nullopt; } break; case UnaryExpression::Exp: if (val->type == ConstEvalValue::Type::ConstFloat) { - val->value = exp(std::get<1>(val->value)); + val->value = std::exp(std::get<1>(val->value)); } else { return std::nullopt; } break; case UnaryExpression::Ln: if (val->type == ConstEvalValue::Type::ConstFloat) { - val->value = log(std::get<1>(val->value)); + val->value = std::log(std::get<1>(val->value)); } else { return std::nullopt; } break; case UnaryExpression::Sqrt: if (val->type == ConstEvalValue::Type::ConstFloat) { - val->value = sqrt(std::get<1>(val->value)); + val->value = std::sqrt(std::get<1>(val->value)); } else { return std::nullopt; }