From 68cc427b008221854b8b88a4b52aab4064b12b2c Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 28 Apr 2018 12:10:55 +0200 Subject: [PATCH] Improve handling of external smesh + add SMESH_version.h.cmake to set full version number instead of using compiler define + do not set include path of smesh globally + do not set library path of smesh globally + do not set HAVE_NETGEN define globally + improve using debug and release libs of smesh for MSVC --- CMakeLists.txt | 10 ++-- SMESH_Version.h.cmake | 12 +++++ src/Mod/Fem/App/AppFem.cpp | 1 + src/Mod/Fem/App/AppFemPy.cpp | 3 -- src/Mod/Fem/App/CMakeLists.txt | 22 ++++---- src/Mod/Fem/App/FemMesh.cpp | 4 +- src/Mod/Fem/App/FemMesh.h | 1 + src/Mod/Fem/App/FemMeshPyImp.cpp | 4 +- src/Mod/Fem/App/FemMeshShapeNetgenObject.cpp | 4 +- src/Mod/Fem/App/FemMeshShapeObject.cpp | 3 -- src/Mod/Fem/App/FemVTKTools.cpp | 4 +- src/Mod/Fem/App/HypothesisPy.cpp | 2 +- src/Mod/Fem/App/HypothesisPy.h | 3 +- src/Mod/Fem/Gui/CMakeLists.txt | 1 + src/Mod/MeshPart/App/CMakeLists.txt | 54 +++++++++----------- src/Mod/MeshPart/App/Mesher.cpp | 10 ++-- src/Mod/MeshPart/App/Mesher.h | 1 + src/Mod/MeshPart/Gui/CMakeLists.txt | 2 + 18 files changed, 71 insertions(+), 70 deletions(-) create mode 100644 SMESH_Version.h.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index beb53a3e11..d26642a52b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -650,6 +650,9 @@ endif() IF(BUILD_SMESH) # set the internal smesh version: set(SMESH_VERSION_MAJOR 5) # in src/3rdParty it says smesh is version 5.*, is this true? + set(SMESH_VERSION_MINOR 1) + set(SMESH_VERSION_PATCH 2) + set(SMESH_VERSION_TWEAK 2) #if we use smesh we definitely also need vtk, no matter of external or internal smesh set (VTK_COMPONENTS @@ -740,11 +743,8 @@ endif() else(NOT FREECAD_USE_EXTERNAL_SMESH) find_package(SMESH CONFIG) - include_directories(${SMESH_INCLUDE_DIR}) - link_directories(${SMESH_LIB_PATH}) + set (SMESH_INCLUDE_DIR ${SMESH_INCLUDE_PATH}) SET(EXTERNAL_SMESH_LIBS ${SMESH_LIBRARIES}) - add_definitions(-DHAVE_NETGEN) - add_definitions(-DSMESH_VERSION_MAJOR=${SMESH_VERSION_MAJOR}) if(NOT SMESH_FOUND) message(ERROR "================\n" "SMESH not found.\n" @@ -752,7 +752,9 @@ endif() endif() include_directories(${SMESH_INCLUDE_DIR}) endif() + set(SMESH_FOUND TRUE) + configure_file(SMESH_Version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/SMESH_Version.h) ENDIF(BUILD_SMESH) # -------------------------------- Netgen -------------------------------- diff --git a/SMESH_Version.h.cmake b/SMESH_Version.h.cmake new file mode 100644 index 0000000000..b311f984a6 --- /dev/null +++ b/SMESH_Version.h.cmake @@ -0,0 +1,12 @@ +#ifndef SMESH_VERSION_H +#define SMESH_VERSION_H + +/* SMESH_Version.h. Generated from SMESH_Version.h.cmake by cmake. */ + +// SMESH version +#define SMESH_VERSION_MAJOR ${SMESH_VERSION_MAJOR} +#define SMESH_VERSION_MINOR ${SMESH_VERSION_MINOR} +#define SMESH_VERSION_PATCH ${SMESH_VERSION_PATCH} +#define SMESH_VERSION_TWEAK ${SMESH_VERSION_TWEAK} + +#endif // SMESH_VERSION_H diff --git a/src/Mod/Fem/App/AppFem.cpp b/src/Mod/Fem/App/AppFem.cpp index 297d79428a..108b9ec35d 100644 --- a/src/Mod/Fem/App/AppFem.cpp +++ b/src/Mod/Fem/App/AppFem.cpp @@ -30,6 +30,7 @@ #include #include +#include #include "FemMeshPy.h" #include "FemMesh.h" #include "FemMeshProperty.h" diff --git a/src/Mod/Fem/App/AppFemPy.cpp b/src/Mod/Fem/App/AppFemPy.cpp index 7a05bcec35..e9dd68a939 100644 --- a/src/Mod/Fem/App/AppFemPy.cpp +++ b/src/Mod/Fem/App/AppFemPy.cpp @@ -50,9 +50,6 @@ #include #include #include -#if SMESH_VERSION_MAJOR < 7 - #include -#endif #include #include #include diff --git a/src/Mod/Fem/App/CMakeLists.txt b/src/Mod/Fem/App/CMakeLists.txt index cd4bba85ea..a3b59e328e 100644 --- a/src/Mod/Fem/App/CMakeLists.txt +++ b/src/Mod/Fem/App/CMakeLists.txt @@ -28,23 +28,23 @@ include_directories( link_directories(${OCC_LIBRARY_DIR}) +link_directories(${SMESH_LIB_PATH}) set(Fem_LIBS Part FreeCADApp - StdMeshers - SMESH - SMDS - SMESHDS ) - -if(BUILD_FEM_NETGEN) - list(APPEND Fem_LIBS - NETGENPlugin - ) -endif(BUILD_FEM_NETGEN) +if (FREECAD_USE_EXTERNAL_SMESH) + list(APPEND Fem_LIBS ${EXTERNAL_SMESH_LIBS}) +else() + if (BUILD_FEM_NETGEN) + list(APPEND Fem_LIBS StdMeshers SMESH SMDS SMESHDS NETGENPlugin) + else () + list(APPEND Fem_LIBS StdMeshers SMESH SMDS SMESHDS) + endif() +endif() generate_from_xml(FemMeshPy) @@ -181,7 +181,7 @@ SET(Fem_SRCS add_library(Fem SHARED ${Fem_SRCS}) -target_link_libraries(Fem ${Fem_LIBS} ${VTK_LIBRARIES} ${EXTERNAL_SMESH_LIBS}) +target_link_libraries(Fem ${Fem_LIBS} ${VTK_LIBRARIES}) SET_BIN_DIR(Fem Fem /Mod/Fem) diff --git a/src/Mod/Fem/App/FemMesh.cpp b/src/Mod/Fem/App/FemMesh.cpp index 3ff5bb36dc..096da47374 100644 --- a/src/Mod/Fem/App/FemMesh.cpp +++ b/src/Mod/Fem/App/FemMesh.cpp @@ -50,7 +50,7 @@ #include "FemMesh.h" #ifdef FC_USE_VTK - #include "FemVTKTools.h" +#include "FemVTKTools.h" #endif #include @@ -496,7 +496,7 @@ SMESH_Gen * FemMesh::getGenerator() #if SMESH_VERSION_MAJOR < 7 return SMESH_Gen::get(); #else - if (! FemMesh::_mesh_gen) + if (!FemMesh::_mesh_gen) FemMesh::_mesh_gen = new SMESH_Gen(); return FemMesh::_mesh_gen; #endif diff --git a/src/Mod/Fem/App/FemMesh.h b/src/Mod/Fem/App/FemMesh.h index e335e9c867..bb7db7d3e8 100644 --- a/src/Mod/Fem/App/FemMesh.h +++ b/src/Mod/Fem/App/FemMesh.h @@ -31,6 +31,7 @@ #include #include #include +#include class SMESH_Gen; class SMESH_Mesh; diff --git a/src/Mod/Fem/App/FemMeshPyImp.cpp b/src/Mod/Fem/App/FemMeshPyImp.cpp index 70fc732c5e..6afef7c92c 100644 --- a/src/Mod/Fem/App/FemMeshPyImp.cpp +++ b/src/Mod/Fem/App/FemMeshPyImp.cpp @@ -37,9 +37,7 @@ #include #include #include -#if SMESH_VERSION_MAJOR >= 7 - #include -#endif +#include #include #include diff --git a/src/Mod/Fem/App/FemMeshShapeNetgenObject.cpp b/src/Mod/Fem/App/FemMeshShapeNetgenObject.cpp index a30b677852..4201eebd38 100644 --- a/src/Mod/Fem/App/FemMeshShapeNetgenObject.cpp +++ b/src/Mod/Fem/App/FemMeshShapeNetgenObject.cpp @@ -34,9 +34,7 @@ #include #include -#if SMESH_VERSION_MAJOR >= 7 - #include -#endif +#include #include #include diff --git a/src/Mod/Fem/App/FemMeshShapeObject.cpp b/src/Mod/Fem/App/FemMeshShapeObject.cpp index a2c690f101..07824bdc1f 100644 --- a/src/Mod/Fem/App/FemMeshShapeObject.cpp +++ b/src/Mod/Fem/App/FemMeshShapeObject.cpp @@ -61,9 +61,6 @@ #include #include #include -#if SMESH_VERSION_MAJOR < 7 - #include -#endif #include #include #include diff --git a/src/Mod/Fem/App/FemVTKTools.cpp b/src/Mod/Fem/App/FemVTKTools.cpp index 1e8286eebe..92bd9b8938 100644 --- a/src/Mod/Fem/App/FemVTKTools.cpp +++ b/src/Mod/Fem/App/FemVTKTools.cpp @@ -53,9 +53,7 @@ #include #include #include -#if SMESH_VERSION_MAJOR >= 7 - #include -#endif +#include # include # include diff --git a/src/Mod/Fem/App/HypothesisPy.cpp b/src/Mod/Fem/App/HypothesisPy.cpp index 99f90cd34a..aa7b097158 100755 --- a/src/Mod/Fem/App/HypothesisPy.cpp +++ b/src/Mod/Fem/App/HypothesisPy.cpp @@ -54,7 +54,7 @@ #include #include #if SMESH_VERSION_MAJOR < 7 - #include +#include #endif #include #include diff --git a/src/Mod/Fem/App/HypothesisPy.h b/src/Mod/Fem/App/HypothesisPy.h index ed8db84ca2..2949c1f0b9 100755 --- a/src/Mod/Fem/App/HypothesisPy.h +++ b/src/Mod/Fem/App/HypothesisPy.h @@ -25,6 +25,7 @@ #include #include +#include class SMESH_Hypothesis; class SMESH_Gen; @@ -60,7 +61,7 @@ public: Py::Object repr(); Py::Object getLibName(const Py::Tuple& args); Py::Object setLibName(const Py::Tuple& args); -#ifndef EXTERNAL_SMESH +#if SMESH_VERSION_MAJOR < 7 Py::Object setParameters(const Py::Tuple& args); Py::Object getParameters(const Py::Tuple& args); Py::Object setLastParameters(const Py::Tuple& args); diff --git a/src/Mod/Fem/Gui/CMakeLists.txt b/src/Mod/Fem/Gui/CMakeLists.txt index 6b2c4501bd..b1c5298f12 100755 --- a/src/Mod/Fem/Gui/CMakeLists.txt +++ b/src/Mod/Fem/Gui/CMakeLists.txt @@ -25,6 +25,7 @@ include_directories( ) link_directories(${OCC_LIBRARY_DIR}) +link_directories(${SMESH_LIB_PATH}) set(FemGui_LIBS diff --git a/src/Mod/MeshPart/App/CMakeLists.txt b/src/Mod/MeshPart/App/CMakeLists.txt index 6c644e9ca8..fe3e1d124a 100644 --- a/src/Mod/MeshPart/App/CMakeLists.txt +++ b/src/Mod/MeshPart/App/CMakeLists.txt @@ -13,6 +13,7 @@ if(BUILD_FEM_NETGEN) endif(BUILD_FEM_NETGEN) include_directories( + ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/src ${Boost_INCLUDE_DIRS} ${OCC_INCLUDE_DIR} @@ -26,31 +27,22 @@ include_directories( link_directories(${OCC_LIBRARY_DIR}) +link_directories(${SMESH_LIB_PATH}) +set(MeshPart_LIBS + Part + Mesh +) -if(BUILD_FEM_NETGEN) - set(MeshPart_LIBS - Part - Mesh - StdMeshers - NETGENPlugin - SMESH - SMDS - ) -elseif(BUILD_SMESH) - set(MeshPart_LIBS - Part - Mesh - StdMeshers - SMESH - SMDS - ) -else(BUILD_FEM_NETGEN) - set(MeshPart_LIBS - Part - Mesh - ) -endif(BUILD_FEM_NETGEN) +if (FREECAD_USE_EXTERNAL_SMESH) + list(APPEND MeshPart_LIBS ${EXTERNAL_SMESH_LIBS}) +else() + if (BUILD_FEM_NETGEN) + list(APPEND MeshPart_LIBS StdMeshers NETGENPlugin SMESH SMDS) + elseif (BUILD_SMESH) + list(APPEND MeshPart_LIBS StdMeshers SMESH SMDS) + endif() +endif() SET(MeshPart_SRCS @@ -67,7 +59,7 @@ SET(MeshPart_SRCS ) add_library(MeshPart SHARED ${MeshPart_SRCS}) -target_link_libraries(MeshPart ${MeshPart_LIBS} ${EXTERNAL_SMESH_LIBS}) +target_link_libraries(MeshPart ${MeshPart_LIBS}) fc_target_copy_resource(MeshPart @@ -84,13 +76,13 @@ INSTALL(TARGETS MeshPart DESTINATION ${CMAKE_INSTALL_LIBDIR}) ################################ flat mesh ############################### if (FREECAD_USE_PYBIND11) SET(FLATMESH_SRCS - MeshFlattening.cpp - MeshFlattening.h - MeshFlatteningNurbs.h - MeshFlatteningNurbs.cpp - MeshFlatteningLscmRelax.h - MeshFlatteningLscmRelax.cpp - MeshFlatteningPy.cpp + MeshFlattening.cpp + MeshFlattening.h + MeshFlatteningNurbs.h + MeshFlatteningNurbs.cpp + MeshFlatteningLscmRelax.h + MeshFlatteningLscmRelax.cpp + MeshFlatteningPy.cpp ) diff --git a/src/Mod/MeshPart/App/Mesher.cpp b/src/Mod/MeshPart/App/Mesher.cpp index a8bdbfa732..5c2796a30a 100644 --- a/src/Mod/MeshPart/App/Mesher.cpp +++ b/src/Mod/MeshPart/App/Mesher.cpp @@ -40,14 +40,14 @@ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Woverloaded-virtual" #endif + #include #include +#include +#include -#if SMESH_VERSION_MAJOR >= 7 - #include - #include -#else - #include +#if SMESH_VERSION_MAJOR < 7 +#include #endif #include diff --git a/src/Mod/MeshPart/App/Mesher.h b/src/Mod/MeshPart/App/Mesher.h index 079454a080..ecb5ca9ab4 100644 --- a/src/Mod/MeshPart/App/Mesher.h +++ b/src/Mod/MeshPart/App/Mesher.h @@ -25,6 +25,7 @@ #include #include +#include class TopoDS_Shape; class SMESH_Gen; diff --git a/src/Mod/MeshPart/Gui/CMakeLists.txt b/src/Mod/MeshPart/Gui/CMakeLists.txt index 943449547c..f66c4cad53 100644 --- a/src/Mod/MeshPart/Gui/CMakeLists.txt +++ b/src/Mod/MeshPart/Gui/CMakeLists.txt @@ -23,7 +23,9 @@ include_directories( ${PYTHON_INCLUDE_DIRS} ${XercesC_INCLUDE_DIRS} ) + link_directories(${OCC_LIBRARY_DIR}) +link_directories(${SMESH_LIB_PATH}) set(MeshPartGui_LIBS MeshPart