From b422d3957ece661c4b9f3c444e41b7476f62dd54 Mon Sep 17 00:00:00 2001 From: Frederick Roy <fredroy@users.noreply.github.com> Date: Wed, 22 Nov 2023 13:33:23 +0100 Subject: [PATCH] [LinearAlgera, Core] Fix linking with LTO on MacOS/Clang (#4293) Fix linking with LTO on macos --- Sofa/framework/Core/CMakeLists.txt | 1 + .../src/sofa/core/topology/TopologyData.cpp | 32 +++++++++++++++++++ .../src/sofa/core/topology/TopologyData.h | 4 +++ .../core/topology/TopologySubsetIndices.cpp | 1 - .../src/sofa/linearalgebra/FullVector.cpp | 2 +- .../src/sofa/linearalgebra/FullVector.h | 2 +- 6 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 Sofa/framework/Core/src/sofa/core/topology/TopologyData.cpp diff --git a/Sofa/framework/Core/CMakeLists.txt b/Sofa/framework/Core/CMakeLists.txt index 88e44c0829c..8ba69b2f109 100644 --- a/Sofa/framework/Core/CMakeLists.txt +++ b/Sofa/framework/Core/CMakeLists.txt @@ -306,6 +306,7 @@ set(SOURCE_FILES ${SRC_ROOT}/topology/Topology.cpp ${SRC_ROOT}/topology/TopologyChange.cpp ${SRC_ROOT}/topology/TopologyHandler.cpp + ${SRC_ROOT}/topology/TopologyData.cpp ${SRC_ROOT}/topology/TopologySubsetIndices.cpp ${SRC_ROOT}/visual/Data[DisplayFlags].cpp ${SRC_ROOT}/visual/DisplayFlags.cpp diff --git a/Sofa/framework/Core/src/sofa/core/topology/TopologyData.cpp b/Sofa/framework/Core/src/sofa/core/topology/TopologyData.cpp new file mode 100644 index 00000000000..ac1a0847a0c --- /dev/null +++ b/Sofa/framework/Core/src/sofa/core/topology/TopologyData.cpp @@ -0,0 +1,32 @@ +/****************************************************************************** +* SOFA, Simulation Open-Framework Architecture * +* (c) 2006 INRIA, USTL, UJF, CNRS, MGH * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU Lesser General Public License as published by * +* the Free Software Foundation; either version 2.1 of the License, or (at * +* your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but WITHOUT * +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * +* for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with this program. If not, see <http://www.gnu.org/licenses/>. * +******************************************************************************* +* Authors: The SOFA Team and external contributors (see Authors.txt) * +* * +* Contact information: contact@sofa-framework.org * +******************************************************************************/ +#define SOFA_CORE_TOPOLOGY_TOPOLOGYDATA_DEFINITION + +#include <sofa/core/topology/TopologyData.inl> + + +namespace sofa::core::topology +{ + +template class SOFA_CORE_API sofa::core::topology::TopologyData < core::topology::BaseMeshTopology::Point, type::vector<Index> >; + +} //namespace sofa::core::topology diff --git a/Sofa/framework/Core/src/sofa/core/topology/TopologyData.h b/Sofa/framework/Core/src/sofa/core/topology/TopologyData.h index 645fd16ce9b..25f5366c8d8 100644 --- a/Sofa/framework/Core/src/sofa/core/topology/TopologyData.h +++ b/Sofa/framework/Core/src/sofa/core/topology/TopologyData.h @@ -164,5 +164,9 @@ template< class VecT > using QuadData = TopologyData<core::topology::Base template< class VecT > using TetrahedronData = TopologyData<core::topology::BaseMeshTopology::Tetrahedron, VecT>; template< class VecT > using HexahedronData = TopologyData<core::topology::BaseMeshTopology::Hexahedron, VecT>; +#if !defined(SOFA_CORE_TOPOLOGY_TOPOLOGYDATA_DEFINITION) +extern template class SOFA_CORE_API sofa::core::topology::TopologyData < core::topology::BaseMeshTopology::Point, type::vector<Index> >; +#endif + } //namespace sofa::core::topology diff --git a/Sofa/framework/Core/src/sofa/core/topology/TopologySubsetIndices.cpp b/Sofa/framework/Core/src/sofa/core/topology/TopologySubsetIndices.cpp index 38770cc257c..59c5dfc48f1 100644 --- a/Sofa/framework/Core/src/sofa/core/topology/TopologySubsetIndices.cpp +++ b/Sofa/framework/Core/src/sofa/core/topology/TopologySubsetIndices.cpp @@ -85,7 +85,6 @@ void TopologySubsetIndices::updateLastIndex(Index posLastIndex, Index newGlobalI } template class SOFA_CORE_API sofa::core::topology::TopologyDataHandler < core::topology::BaseMeshTopology::Point, type::vector<Index> >; -template class SOFA_CORE_API sofa::core::topology::TopologyData < core::topology::BaseMeshTopology::Point, type::vector<Index> >; //template class SOFA_CORE_API sofa::core::topology::BaseTopologyData < type::vector<Index> >; } //namespace sofa::core::topology diff --git a/Sofa/framework/LinearAlgebra/src/sofa/linearalgebra/FullVector.cpp b/Sofa/framework/LinearAlgebra/src/sofa/linearalgebra/FullVector.cpp index 35e24709a93..104a3d23deb 100644 --- a/Sofa/framework/LinearAlgebra/src/sofa/linearalgebra/FullVector.cpp +++ b/Sofa/framework/LinearAlgebra/src/sofa/linearalgebra/FullVector.cpp @@ -19,7 +19,7 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#define SOFABASELINEARSOLVER_FULLMATRIX_DEFINITION +#define SOFA_LINEARALGEBRA_FULLVECTOR_DEFINITION #include <sofa/linearalgebra/FullVector.inl> namespace sofa::linearalgebra diff --git a/Sofa/framework/LinearAlgebra/src/sofa/linearalgebra/FullVector.h b/Sofa/framework/LinearAlgebra/src/sofa/linearalgebra/FullVector.h index 628a702fe36..8f4e7b0a71e 100644 --- a/Sofa/framework/LinearAlgebra/src/sofa/linearalgebra/FullVector.h +++ b/Sofa/framework/LinearAlgebra/src/sofa/linearalgebra/FullVector.h @@ -220,7 +220,7 @@ class FullVector : public linearalgebra::BaseVector SOFA_LINEARALGEBRA_API std::ostream& operator <<(std::ostream& out, const FullVector<float>& v); SOFA_LINEARALGEBRA_API std::ostream& operator <<(std::ostream& out, const FullVector<double>& v); -#if !defined(SOFABASELINEARSOLVER_FULLMATRIX_DEFINITION) +#if !defined(SOFA_LINEARALGEBRA_FULLVECTOR_DEFINITION) extern template class SOFA_LINEARALGEBRA_API FullVector<float>; extern template class SOFA_LINEARALGEBRA_API FullVector<double>; #endif