Skip to content

Commit 763a397

Browse files
Neumann-Avzhli17
andauthored
[netgen] add new port (microsoft#31288)
* [netgen] add new port * v db * fix config path for linux * v db * add supports * figure out CI error * fix the path correctly * v db * fix install layout * v db * more cleanup * v db * fix cmake usage and missing filesystem include * v db * disable parallel configure * v db * update to latest tag * v db * control cmake install loc * v db * more install control for mac * v db * more mac fixes * v db * remove old version * replace cgns patch * v db --------- Co-authored-by: vzhli17 <[email protected]>
1 parent 67e366d commit 763a397

11 files changed

+313
-0
lines changed

ports/netgen/add_filesystem.patch

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/libsrc/core/logging.hpp b/libsrc/core/logging.hpp
2+
index adfed7e..d34d3e9 100644
3+
--- a/libsrc/core/logging.hpp
4+
+++ b/libsrc/core/logging.hpp
5+
@@ -6,6 +6,7 @@
6+
#include <memory>
7+
#include <string>
8+
#include <vector>
9+
+#include <filesystem>
10+
11+
#include "exception.hpp"
12+
#include "ngcore_api.hpp"

ports/netgen/cgns-scoped-enum.patch

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
diff --git a/libsrc/interface/rw_cgns.cpp b/libsrc/interface/rw_cgns.cpp
2+
index 096fbfdca..edf199cfd 100644
3+
--- a/libsrc/interface/rw_cgns.cpp
4+
+++ b/libsrc/interface/rw_cgns.cpp
5+
@@ -6,6 +6,37 @@
6+
7+
#include <cgnslib.h>
8+
9+
+//vcpkg builds cgns with scoped enumes. So the associcated types and values need to be correctly scoped.
10+
+#define ElementType_t CGNS_ENUMT(ElementType_t)
11+
+#define GridLocation_t CGNS_ENUMT(GridLocation_t)
12+
+#define PointSetType_t CGNS_ENUMT(PointSetType_t)
13+
+#define DataType_t CGNS_ENUMT(DataType_t)
14+
+#define ZoneType_t CGNS_ENUMT(ZoneType_t)
15+
+#define Unstructured CGNS_ENUMV(Unstructured)
16+
+#define RealDouble CGNS_ENUMV(RealDouble)
17+
+#define MIXED CGNS_ENUMV(MIXED)
18+
+#define EdgeCenter CGNS_ENUMV(EdgeCenter)
19+
+#define KFaceCenter CGNS_ENUMV(KFaceCenter)
20+
+#define JFaceCenter CGNS_ENUMV(JFaceCenter)
21+
+#define IFaceCenter CGNS_ENUMV(IFaceCenter)
22+
+#define FaceCenter CGNS_ENUMV(FaceCenter)
23+
+#define CellCenter CGNS_ENUMV(CellCenter)
24+
+#define Vertex CGNS_ENUMV(Vertex)
25+
+#define BAR_2 CGNS_ENUMV(BAR_2)
26+
+#define BAR_3 CGNS_ENUMV(BAR_3)
27+
+#define TRI_3 CGNS_ENUMV(TRI_3)
28+
+#define TRI_6 CGNS_ENUMV(TRI_6)
29+
+#define QUAD_4 CGNS_ENUMV(QUAD_4)
30+
+#define QUAD_8 CGNS_ENUMV(QUAD_8)
31+
+#define TETRA_4 CGNS_ENUMV(TETRA_4)
32+
+#define TETRA_10 CGNS_ENUMV(TETRA_10)
33+
+#define PYRA_5 CGNS_ENUMV(PYRA_5)
34+
+#define PYRA_13 CGNS_ENUMV(PYRA_13)
35+
+#define HEXA_8 CGNS_ENUMV(HEXA_8)
36+
+#define HEXA_20 CGNS_ENUMV(HEXA_20)
37+
+#define PENTA_6 CGNS_ENUMV(PENTA_6)
38+
+#define PENTA_15 CGNS_ENUMV(PENTA_15)
39+
+
40+
namespace netgen::cg
41+
{
42+
typedef ngcore::ClosedHashTable<ngcore::INT<3,size_t>, size_t> PointTable;
43+
@@ -215,7 +246,7 @@ namespace netgen::cg
44+
if(codim==2) name += mesh.GetCD2Name(index);
45+
46+
int ne = 0;
47+
- Array<int> data;
48+
+ Array<cgsize_t> data;
49+
50+
if(dim==3)
51+
for(const auto el : mesh.VolumeElements())
52+
@@ -333,7 +364,7 @@ namespace netgen::cg
53+
ZoneType_t zone_type;
54+
int fn, base, zone;
55+
int first_index_1d, first_index_2d, first_index_3d;
56+
- int nv=0, ne_1d=0, ne_2d=0, ne_3d=0;
57+
+ cgsize_t nv=0, ne_1d=0, ne_2d=0, ne_3d=0;
58+
59+
Array<string> names_1d, names_2d, names_3d;
60+
61+
@@ -643,7 +674,7 @@ namespace netgen
62+
int n_vertices = 0;
63+
for (auto zi : Range(1, nzones+1))
64+
{
65+
- int size[3];
66+
+ cgsize_t size[3];
67+
char name[100];
68+
cg_zone_read(fn,base,zi, name, size);
69+
n_vertices += size[0];

ports/netgen/cmake-adjustments.patch

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
diff --git a/libsrc/core/CMakeLists.txt b/libsrc/core/CMakeLists.txt
2+
index c4f4795..cd5ad50 100644
3+
--- a/libsrc/core/CMakeLists.txt
4+
+++ b/libsrc/core/CMakeLists.txt
5+
@@ -28,8 +28,7 @@ endif(USE_PYTHON)
6+
7+
if(WIN32)
8+
target_compile_options(ngcore PUBLIC /bigobj /MP /W1 /wd4068)
9+
- get_WIN32_WINNT(ver)
10+
- target_compile_definitions(ngcore PUBLIC _WIN32_WINNT=${ver} WNT WNT_WINDOW NOMINMAX MSVC_EXPRESS _CRT_SECURE_NO_WARNINGS HAVE_STRUCT_TIMESPEC WIN32)
11+
+ target_compile_definitions(ngcore PUBLIC WNT WNT_WINDOW NOMINMAX MSVC_EXPRESS _CRT_SECURE_NO_WARNINGS HAVE_STRUCT_TIMESPEC WIN32)
12+
target_link_options(ngcore PUBLIC /ignore:4273 /ignore:4217 /ignore:4049)
13+
endif(WIN32)
14+

ports/netgen/downstream-fixes.patch

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
diff --git a/libsrc/stlgeom/stltopology.hpp b/libsrc/stlgeom/stltopology.hpp
2+
index 2a3822f70..a14dc5bda 100644
3+
--- a/libsrc/stlgeom/stltopology.hpp
4+
+++ b/libsrc/stlgeom/stltopology.hpp
5+
@@ -350,7 +350,7 @@ public:
6+
int GetNP() const { return points.Size(); }
7+
int AddPoint(const Point<3> & p) { points.Append(p); return points.Size(); }
8+
const Point<3> & GetPoint(STLPointId nr) const { return points[nr]; } // .Get(nr); }
9+
+ DLL_HEADER int GetPointNum (const Point<3> & p);
10+
- int GetPointNum (const Point<3> & p);
11+
void SetPoint(STLPointId nr, const Point<3> & p) { points[nr] = p; } // { points.Elem(nr) = p; }
12+
auto & GetPoints() const { return points; }
13+
14+
diff --git a/nglib/nglib.cpp b/nglib/nglib.cpp
15+
index ee25f3814..c8fe35cb2 100644
16+
--- a/nglib/nglib.cpp
17+
+++ b/nglib/nglib.cpp
18+
@@ -619,6 +619,7 @@ namespace nglib
19+
}
20+
*/
21+
geo->AddEdges(readedges);
22+
+ readedges.SetSize(0);
23+
}
24+
25+
if (geo->GetStatus() == STLTopology::STL_GOOD || geo->GetStatus() == STLTopology::STL_WARNING) return NG_OK;

ports/netgen/git-ver.patch

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index 6e9f4cc..bf92061 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -430,7 +430,8 @@ endif (USE_MPEG)
6+
#######################################################################
7+
add_custom_target(ng_generate_version_file
8+
${CMAKE_COMMAND}
9+
- -DBDIR=${CMAKE_CURRENT_BINARY_DIR}
10+
+ -DBDIR=${CMAKE_CURRENT_BINARY_DIR},
11+
+ -DNETGEN_VERSION_GIT=${NETGEN_VERSION_GIT}
12+
-P ${CMAKE_CURRENT_LIST_DIR}/cmake/generate_version_file.cmake
13+
)
14+
#######################################################################

ports/netgen/portfile.cmake

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
vcpkg_from_github(
2+
OUT_SOURCE_PATH SOURCE_PATH
3+
REPO NGSolve/netgen
4+
REF v${VERSION}
5+
SHA512 647ccc0f1990918330457c2d014f243791e7dae8f9ec91880dbab714fa9b2e9b030387958fe74e94a9b4988c3d185c251c5c47764d587826d6d56277658b57d9
6+
HEAD_REF master
7+
PATCHES
8+
git-ver.patch
9+
static-exports.patch
10+
cmake-adjustments.patch
11+
vcpkg-fix-cgns-link.patch
12+
cgns-scoped-enum.patch
13+
downstream-fixes.patch
14+
add_filesystem.patch
15+
)
16+
17+
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
18+
list(APPEND OPTIONS
19+
"-DNGLIB_LIBRARY_TYPE=STATIC"
20+
"-DNGCORE_LIBRARY_TYPE=STATIC"
21+
"-DNGGUI_LIBRARY_TYPE=STATIC"
22+
)
23+
string(APPEND VCPKG_C_FLAGS " -DNGSTATIC_BUILD")
24+
string(APPEND VCPKG_CXX_FLAGS " -DNGSTATIC_BUILD")
25+
endif()
26+
27+
vcpkg_cmake_configure(
28+
DISABLE_PARALLEL_CONFIGURE
29+
SOURCE_PATH "${SOURCE_PATH}"
30+
OPTIONS ${OPTIONS}
31+
-DUSE_PYTHON=OFF
32+
-DUSE_JPEG=ON
33+
-DUSE_CGNS=ON
34+
-DUSE_OCC=ON
35+
-DUSE_MPEG=ON
36+
-DUSE_SPDLOG=OFF # will be vendored otherwise
37+
-DUSE_GUI=OFF
38+
-DPREFER_SYSTEM_PYBIND11=ON
39+
-DENABLE_UNIT_TESTS=OFF
40+
-DUSE_NATIVE_ARCH=OFF
41+
-DUSE_MPI=OFF
42+
-DUSE_SUPERBUILD=OFF
43+
-DNETGEN_VERSION_GIT=v${VERSION} # this variable is patched in via git-ver.patch
44+
-DNG_INSTALL_DIR_CMAKE=lib/cmake/netgen
45+
-DNG_INSTALL_DIR_BIN=bin
46+
-DNG_INSTALL_DIR_LIB=lib
47+
-DNG_INSTALL_DIR_RES=share
48+
-DNG_INSTALL_DIR_INCLUDE=include
49+
-DSKBUILD=ON
50+
)
51+
52+
vcpkg_cmake_install()
53+
54+
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/netgen)
55+
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
56+
57+
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
58+
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin")
59+
endif()
60+
61+
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
62+
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/nglib.h" "defined(NGSTATIC_BUILD)" "1")
63+
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/nglib.h" "define NGLIB" "define NGLIB\n#define OCCGEOMETRY\n#define JPEGLIB\n#define FFMPEG\n")
64+
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/core/ngcore_api.hpp" "!defined(NGSTATIC_BUILD)" "0")
65+
endif()
66+
67+
set(config_file "${CURRENT_PACKAGES_DIR}/share/netgen/NetgenConfig.cmake")
68+
file(READ "${config_file}" contents)
69+
string(REPLACE "${SOURCE_PATH}" "NOT-USABLE" contents "${contents}")
70+
string(REGEX REPLACE "\\\$<\\\$<CONFIG:Release>:([^>]+)>" "\\1" contents "${contents}")
71+
string(REPLACE "\${NETGEN_CMAKE_DIR}/../" "\${NETGEN_CMAKE_DIR}/../../" contents "${contents}")
72+
if(NOT VCPKG_BUILD_TYPE)
73+
string(REPLACE "/lib" "$<$<CONFIG:DEBUG>:/debug>/lib" contents "${contents}")
74+
endif()
75+
string(REGEX REPLACE "$<CONFIG:Release>:([^>]+)>" "\\1" contents "${contents}")
76+
file(WRITE "${config_file}" "${contents}")
77+
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/netgen/NetgenConfig.cmake" "${SOURCE_PATH}" "NOT-USABLE")
78+
79+
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
80+
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")

