Permalink
Browse files

Support for NETGEN 6.2.

Upstream changed:
https://sourceforge.net/p/netgen-mesher/git/ci/7e4892a

There is also a pending request to fix NETGEN build, installation and version detection after 6.1:
https://sourceforge.net/p/netgen-mesher/git/merge-requests/1/

Just a note:
NETGEN development happens on https://gitlab.asc.tuwien.ac.at/jschoeberl/netgen but it is a very hard/strange way to find that out and get in contact with NETGEN developers as well as getting permission to fork the repository there to create a pull request.
Maybe some other developer can get in contact with NETGEN developers ...
  • Loading branch information...
1 parent cd59747 commit 55160cf50db0b433c9dd13e9e3573ae8c19fa190 @jobermayr jobermayr committed with wwmayer Dec 11, 2016
@@ -107,11 +107,14 @@ ELSE()
file(STRINGS ${NETGEN_DIR_include}/mydefs.hpp NETGEN_VERSION
REGEX "#define PACKAGE_VERSION.*"
)
- string(REGEX MATCH "[0-9]+" NETGEN_VERSION ${NETGEN_VERSION})
-# EXECUTE_PROCESS(COMMAND grep -e ".*define.*PACKAGE_VERSION" ${NETGEN_DIR_include}/mydefs.hpp
-# COMMAND sed -r "s:.*PACKAGE_VERSION \"([0-9]*).*:\\1:g"
-# OUTPUT_VARIABLE NETGEN_VERSION
-# OUTPUT_STRIP_TRAILING_WHITESPACE)
+ string(REGEX MATCHALL "[0-9]+" NETGEN_VERSION ${NETGEN_VERSION})
+ list(LENGTH NETGEN_VERSION NETGEN_VERSION_COUNT)
+ list(GET NETGEN_VERSION 0 NETGEN_VERSION_MAJOR)
+ if(NETGEN_VERSION_COUNT GREATER 1)
+ list(GET NETGEN_VERSION 1 NETGEN_VERSION_MINOR)
+ else()
+ set(NETGEN_VERSION_MINOR 0)
+ endif()
ENDIF()
IF(NOT NGLIB_LIBRARIES)
@@ -125,7 +128,40 @@ IF(NGLIB_INCLUDE_DIR AND NGLIB_LIBRARIES)
${NETGEN_DIR_gprim} ${NETGEN_DIR_la} ${NETGEN_DIR_mesh}
${NETGEN_DIR_occ} ${NETGEN_DIR_stlgeom})
LIST(REMOVE_DUPLICATES NETGEN_INCLUDE_DIRS)
- MESSAGE(STATUS "Found NETGEN version ${NETGEN_VERSION}")
+ MATH(EXPR NETGEN_VERSION "(${NETGEN_VERSION_MAJOR} << 16) + (${NETGEN_VERSION_MINOR} << 8)")
+ MATH(EXPR NETGEN_VERSION_62 "(6 << 16) + (2 << 8)")
+ IF(NOT NETGEN_VERSION LESS NETGEN_VERSION_62) # Version >= 6.2
+ # NETGEN v6.2 or newer requires c++1y/c++14
+ include(CheckCXXCompilerFlag)
+ check_cxx_compiler_flag("-std=c++14" HAS_CPP14_FLAG)
+ check_cxx_compiler_flag("-std=c++1y" HAS_CPP1Y_FLAG)
+ if(HAS_CPP14_FLAG)
+ set(NETGEN_CXX_FLAGS "-std=c++14")
+ elseif(HAS_CPP1Y_FLAG)
+ set(NETGEN_CXX_FLAGS "-std=c++1y")
+ else()
+ message(FATAL_ERROR "Unsupported compiler -- C++1y support or newer required!")
+ endif()
+ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+ # Clang sometimes fails to include <cstdio>
+ include(CMakePushCheckState)
+ cmake_push_check_state(RESET)
+ set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${NETGEN_CXX_FLAGS}")
+ check_cxx_source_compiles("#include <cstdio>\nint main(){}" CSTDIO_INCLUDE_TRY1)
+ if(NOT CSTDIO_INCLUDE_TRY1)
+ # Ugly hack to make <stdio.h> building gets function
+ set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -U__cplusplus -D__cplusplus=201103L")
+ check_cxx_source_compiles("#include <cstdio>\nint main(){}" CSTDIO_INCLUDE_TRY2)
+ if(NOT CSTDIO_INCLUDE_TRY2)
+ message(FATAL_ERROR "Cannot #include <cstdio>.")
+ else()
+ set(NETGEN_CXX_FLAGS "${NETGEN_CXX_FLAGS} -U__cplusplus -D__cplusplus=201103L")
+ endif()
+ endif()
+ cmake_pop_check_state()
+ endif()
+ ENDIF()
+ MESSAGE(STATUS "Found NETGEN version ${NETGEN_VERSION_MAJOR}.${NETGEN_VERSION_MINOR}, calculated: ${NETGEN_VERSION}")
LIST(APPEND NETGEN_DEFINITIONS -DNETGEN_VERSION=${NETGEN_VERSION})
ELSE()
SET(NETGEN_FOUND FALSE)
@@ -373,6 +373,8 @@ TARGET_LINK_LIBRARIES(NETGENPlugin SMDS SMESHDS SMESH StdMeshers ${SMESH_LIBS} )
SET_BIN_DIR(NETGENPlugin NETGENPlugin)
if(WIN32)
set_target_properties(NETGENPlugin PROPERTIES COMPILE_FLAGS "-DNETGENPLUGIN_EXPORTS -DNO_PARALLEL_THREADS -DOCCGEOMETRY -DNETGEN_VERSION=${NETGEN_VERSION}")
+else()
+ set_target_properties(NETGENPlugin PROPERTIES COMPILE_FLAGS "${NETGEN_CXX_FLAGS}")
endif(WIN32)
endif (BUILD_FEM_NETGEN)
@@ -36,6 +36,8 @@
#include <SMESH_Algo.hxx>
#include <SMESH_ProxyMesh.hxx>
+#define NETGEN_VERSION_STRING(a,b) (a << 16) + (b << 8)
+
namespace nglib {
#include <nglib.h>
}
@@ -83,7 +85,7 @@ struct NETGENPlugin_ngMeshInfo
struct NETGENPLUGIN_EXPORT NETGENPlugin_NetgenLibWrapper
{
bool _isComputeOk;
-#if NETGEN_VERSION < 6
+#if NETGEN_VERSION < NETGEN_VERSION_STRING(6,0)
nglib::Ng_Mesh * _ngMesh;
#else
std::shared_ptr<nglib::Ng_Mesh> _ngMesh;
@@ -202,7 +204,7 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_Mesher
bool _optimize;
int _fineness;
bool _isViscousLayers2D;
-#if NETGEN_VERSION < 6
+#if NETGEN_VERSION < NETGEN_VERSION_STRING(6,0)
netgen::Mesh* _ngMesh;
#else
std::shared_ptr<netgen::Mesh> _ngMesh;
Oops, something went wrong.

0 comments on commit 55160cf

Please sign in to comment.