From ba5e741ad32b27060c3f27db5c61088043f831b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20Sch=C3=B6berl?= Date: Wed, 22 Jul 2020 10:15:15 +0200 Subject: [PATCH 01/10] adding pybind11/stl to ngcore (needed for BitArray ctor) --- libsrc/core/python_ngcore.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libsrc/core/python_ngcore.hpp b/libsrc/core/python_ngcore.hpp index 92cbbe62..a8ef5755 100644 --- a/libsrc/core/python_ngcore.hpp +++ b/libsrc/core/python_ngcore.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "array.hpp" #include "archive.hpp" From 2f88502729363011f6127395f5ff2c9bb752220e Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Thu, 23 Jul 2020 16:01:34 +0200 Subject: [PATCH 02/10] Remove Segment::bcname, fix Mesh::operator= Remap the 'string* bcname' members in the FaceDescriptor objects in Mesh::operator= to the new mesh --- libsrc/geom2d/genmesh2d.cpp | 3 --- libsrc/interface/nginterface.cpp | 2 +- libsrc/interface/readuser.cpp | 5 ----- libsrc/meshing/meshclass.cpp | 33 +++++++++----------------------- libsrc/meshing/meshtype.cpp | 7 ++----- libsrc/meshing/meshtype.hpp | 19 ------------------ 6 files changed, 12 insertions(+), 57 deletions(-) diff --git a/libsrc/geom2d/genmesh2d.cpp b/libsrc/geom2d/genmesh2d.cpp index c1eadf1a..6d00f1fe 100644 --- a/libsrc/geom2d/genmesh2d.cpp +++ b/libsrc/geom2d/genmesh2d.cpp @@ -458,9 +458,6 @@ namespace netgen for ( int sindex = 0; sindex < maxsegmentindex; sindex++ ) mesh->SetBCName ( sindex, geometry.GetBCName( sindex+1 ) ); - for (SegmentIndex si = 0; si < mesh->GetNSeg(); si++) - (*mesh)[si].SetBCName ( (*mesh).GetBCNamePtr( (*mesh)[si].si-1 ) ); - mesh->CalcLocalH(mp.grading); int bnp = mesh->GetNP(); // boundary points diff --git a/libsrc/interface/nginterface.cpp b/libsrc/interface/nginterface.cpp index 7c647119..42d26094 100644 --- a/libsrc/interface/nginterface.cpp +++ b/libsrc/interface/nginterface.cpp @@ -560,7 +560,7 @@ char * Ng_GetSurfaceElementBCName (int ei) if ( mesh->GetDimension() == 3 ) return const_cast(mesh->GetFaceDescriptor(mesh->SurfaceElement(ei).GetIndex()).GetBCName().c_str()); else - return const_cast(mesh->LineSegment(ei).GetBCName().c_str()); + return const_cast(mesh->GetBCName(mesh->LineSegment(ei).si).c_str()); } diff --git a/libsrc/interface/readuser.cpp b/libsrc/interface/readuser.cpp index d3d50cf2..29b16afa 100644 --- a/libsrc/interface/readuser.cpp +++ b/libsrc/interface/readuser.cpp @@ -313,7 +313,6 @@ namespace netgen ednr = mesh.AddEdgeDescriptor(ed); mesh.SetCD2Name(bcpr, name); auto nr = mesh.AddSegment(tmp_segments[get<0>(element_map[index])-1]); - mesh[nr].SetBCName(mesh.GetCD2NamePtr(mesh.GetNCD2Names())); mesh[nr].edgenr = ednr+1; } else if(dim == 2) @@ -321,7 +320,6 @@ namespace netgen Segment & seg = mesh.LineSegment(get<0>(element_map[index])); seg.si = bccounter + 1; mesh.SetBCName(bccounter, name); - seg.SetBCName(mesh.GetBCNamePtr(bccounter)); bccounter++; } break; @@ -353,13 +351,11 @@ namespace netgen { auto nr = mesh.AddSegment(tmp_segments[get<0>(element_map[index])-1]); mesh[nr].edgenr = ednr+1; - mesh[nr].SetBCName(mesh.GetCD2NamePtr(mesh.GetNCD2Names())); } else if(dim == 2) { Segment & seg = mesh.LineSegment(get<0>(element_map[index])); seg.si = bccounter; - seg.SetBCName(mesh.GetBCNamePtr(bccounter-1)); } break; default: @@ -388,7 +384,6 @@ namespace netgen if(seg.si == -1){ seg.si = bccounter + 1; if(bccounter_tmp == bccounter) mesh.SetBCName(bccounter, "default"); // could be more efficient - seg.SetBCName(mesh.GetBCNamePtr(bccounter)); bccounter_tmp++; } } diff --git a/libsrc/meshing/meshclass.cpp b/libsrc/meshing/meshclass.cpp index 76a22ffc..703109a1 100644 --- a/libsrc/meshing/meshclass.cpp +++ b/libsrc/meshing/meshclass.cpp @@ -105,11 +105,18 @@ namespace netgen if ( mesh2.materials[i] ) materials[i] = new string ( *mesh2.materials[i] ); else materials[i] = 0; - + std::map bcmap; bcnames.SetSize( mesh2.bcnames.Size() ); for ( int i = 0; i < mesh2.bcnames.Size(); i++ ) + { if ( mesh2.bcnames[i] ) bcnames[i] = new string ( *mesh2.bcnames[i] ); else bcnames[i] = 0; + bcmap[mesh2.bcnames[i]] = bcnames[i]; + } + + // Remap string* members in FaceDescriptor to new mesh + for (auto & f : facedecoding) + f.SetBCName( bcmap[&f.GetBCName()] ); cd2names.SetSize(mesh2.cd2names.Size()); @@ -1112,18 +1119,7 @@ namespace netgen bcnames[bcnrs[i-1]-1] = new string(nextbcname); } - if ( GetDimension() == 2 ) - { - for (i = 1; i <= GetNSeg(); i++) - { - Segment & seg = LineSegment (i); - if ( seg.si <= n ) - seg.SetBCName (bcnames[seg.si-1]); - else - seg.SetBCName(0); - } - } - else + if ( GetDimension() == 3 ) { for (SurfaceElementIndex sei = 0; sei < GetNSE(); sei++) { @@ -1156,17 +1152,6 @@ namespace netgen { throw NgException("co dim 2 elements not implemented for dimension 2"); } - else - { - for (i = 1; i<= GetNSeg(); i++) - { - Segment & seg = LineSegment(i); - if ( seg.edgenr <= n ) - seg.SetBCName (cd2names[seg.edgenr-1]); - else - seg.SetBCName(0); - } - } } if (strcmp (str, "singular_points") == 0) diff --git a/libsrc/meshing/meshtype.cpp b/libsrc/meshing/meshtype.cpp index 9523fab7..f512c683 100644 --- a/libsrc/meshing/meshtype.cpp +++ b/libsrc/meshing/meshtype.cpp @@ -80,8 +80,6 @@ namespace netgen epgeominfo[1].edgenr = 1; epgeominfo[1].dist = 0; */ - - bcname = nullptr; } Segment::Segment (const Segment & other) @@ -109,7 +107,6 @@ namespace netgen geominfo[1] = other.geominfo[1]; epgeominfo[0] = other.epgeominfo[0]; epgeominfo[1] = other.epgeominfo[1]; - bcname = other.bcname; } Segment& Segment::operator=(const Segment & other) @@ -135,7 +132,6 @@ namespace netgen pnums[2] = other.pnums[2]; meshdocval = other.meshdocval; hp_elnr = other.hp_elnr; - bcname = other.bcname; is_curved = other.is_curved; } @@ -144,11 +140,12 @@ namespace netgen void Segment :: DoArchive (Archive & ar) { + string * bcname_dummy = nullptr; ar & pnums[0] & pnums[1] & pnums[2] & edgenr & singedge_left & singedge_right & si & cd2i & domin & domout & tlosurf & surfnr1 & surfnr2 - & bcname + & bcname_dummy // keep this for backward compatiblity & epgeominfo[0].edgenr & epgeominfo[1].edgenr; } diff --git a/libsrc/meshing/meshtype.hpp b/libsrc/meshing/meshtype.hpp index e6ccc83e..84e9aec8 100644 --- a/libsrc/meshing/meshtype.hpp +++ b/libsrc/meshing/meshtype.hpp @@ -1031,7 +1031,6 @@ namespace netgen // #endif private: - string* bcname; bool is_curved; public: @@ -1048,24 +1047,6 @@ namespace netgen int hp_elnr; - void SetBCName ( string * abcname ) - { - bcname = abcname; - } - - string * BCNamePtr () - { return bcname; } - - const string * BCNamePtr () const - { return bcname; } - - const string & GetBCName () const - { - static string defaultstring = "default"; - if (! bcname ) return defaultstring; - return *bcname; - } - int GetNP() const { return pnums[2].IsValid() ? 3 : 2; From dcc0484be05ff099f9daddfca8edf8056f103679 Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Thu, 23 Jul 2020 16:24:22 +0200 Subject: [PATCH 03/10] install netgen_version.hpp, set version in Archive --- CMakeLists.txt | 1 + cmake/generate_version_file.cmake | 12 +++++++++++- libsrc/core/archive.cpp | 7 +++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index db13de81..86aac285 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,6 +79,7 @@ endif() set(CMAKE_EXPORT_COMPILE_COMMANDS ON) include (${CMAKE_CURRENT_LIST_DIR}/cmake/generate_version_file.cmake) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/netgen_version.hpp DESTINATION ${NG_INSTALL_DIR_INCLUDE}/include COMPONENT netgen_devel) set(CPACK_PACKAGE_VERSION "${NETGEN_VERSION}") diff --git a/cmake/generate_version_file.cmake b/cmake/generate_version_file.cmake index 3b913636..eb1a5e35 100644 --- a/cmake/generate_version_file.cmake +++ b/cmake/generate_version_file.cmake @@ -36,7 +36,17 @@ endif() set(NETGEN_VERSION_LONG ${NETGEN_VERSION_SHORT}-${NETGEN_VERSION_TWEAK}-${NETGEN_VERSION_HASH}) set(version_file ${BDIR}/netgen_version.hpp) -set(new_version_file_string "#define NETGEN_VERSION \"${NETGEN_VERSION}\"\n") +set(new_version_file_string "\ +#ifndef NETGEN_VERSION_HPP_INCLUDED +#define NETGEN_VERSION_HPP_INCLUDED +#define NETGEN_VERSION \"${NETGEN_VERSION}\" +#define NETGEN_VERSION_MAJOR ${NETGEN_VERSION_MAJOR} +#define NETGEN_VERSION_MINOR ${NETGEN_VERSION_MINOR} +#define NETGEN_VERSION_PATCH ${NETGEN_VERSION_PATCH} +#define NETGEN_VERSION_TWEAK ${NETGEN_VERSION_TWEAK} +#define NETGEN_VERSION_HASH \"${NETGEN_VERSION_HASH}\" +#endif // NETGEN_VERSION_HPP_INCLUDED +") if(EXISTS ${version_file}) file(READ ${version_file} old_version_file_string ) if(${old_version_file_string} STREQUAL ${new_version_file_string}) diff --git a/libsrc/core/archive.cpp b/libsrc/core/archive.cpp index 84e6d875..5d968b6c 100644 --- a/libsrc/core/archive.cpp +++ b/libsrc/core/archive.cpp @@ -1,5 +1,6 @@ #include "archive.hpp" +#include #ifndef WIN32 #include @@ -44,4 +45,10 @@ namespace ngcore std::make_unique>(); return type_register->count(classname) != 0; } + + + static bool dummy = [](){ + SetLibraryVersion("netgen", NETGEN_VERSION); + return true; + }(); } // namespace ngcore From 829ff0aa535f51680f9ec7f19110a64364e1b0f6 Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Thu, 23 Jul 2020 17:49:10 +0200 Subject: [PATCH 04/10] fix install of netgen_version.hpp --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 86aac285..d6197b45 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,7 +79,6 @@ endif() set(CMAKE_EXPORT_COMPILE_COMMANDS ON) include (${CMAKE_CURRENT_LIST_DIR}/cmake/generate_version_file.cmake) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/netgen_version.hpp DESTINATION ${NG_INSTALL_DIR_INCLUDE}/include COMPONENT netgen_devel) set(CPACK_PACKAGE_VERSION "${NETGEN_VERSION}") @@ -405,6 +404,8 @@ if(USE_CGNS) endif(NOT WIN32 AND NOT APPLE) endif(USE_CGNS) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/netgen_version.hpp DESTINATION ${NG_INSTALL_DIR_INCLUDE}/include COMPONENT netgen_devel) + add_subdirectory(libsrc) add_subdirectory(ng) add_subdirectory(tutorials) From f73159e35a4b992a0f156bef6213d7fa103275c0 Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Thu, 23 Jul 2020 19:04:21 +0200 Subject: [PATCH 05/10] Set version of Netgen globally (for archives), interface to get version --- libsrc/core/CMakeLists.txt | 1 + libsrc/core/archive.cpp | 20 +------------------- libsrc/core/archive.hpp | 6 ------ libsrc/core/python_ngcore.hpp | 4 ++-- libsrc/core/version.cpp | 29 +++++++++++++++++++++++++++++ libsrc/core/version.hpp | 8 ++++++++ 6 files changed, 41 insertions(+), 27 deletions(-) create mode 100644 libsrc/core/version.cpp diff --git a/libsrc/core/CMakeLists.txt b/libsrc/core/CMakeLists.txt index f0f07399..16c43a82 100644 --- a/libsrc/core/CMakeLists.txt +++ b/libsrc/core/CMakeLists.txt @@ -11,6 +11,7 @@ add_library(ngcore SHARED table.cpp taskmanager.cpp utils.cpp + version.cpp ) # Pybind11 2.3 Issue https://github.com/pybind/pybind11/issues/1604 diff --git a/libsrc/core/archive.cpp b/libsrc/core/archive.cpp index 5d968b6c..448b8f47 100644 --- a/libsrc/core/archive.cpp +++ b/libsrc/core/archive.cpp @@ -1,6 +1,6 @@ #include "archive.hpp" -#include +#include "version.hpp" #ifndef WIN32 #include @@ -8,18 +8,6 @@ namespace ngcore { - // clang-tidy should ignore this static object - static std::map library_versions; // NOLINT - std::map& Archive :: GetLibraryVersions() - { - return library_versions; - } - const VersionInfo& GetLibraryVersion(const std::string& library) - { return library_versions[library]; } - - void SetLibraryVersion(const std::string& library, const VersionInfo& version) - { library_versions[library] = version; } - // clang-tidy should ignore this static object static std::unique_ptr> type_register; // NOLINT const detail::ClassArchiveInfo& Archive :: GetArchiveRegister(const std::string& classname) @@ -45,10 +33,4 @@ namespace ngcore std::make_unique>(); return type_register->count(classname) != 0; } - - - static bool dummy = [](){ - SetLibraryVersion("netgen", NETGEN_VERSION); - return true; - }(); } // namespace ngcore diff --git a/libsrc/core/archive.hpp b/libsrc/core/archive.hpp index 22019302..ad4d5676 100644 --- a/libsrc/core/archive.hpp +++ b/libsrc/core/archive.hpp @@ -30,9 +30,6 @@ namespace pybind11 namespace ngcore { - // Libraries using this archive can store their version here to implement backwards compatibility - NGCORE_API const VersionInfo& GetLibraryVersion(const std::string& library); - NGCORE_API void SetLibraryVersion(const std::string& library, const VersionInfo& version); class NGCORE_API Archive; @@ -570,9 +567,6 @@ namespace ngcore virtual void FlushBuffer() {} - protected: - static std::map& GetLibraryVersions(); - private: template friend class RegisterClassForArchive; diff --git a/libsrc/core/python_ngcore.hpp b/libsrc/core/python_ngcore.hpp index a8ef5755..6bedabf9 100644 --- a/libsrc/core/python_ngcore.hpp +++ b/libsrc/core/python_ngcore.hpp @@ -230,7 +230,6 @@ namespace ngcore using ARCHIVE::stream; using ARCHIVE::version_map; using ARCHIVE::logger; - using ARCHIVE::GetLibraryVersions; public: PyArchive(const pybind11::object& alst = pybind11::none()) : ARCHIVE(std::make_shared()), @@ -275,10 +274,11 @@ namespace ngcore pybind11::list WriteOut() { + auto version_runtime = GetLibraryVersions(); FlushBuffer(); lst.append(pybind11::bytes(std::static_pointer_cast(stream)->str())); stream = std::make_shared(); - *this & GetLibraryVersions(); + *this & version_runtime; FlushBuffer(); lst.append(pybind11::bytes(std::static_pointer_cast(stream)->str())); stream = std::make_shared(); diff --git a/libsrc/core/version.cpp b/libsrc/core/version.cpp new file mode 100644 index 00000000..546abbf7 --- /dev/null +++ b/libsrc/core/version.cpp @@ -0,0 +1,29 @@ +#include + +#include +#include "exception.hpp" +#include "version.hpp" + +namespace ngcore +{ + // clang-tidy should ignore this static object + static std::map library_versions; // NOLINT + + const VersionInfo& GetLibraryVersion(const std::string& library) + { return library_versions[library]; } + + const std::map& GetLibraryVersions() + { return library_versions; } + + void SetLibraryVersion(const std::string& library, const VersionInfo& version) + { + if(library_versions.count(library) && (library_versions[library] != version)) + throw Exception("Failed to set library version for " + library + " to " + version.to_string() + ": version already set to " + library_versions[library].to_string()); + library_versions[library] = version; + } + + static bool dummy = [](){ + SetLibraryVersion("netgen", NETGEN_VERSION); + return true; + }(); +} // namespace ngcore diff --git a/libsrc/core/version.hpp b/libsrc/core/version.hpp index aea50bf6..3048ce5b 100644 --- a/libsrc/core/version.hpp +++ b/libsrc/core/version.hpp @@ -80,6 +80,10 @@ namespace ngcore return mayor_ == other.mayor_ && minor_ == other.minor_ && release == other.release && patch == other.patch; } + bool operator !=(const VersionInfo& other) const + { + return !(*this==other); + } bool operator >(const VersionInfo& other) const { return other < (*this); } bool operator <=(const VersionInfo& other) const { return !((*this) > other); } bool operator >=(const VersionInfo& other) const { return !((*this) < other); } @@ -89,6 +93,10 @@ namespace ngcore { return ost << version.to_string(); } + + NGCORE_API const VersionInfo& GetLibraryVersion(const std::string& library); + NGCORE_API const std::map& GetLibraryVersions(); + NGCORE_API void SetLibraryVersion(const std::string& library, const VersionInfo& version); } // namespace ngcore #endif // NETGEN_CORE_VERSION_HPP From 3305d1101a9df24b9a2aba331e9b45009abc0dfc Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Thu, 23 Jul 2020 19:04:36 +0200 Subject: [PATCH 06/10] Store Netgen version in generated mesh files --- libsrc/meshing/meshclass.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libsrc/meshing/meshclass.cpp b/libsrc/meshing/meshclass.cpp index 703109a1..ea30e5f6 100644 --- a/libsrc/meshing/meshclass.cpp +++ b/libsrc/meshing/meshclass.cpp @@ -435,6 +435,7 @@ namespace netgen int inverttets = 0; // globflags.GetDefineFlag ("inverttets"); int invertsurf = 0; // globflags.GetDefineFlag ("invertsurfacemesh"); + outfile << "# Generated by NETGEN " << GetLibraryVersion("netgen") << endl << endl; outfile << "mesh3d" << "\n"; From 68f56058664bb34cf045327ae63785ece5a9d887 Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Fri, 24 Jul 2020 17:13:22 +0200 Subject: [PATCH 07/10] Fix version parsing in conda build --- cmake/generate_version_file.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/generate_version_file.cmake b/cmake/generate_version_file.cmake index eb1a5e35..5745e2db 100644 --- a/cmake/generate_version_file.cmake +++ b/cmake/generate_version_file.cmake @@ -4,7 +4,7 @@ endif() find_package(Git REQUIRED) -if(GIT_FOUND AND EXISTS ${CMAKE_CURRENT_LIST_DIR}/../.git) +if(GIT_FOUND AND IS_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/../.git) execute_process(COMMAND git describe --tags --match "v[0-9]*" --long --dirty WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} OUTPUT_VARIABLE git_version_string) else() # for source package files (generated for ubuntu builds on launchpad) read the version from version.txt From fa1a5d11eeb596b6a9f829247cc6d4a0135024ca Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Sat, 25 Jul 2020 08:41:17 +0200 Subject: [PATCH 08/10] Fix version file generation --- cmake/generate_version_file.cmake | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/cmake/generate_version_file.cmake b/cmake/generate_version_file.cmake index 5745e2db..de709298 100644 --- a/cmake/generate_version_file.cmake +++ b/cmake/generate_version_file.cmake @@ -3,16 +3,20 @@ if(NOT BDIR) endif() find_package(Git REQUIRED) +execute_process(COMMAND git describe --tags --match "v[0-9]*" --long --dirty WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} OUTPUT_VARIABLE git_version_string RESULT_VARIABLE status ERROR_QUIET) -if(GIT_FOUND AND IS_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/../.git) - execute_process(COMMAND git describe --tags --match "v[0-9]*" --long --dirty WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} OUTPUT_VARIABLE git_version_string) -else() - # for source package files (generated for ubuntu builds on launchpad) read the version from version.txt +if(status AND NOT status EQUAL 0) if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/../version.txt) - file(READ ${CMAKE_CURRENT_LIST_DIR}/../version.txt git_version_string ) + # for source package files (generated for ubuntu builds on launchpad) read the version from version.txt + if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/../version.txt) + file(READ ${CMAKE_CURRENT_LIST_DIR}/../version.txt git_version_string ) + else() + get_filename_component(git_version_string ${CMAKE_CURRENT_LIST_DIR}/.. NAME) + string(REGEX REPLACE "^netgen(.*)" "\\1" git_version_string "${git_version_string}") + endif() else() - get_filename_component(git_version_string ${CMAKE_CURRENT_LIST_DIR}/.. NAME) - string(REGEX REPLACE "^netgen(.*)" "\\1" git_version_string "${git_version_string}") + MESSAGE(WARNING "Could not determine git-version from source code - assuming 6.2.0.0") + set(git_version_string "v6.2.0.0") endif() endif() From 2744d629358d9784900a2876fe0fe2baa39e4f19 Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Sat, 25 Jul 2020 08:46:46 +0200 Subject: [PATCH 09/10] pybind11-stubgen - use python module instead of standalone program --- python/CMakeLists.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index bcbf0a35..a64e54b7 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -9,13 +9,13 @@ install(FILES # build stub files for pybind11 packages if(BUILD_STUB_FILES) -find_program(PYBIND11_STUBS NAMES pybind11-stubgen) -if(PYBIND11_STUBS) - message("-- Found pybind11-stubgen: ${PYBIND11_STUBS}") - install(CODE "execute_process(COMMAND ${PYBIND11_STUBS} --no-setup-py netgen)") - install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../stubs/netgen-stubs/ DESTINATION ${NG_INSTALL_DIR_PYTHON}/netgen/ COMPONENT netgen) -else(PYBIND11_STUBS) +execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import pybind11_stubgen; print(pybind11_stubgen.__file__)" OUTPUT_VARIABLE stubgen_path RESULT_VARIABLE pybind11_stubgen) +if(pybind11_stubgen AND NOT ${pybind11_stubgen} EQUAL 0) message(WARNING "pybind11-stubgen not found, if you want to create stub files for better autocompletion support install it with pip.") -endif(PYBIND11_STUBS) +else() + message("-- Found pybind11-stubgen: ${stubgen_path}") + install(CODE "execute_process(COMMAND ${PYTHON_EXEcUTABLE} -m pybind11_stubgen --no-setup-py netgen)") + install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../stubs/netgen-stubs/ DESTINATION ${NG_INSTALL_DIR_PYTHON}/netgen/ COMPONENT netgen) +endif() endif(BUILD_STUB_FILES) From f864e53090980f8c9fed2a2c3d6dcc878595c57a Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Sat, 25 Jul 2020 13:04:18 +0200 Subject: [PATCH 10/10] [cmake] fix typo --- python/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index a64e54b7..47910190 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -15,7 +15,7 @@ if(pybind11_stubgen AND NOT ${pybind11_stubgen} EQUAL 0) for better autocompletion support install it with pip.") else() message("-- Found pybind11-stubgen: ${stubgen_path}") - install(CODE "execute_process(COMMAND ${PYTHON_EXEcUTABLE} -m pybind11_stubgen --no-setup-py netgen)") + install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pybind11_stubgen --no-setup-py netgen)") install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../stubs/netgen-stubs/ DESTINATION ${NG_INSTALL_DIR_PYTHON}/netgen/ COMPONENT netgen) endif() endif(BUILD_STUB_FILES)