ports/netgen/static-exports.patch

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
diff --git a/libsrc/core/ngcore_api.hpp b/libsrc/core/ngcore_api.hpp
2+
index e66e9b8..4ecaa05 100644
3+
--- a/libsrc/core/ngcore_api.hpp
4+
+++ b/libsrc/core/ngcore_api.hpp
5+
@@ -35,8 +35,13 @@
6+
7+
8+
#ifdef WIN32
9+
+#if !defined(NGSTATIC_BUILD)
10+
#define NGCORE_API_EXPORT __declspec(dllexport)
11+
#define NGCORE_API_IMPORT __declspec(dllimport)
12+
+#else
13+
+ #define NGCORE_API_EXPORT
14+
+ #define NGCORE_API_IMPORT
15+
+#endif
16+
#else
17+
#define NGCORE_API_EXPORT __attribute__((visibility("default")))
18+
#define NGCORE_API_IMPORT __attribute__((visibility("default")))
19+
diff --git a/nglib/nglib.h b/nglib/nglib.h
20+
index f8c745a..e4587d2 100644
21+
--- a/nglib/nglib.h
22+
+++ b/nglib/nglib.h
23+
@@ -26,11 +26,15 @@
24+
// Philippose - 14.02.2009
25+
// Modifications for creating a DLL in Windows
26+
#ifdef WIN32
27+
+ #if defined(NGSTATIC_BUILD)
28+
+ #define NGLIB_API
29+
+ #else
30+
#ifdef nglib_EXPORTS
31+
#define NGLIB_API __declspec(dllexport)
32+
#else
33+
#define NGLIB_API __declspec(dllimport)
34+
#endif
35+
+ #endif
36+
#else
37+
#define NGLIB_API __attribute__((visibility("default")))
38+
#endif
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index bf92061..933505d 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -500,7 +500,7 @@ endif(ENABLE_CPP_CORE_GUIDELINES_CHECK)
6+
7+
add_library(netgen_cgns INTERFACE)
8+
if(USE_CGNS)
9+
- find_library( CGNS_LIBRARY NAMES cgns cgnsdll )
10+
+ find_library( CGNS_LIBRARY NAMES cgnsdll cgns)
11+
find_path( CGNS_INCLUDE_DIR cgnslib.h )
12+
target_compile_definitions(netgen_cgns INTERFACE NG_CGNS)
13+
target_include_directories(netgen_cgns INTERFACE ${CGNS_INCLUDE_DIR})

