diff --git a/CMakeLists.txt b/CMakeLists.txt index a1335759971411fa62f8167e6231828eaad5f2d0..2be515dcd012c547d039dcdefeb4153ede1aede8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,7 +53,7 @@ opt(GETDP "Enable GetDP solver (as a directly linked library)" ${DEFAULT}) opt(GMM "Enable GMM linear solvers (simple alternative to PETSc)" ${DEFAULT}) opt(GMP "Enable GMP for Kbipack (advanced)" ON) opt(GRAPHICS "Enable building graphics lib even without GUI (advanced)" OFF) -opt(INTERNAL_DEVELOPER_API "Enable internal developer API (will be off by default)" ON) +opt(INTERNAL_DEVELOPER_API "Enable internal developer API" OFF) opt(KBIPACK "Enable Kbipack (neeeded by homology solver)" ${DEFAULT}) opt(MATHEX "Enable math expression parser (used by plugins and options)" ${DEFAULT}) opt(MED "Enable MED mesh and post file formats" ${DEFAULT}) @@ -105,75 +105,22 @@ set(GMSH_SHORT_LICENSE "GNU General Public License") set(GMSH_API Common/gmsh.h) -set(GMSH_INTERNAL_DEVELOPER_API - ${CMAKE_CURRENT_BINARY_DIR}/Common/GmshConfig.h - ${CMAKE_CURRENT_BINARY_DIR}/Common/GmshVersion.h - Common/GmshGlobal.h Common/Context.h Common/GmshDefines.h Common/GmshMessage.h - Common/VertexArray.h Common/Octree.h Common/OctreeInternals.h Common/OS.h - Common/StringUtils.h Common/OpenFile.h Common/Hash.h Common/onelab.h - Common/GmshSocket.h Common/onelabUtils.h Common/Options.h Common/picojson.h - Numeric/Numeric.h Numeric/GaussIntegration.h Numeric/polynomialBasis.h - Numeric/JacobianBasis.h Numeric/bezierBasis.h Numeric/fullMatrix.h - Numeric/FuncSpaceData.h Numeric/pointsGenerators.h Numeric/simpleFunction.h - Numeric/cartesian.h Numeric/ElementType.h Numeric/BasisFactory.h - Numeric/CondNumBasis.h Numeric/mathEvaluator.h Numeric/nodalBasis.h - Geo/GModel.h Geo/GEntity.h Geo/GPoint.h Geo/GVertex.h Geo/GEdge.h Geo/GFace.h - Geo/GRegion.h Geo/GEdgeLoop.h Geo/MVertex.h Geo/MVertexBoundaryLayerData.h - Geo/MEdge.h Geo/MFace.h Geo/MEdgeHash.h Geo/MFaceHash.h Geo/MElement.h - Geo/MElementOctree.h Geo/MPoint.h Geo/MLine.h Geo/MTriangle.h - Geo/MQuadrangle.h Geo/MTetrahedron.h Geo/MHexahedron.h Geo/MPrism.h - Geo/MPyramid.h Geo/MTrihedron.h Geo/MElementCut.h Geo/discreteVertex.h - Geo/discreteEdge.h Geo/discreteFace.h Geo/discreteRegion.h Geo/SPoint2.h - Geo/SPoint3.h Geo/SVector3.h Geo/STensor3.h Geo/SBoundingBox3d.h Geo/Pair.h - Geo/Range.h Geo/SOrientedBoundingBox.h Geo/CellComplex.h Geo/ChainComplex.h - Geo/Cell.h Geo/Homology.h Geo/Chain.h Geo/GenericVertex.h Geo/GenericEdge.h - Geo/GenericFace.h Geo/GenericRegion.h Geo/partitionVertex.h - Geo/partitionEdge.h Geo/partitionFace.h Geo/CGNSOptions.h Geo/gmshLevelset.h - Geo/boundaryLayersData.h - Mesh/meshGEdge.h Mesh/meshGFace.h Mesh/meshGFaceOptimize.h - Mesh/meshPartition.h Mesh/meshGFaceDelaunayInsertion.h Mesh/simple3D.h - Mesh/meshPartitionOptions.h Mesh/directions3D.h Mesh/yamakawa.h - Mesh/Voronoi3D.h Mesh/Levy3D.h Mesh/meshMetric.h Mesh/ThinLayer.h - Solver/dofManager.h Solver/femTerm.h Solver/laplaceTerm.h - Solver/elasticityTerm.h Solver/crossConfTerm.h Solver/orthogonalTerm.h - Solver/linearSystem.h Solver/linearSystemGMM.h Solver/linearSystemCSR.h - Solver/linearSystemFull.h Solver/elasticitySolver.h Solver/sparsityPattern.h - Solver/groupOfElements.h Solver/linearSystemPETSc.h - Solver/linearSystemMUMPS.h Solver/thermicSolver.h - Post/PView.h Post/PViewData.h Plugin/PluginManager.h Post/OctreePost.h - Post/PViewDataList.h Post/PViewDataGModel.h Post/PViewOptions.h - Post/ColorTable.h Post/adaptiveData.h - Graphics/drawContext.h - contrib/kbipack/gmp_normal_form.h contrib/kbipack/gmp_matrix.h - contrib/kbipack/gmp_blas.h contrib/kbipack/mpz.h - contrib/DiscreteIntegration/Integration3D.h - contrib/HighOrderMeshOptimizer/OptHOM.h - contrib/HighOrderMeshOptimizer/OptHomMesh.h - contrib/HighOrderMeshOptimizer/OptHomRun.h - contrib/HighOrderMeshOptimizer/ParamCoord.h - contrib/HighOrderMeshOptimizer/OptHomFastCurving.h - contrib/HighOrderMeshOptimizer/BoundaryLayerCurver.h - contrib/HighOrderMeshOptimizer/OptHomIntegralBoundaryDist.h - contrib/HighOrderMeshOptimizer/CADDistances.h - contrib/HighOrderMeshOptimizer/OptHomObjContribScaledJac.h - contrib/HighOrderMeshOptimizer/OptHomObjContribMetricMin.h - contrib/HighOrderMeshOptimizer/OptHomObjContribCADDist.h - contrib/MeshOptimizer/MeshOptPatch.h contrib/MeshOptimizer/MeshOpt.h - contrib/MeshOptimizer/MeshOptCommon.h contrib/MeshOptimizer/MeshOptimizer.h - contrib/MeshOptimizer/MeshOptObjContribFunc.h - contrib/MeshOptimizer/MeshOptObjContrib.h - contrib/MeshOptimizer/MeshOptObjContribScaledNodeDispSq.h - contrib/MeshOptimizer/MeshOptObjectiveFunction.h - contrib/MeshOptimizer/MeshOptVertexCoord.h - contrib/MeshQualityOptimizer/MeshQualityObjContribIdealJac.h - contrib/MeshQualityOptimizer/MeshQualityObjContribInvCond.h - contrib/MeshQualityOptimizer/MeshQualityOptimizer.h - contrib/MathEx/mathex.h) - -get_property(IAMCHILD DIRECTORY PROPERTY PARENT_DIRECTORY) -if(IAMCHILD) - set(GMSH_INTERNAL_DEVELOPER_API ${GMSH_API} PARENT_SCOPE) -endif(IAMCHILD) +if(ENABLE_INTERNAL_DEVELOPER_API) + message(WARNING "The internal developer API is unsupported and undocumented. " + "It is meant for Gmsh (and related projects) developers, not for wide " + "distribution. If you are packaging Gmsh for redistribution, please " + "DO NOT enable this and just ship the stable API (${GMSH_API}) instead.") + file(GLOB_RECURSE HEADERS Common/*.h Numeric/*.h Geo/*.h Mesh/*.h Solver/*.h + Post/*.h Graphics/*.h contrib/kbipack/*.h contrib/DiscreteIntegration/*.h + contrib/HighOrderMeshOptimizer/*.h contrib/MeshOptimizer/*.h + contrib/MeshQualityOptimizer/*.h contrib/MathEx/*.h) + set(GMSH_INTERNAL_DEVELOPER_API ${CMAKE_CURRENT_BINARY_DIR}/Common/GmshConfig.h + ${CMAKE_CURRENT_BINARY_DIR}/Common/GmshVersion.h ${HEADERS}) + get_property(IAMCHILD DIRECTORY PROPERTY PARENT_DIRECTORY) + if(IAMCHILD) + set(GMSH_INTERNAL_DEVELOPER_API ${GMSH_API} PARENT_SCOPE) + endif(IAMCHILD) +endif(ENABLE_INTERNAL_DEVELOPER_API) if(${CMAKE_MAJOR_VERSION} GREATER 2) string(TIMESTAMP DATE "%Y%m%d") @@ -446,7 +393,7 @@ if(ENABLE_BLAS_LAPACK) endif(NOT HAVE_BLAS OR NOT HAVE_LAPACK) if(NOT HAVE_BLAS OR NOT HAVE_LAPACK) - message(STATUS "Warning: Could not find Blas or Lapack: most meshing algorithms " + message(WARNING "Could not find Blas or Lapack: most meshing algorithms " "will not be functional") endif(NOT HAVE_BLAS OR NOT HAVE_LAPACK) @@ -1074,7 +1021,7 @@ if(HAVE_SOLVER) set_source_files_properties(${TAUCS_G} PROPERTIES COMPILE_FLAGS -DTAUCS_CORE_GENERAL) set_config_option(HAVE_TAUCS "Taucs") else(HAVE_METIS) - message(STATUS "Warning: Disabling Taucs (requires METIS)") + message(WARNING "Disabling Taucs (requires METIS)") endif(HAVE_METIS) endif(ENABLE_TAUCS AND HAVE_BLAS AND HAVE_LAPACK) @@ -1145,9 +1092,9 @@ if(ENABLE_OCC) endif(OCC_MAJOR AND OCC_MINOR AND OCC_MAINT) endif(OCC_INC) if(OCC_VERSION AND OCC_VERSION STRLESS ${OCC_MINIMAL_VERSION}) - message(WARNING "Gmsh requires OpenCASCADE >= ${OCC_MINIMAL_VERSION}") - message(WARNING "Use CMAKE_PREFIX_PATH or the CASROOT environment variable " - "to explicitely specify the installation path of OpenCASCADE") + message(WARNING "Gmsh requires OpenCASCADE >= ${OCC_MINIMAL_VERSION}. " + "Use CMAKE_PREFIX_PATH or the CASROOT environment variable " + "to explicitely specify the installation path of OpenCASCADE") else(OCC_VERSION AND OCC_VERSION STRLESS ${OCC_MINIMAL_VERSION}) set(OCC_LIBS_REQUIRED # subset of DataExchange @@ -1267,7 +1214,11 @@ if(ENABLE_WRAP_PYTHON) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) set(CMAKE_SWIG_FLAGS "") set_source_files_properties(Common/gmsh.i PROPERTIES CPLUSPLUS ON) - swig_add_module(gmsh python Common/gmsh.i) + if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.8) + swig_add_library(gmsh LANGUAGE python SOURCES Common/gmsh.i) + else(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.8) + swig_add_module(gmsh python Common/gmsh.i) + endif(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.8) swig_link_libraries(gmsh ${PYTHON_LIBRARIES} shared) if(APPLE) set_target_properties("_gmsh" PROPERTIES LINK_FLAGS diff --git a/contrib/mobile/utils/ios_build.sh b/contrib/mobile/utils/ios_build.sh index 5f6c6065271db48c44f4443245b6025e6fb9fca3..078c4a4a207d53534ad6fed6da7fb2efc74c7a43 100755 --- a/contrib/mobile/utils/ios_build.sh +++ b/contrib/mobile/utils/ios_build.sh @@ -54,9 +54,9 @@ getdp_framework="$frameworks_dir/getdp.framework" occt_framework="$frameworks_dir/occt.framework" if [ $enable_simulator != 0 ]; then - cmake_default="-DDEFAULT=0 -DCMAKE_TOOLCHAIN_FILE=$gmsh_git/contrib/mobile/utils/iOS.cmake -DIOS_PLATFORM=SIMULATOR -DENABLE_BUILD_IOS=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=x86_64 -GXcode" + cmake_default="-DDEFAULT=0 -DENABLE_INTERNAL_DEVELOPER_API=1 -DCMAKE_TOOLCHAIN_FILE=$gmsh_git/contrib/mobile/utils/iOS.cmake -DIOS_PLATFORM=SIMULATOR -DENABLE_BUILD_IOS=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=x86_64 -GXcode" else - cmake_default="-DDEFAULT=0 -DCMAKE_TOOLCHAIN_FILE=$gmsh_git/contrib/mobile/utils/iOS.cmake -DIOS_PLATFORM=OS -DENABLE_BUILD_IOS=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=armv7;armv7s;arm64 -GXcode" + cmake_default="-DDEFAULT=0 -DENABLE_INTERNAL_DEVELOPER_API=1 -DCMAKE_TOOLCHAIN_FILE=$gmsh_git/contrib/mobile/utils/iOS.cmake -DIOS_PLATFORM=OS -DENABLE_BUILD_IOS=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=armv7;armv7s;arm64 -GXcode" fi build_cmd="xcodebuild -target lib -configuration Release" diff --git a/demos/api/README.txt b/demos/api/README.txt index 99119011865646acaaa916b6c0839648d606fa5f..63b050491db69c028ba7ff7747b16c0cdb5b5307 100644 --- a/demos/api/README.txt +++ b/demos/api/README.txt @@ -1,2 +1,29 @@ -This directory contains examples on how to use the Gmsh API in C++ and in Python. +This directory contains examples on how to use the Gmsh API in C++ and in +Python. The full API is available in Common/gmsh.h. +The files t1.{cpp,py}, t2.{cpp,py}, ... are reimplementations in C++ and Python +of the corresponding tutorials in gmsh/tutorials. + +1) Build and install Gmsh, the dynamic Gmsh library and the Python wrappers: + + cd gmsh + mkdir build + cd build + cmake -DENABLE_WRAP_PYTHON=1 .. + make + make install + cd .. + +2a) To build the C++ examples: + + cd demos/api + mkdir build + cd build + cmake .. + make + ./t1 + +2b) To run the Python examples: + + export PYTHON_PATH=/path/to/gmsh/build + python demos/api/t1.py