View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0002113 | FEM | Bug | public | 2015-05-22 20:22 | 2016-07-16 20:01 |
Reporter | Fat-Zer | Assigned To | |||
Priority | normal | Severity | minor | Reproducibility | have not tried |
Status | closed | Resolution | fixed | ||
Fixed in Version | 0.17 | ||||
Summary | 0002113: [build issue]netgen library version is nailed to OS rather than determined during build time. | ||||
Description | Currently salomesmesh nailed to netgen-5 on windows and netgen-4 on linux. That one supposed to be reworked to a configuration time determiation of the version or features provided by the library. | ||||
Steps To Reproduce | Install netgen-5 on linux Try to build Freecad with -DBUILD_FEM_NETGEN -DFREECAD_USE_EXTERNAL_SMESH=OFF See the fail because sources are trying to compile against wrong library version. | ||||
Tags | FEM | ||||
FreeCAD Information | |||||
related to | 0001462 | closed | FreeCAD | Support linking of Netgen 5.1 |
|
This bug report is related to issue 0001462. The following patch solves the problem for me using Netgen V5.3: In the MeshDesign Workbench I am able to genereate all kind of Meshes (Netgen/Mefisto/Standard). The FEM Workbench I haven't tested yet. OS: Ubuntu 15.04 Word size of OS: 64-bit Word size of FreeCAD: 64-bit Version: 0.16.5096 (Git) Build type: Unknown Branch: master Hash: d0d98b87751f4e5308916f509b72f14053caa61e Python version: 2.7.9 Qt version: 4.8.6 Coin version: 4.0.0a OCC version: 6.7.1.oce-0.16 |
|
netgen_unix_v5.patch (2,351 bytes)
diff --git a/cMake/FindNETGEN.cmake b/cMake/FindNETGEN.cmake index c93aca0..7a52ef1 100644 --- a/cMake/FindNETGEN.cmake +++ b/cMake/FindNETGEN.cmake @@ -37,3 +37,36 @@ SET(NETGEN_INCLUDE_DIRS ${NETGEN_INCLUDE_DIRS} ${NETGEN_DIR_mesh}) SET(NETGEN_INCLUDE_DIRS ${NETGEN_INCLUDE_DIRS} ${NETGEN_DIR_occ}) SET(NETGEN_INCLUDE_DIRS ${NETGEN_INCLUDE_DIRS} ${NETGEN_DIR_stlgeom}) + +############################################# +# WIN32: Netgen V5 is assumed # +# UNIX : Netgen version is determined below # +############################################# +IF(UNIX) + SET(NETGEN_TEST_CPP "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/netgen_test.cpp") + FILE(WRITE "${NETGEN_TEST_CPP}" " +#include <meshing.hpp> + +void func(netgen::Mesh& mesh) { + + /* + The function call to Mesh::CalcLocalH() depends on the Netgen Version: + => V4: CalcLocalH() + => V5: CalcLocalH(double) + (see /src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_Mesher.cpp) + */ + mesh.CalcLocalH(0.); +} +") + TRY_COMPILE(HAVE_NETGEN_V5 + "${CMAKE_CURRENT_BINARY_DIR}" + "${NETGEN_TEST_CPP}" + CMAKE_FLAGS -DCMAKE_CXX_LINK_EXECUTABLE='echo not linking now ...' + COMPILE_DEFINITIONS -DNETGEN_V5 -I"${NETGEN_DIR_mesh}" -I"${NETGEN_DIR_gen}" -I"${NETGEN_DIR_la}" + OUTPUT_VARIABLE NETGEN_TEST_CPP_DEBUG) + + IF(HAVE_NETGEN_V5) + MESSAGE(STATUS "NETGENPlugin requires V5 switch") + SET(NETGEN_VERSION_SWITCH "-DNETGEN_V5") + ENDIF(HAVE_NETGEN_V5) +ENDIF(UNIX) diff --git a/src/3rdParty/salomesmesh/CMakeLists.txt b/src/3rdParty/salomesmesh/CMakeLists.txt index 972c079..2b7544b 100644 --- a/src/3rdParty/salomesmesh/CMakeLists.txt +++ b/src/3rdParty/salomesmesh/CMakeLists.txt @@ -357,6 +357,11 @@ SET_BIN_DIR(NETGENPlugin NETGENPlugin) if(WIN32) set_target_properties(NETGENPlugin PROPERTIES COMPILE_FLAGS "-DNETGENPLUGIN_EXPORTS -DNO_PARALLEL_THREADS -DOCCGEOMETRY -DNETGEN_V5") endif(WIN32) +if(UNIX) + # Traditionally, Netgen V4 has been compiled without any target properties on UNIX. + # Hence, we introduce here just the version switch and omit the other flags used on WIN32. + set_target_properties(NETGENPlugin PROPERTIES COMPILE_FLAGS "${NETGEN_VERSION_SWITCH}") +endif(UNIX) endif (BUILD_FEM_NETGEN) |
|
mauriz, I appreciate your work, but I don't really like your patch: you are supposed to use CheckCXXSourceCompiles cmake macro rather than do it's job by hands. |
|
Thanks for your input. I will rewrite the patch accordingly this week. Mauriz |
|
A related forum link: http://forum.freecadweb.org/viewtopic.php?f=4&t=3863&start=10 |
|
netgen_unix_v5_b.patch (2,699 bytes)
diff --git a/cMake/FindNETGEN.cmake b/cMake/FindNETGEN.cmake index c93aca0..0a5f9a9 100644 --- a/cMake/FindNETGEN.cmake +++ b/cMake/FindNETGEN.cmake @@ -37,3 +37,58 @@ SET(NETGEN_INCLUDE_DIRS ${NETGEN_INCLUDE_DIRS} ${NETGEN_DIR_mesh}) SET(NETGEN_INCLUDE_DIRS ${NETGEN_INCLUDE_DIRS} ${NETGEN_DIR_occ}) SET(NETGEN_INCLUDE_DIRS ${NETGEN_INCLUDE_DIRS} ${NETGEN_DIR_stlgeom}) + +############################################# +# WIN32: Netgen V5 is assumed # +# UNIX : Netgen version is determined below # +############################################# +IF(UNIX) + IF(NOT HAVE_NETGEN_V4 AND NOT HAVE_NETGEN_V5) + # unset cache and try again ... + UNSET(HAVE_NETGEN_V4 CACHE) + UNSET(HAVE_NETGEN_V5 CACHE) + + # libmesh is needed here to link the tests below + GET_FILENAME_COMPONENT(NGLIB_PATH ${NGLIB_LIBRARIES} DIRECTORY) + FIND_LIBRARY(NGLIB_MESH_LIBRARY mesh ${NGLIB_PATH}) + + SET(CMAKE_REQUIRED_INCLUDES + ${NETGEN_DIR_mesh} + ${NETGEN_DIR_gen} + ${NETGEN_DIR_la} + ) + SET(CMAKE_REQUIRED_LIBRARIES + ${NGLIB_MESH_LIBRARY} + ${NGLIB_LIBRARIES} + ) + UNSET(NGLIB_MESH_LIBRARY CACHE) + + CHECK_CXX_SOURCE_COMPILES( + " + #include <meshing.hpp> + + int main() { + netgen::Mesh* mesh; + mesh->CalcLocalH(); + } + " + HAVE_NETGEN_V4 + ) + CHECK_CXX_SOURCE_COMPILES( + " + #include <meshing.hpp> + + int main() { + netgen::Mesh* mesh; + mesh->CalcLocalH(0.); + } + " + HAVE_NETGEN_V5 + ) + ENDIF(NOT HAVE_NETGEN_V4 AND NOT HAVE_NETGEN_V5) + + IF(HAVE_NETGEN_V5) + SET(NETGEN_VERSION_SWITCH "-DNETGEN_V5") + ENDIF(HAVE_NETGEN_V5) + +ENDIF(UNIX) diff --git a/src/3rdParty/salomesmesh/CMakeLists.txt b/src/3rdParty/salomesmesh/CMakeLists.txt index 972c079..2b7544b 100644 --- a/src/3rdParty/salomesmesh/CMakeLists.txt +++ b/src/3rdParty/salomesmesh/CMakeLists.txt @@ -357,6 +357,11 @@ SET_BIN_DIR(NETGENPlugin NETGENPlugin) if(WIN32) set_target_properties(NETGENPlugin PROPERTIES COMPILE_FLAGS "-DNETGENPLUGIN_EXPORTS -DNO_PARALLEL_THREADS -DOCCGEOMETRY -DNETGEN_V5") endif(WIN32) +if(UNIX) + # Traditionally, Netgen V4 has been compiled without any target properties on UNIX. + # Hence, we introduce here just the version switch and omit the other flags used on WIN32. + set_target_properties(NETGENPlugin PROPERTIES COMPILE_FLAGS "${NETGEN_VERSION_SWITCH}") +endif(UNIX) endif (BUILD_FEM_NETGEN) |
|
Hello Fat-Zer, please test the latest version of the patch and give me your comments. Feel free to modify/rewrite it. The NETGENPlugin target properties work on my side. Neverthless, some adjustements might become necessary. Mauriz |
|
Hello, sorry, I haven't replied for a while. I'm still not satisfied here are several notices: 1. Changes to CMAKE_REQUIRED_* supposed to be wrapped in the cmake_{push,pop}_check_state() to not to taint the caller's variables 2. There isn't a lot of sense in checking HAVE_NETGEN_V4 3. You shouldn't unset cached variables unless you have strong reasons for it, also check them with if() is excess. I'm going to rewrite the FindNETGEN completely including the code snippet if you don't mind. |
|
Discussion on proposed changes on the forum: http://forum.freecadweb.org/viewtopic.php?f=18&t=11859 |
|
http://forum.freecadweb.org/viewtopic.php?f=17&t=11713&p=94204#p94204 http://forum.freecadweb.org/viewtopic.php?f=18&t=11859 |
Date Modified | Username | Field | Change |
---|---|---|---|
2015-05-22 20:22 | Fat-Zer | New Issue | |
2015-06-14 12:43 | mauriz | Note Added: 0006203 | |
2015-06-14 12:44 | mauriz | File Added: netgen_unix_v5.patch | |
2015-06-15 17:04 | Fat-Zer | Note Added: 0006206 | |
2015-06-15 17:33 | mauriz | Note Added: 0006207 | |
2015-06-17 13:00 | wmayer | Relationship added | related to 0001462 |
2015-06-17 13:01 | wmayer | Note Added: 0006209 | |
2015-06-18 19:38 | mauriz | File Added: netgen_unix_v5_b.patch | |
2015-06-18 19:43 | mauriz | Note Added: 0006213 | |
2015-07-18 19:57 | Fat-Zer | Note Added: 0006249 | |
2015-07-20 04:39 | Fat-Zer | Note Added: 0006254 | |
2015-11-28 18:12 | wmayer | Note Added: 0006558 | |
2016-03-21 16:44 | berndhahnebach | Tag Attached: FEM | |
2016-03-22 10:49 | berndhahnebach | Project | FreeCAD => FEM |
2016-07-16 20:01 | wmayer | Status | new => closed |
2016-07-16 20:01 | wmayer | Resolution | open => fixed |
2016-07-16 20:01 | wmayer | Fixed in Version | => 0.17 |