ports/netgen/vcpkg.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "netgen",
3+
"version": "6.2.2307",
4+
"description": "NETGEN is an automatic 3d tetrahedral mesh generator. It accepts input from constructive solid geometry (CSG) or boundary representation (BRep) from STL file format. The connection to a geometry kernel allows the handling of IGES and STEP files. NETGEN contains modules for mesh optimization and hierarchical mesh refinement.",
5+
"homepage": "https://ngsolve.org/",
6+
"license": "LGPL-2.1-or-later",
7+
"supports": "arm64 | x64",
8+
"dependencies": [
9+
{
10+
"name": "cgns",
11+
"default-features": false
12+
},
13+
{
14+
"name": "ffmpeg",
15+
"default-features": false,
16+
"features": [
17+
"avcodec"
18+
]
19+
},
20+
"libjpeg-turbo",
21+
{
22+
"name": "opencascade",
23+
"default-features": false
24+
},
25+
{
26+
"name": "vcpkg-cmake",
27+
"host": true
28+
},
29+
{
30+
"name": "vcpkg-cmake-config",
31+
"host": true
32+
},
33+
"zlib"
34+
]
35+
}

versions/baseline.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5948,6 +5948,10 @@
59485948
"baseline": "4.3.1",
59495949
"port-version": 5
59505950
},
5951+
"netgen": {
5952+
"baseline": "6.2.2307",
5953+
"port-version": 0
5954+
},
59515955
"nethost": {
59525956
"baseline": "8.0.0",
59535957
"port-version": 0

versions/n-/netgen.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"versions": [
3+
{
4+
"git-tree": "9326bf9f2364487f83d80a4b594e469db805a511",
5+
"version": "6.2.2307",
6+
"port-version": 0
7+
}
8+
]
9+
}

0 commit comments

Comments
 (0)