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() 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; } 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()