[Gmsh] Link C++ code to gmsh

Martin Vymazal martin.vymazal at vki.ac.be
Fri Nov 18 20:43:22 CET 2011


Dear gmsh users and developers,

  I'd like to write a little c++ driver that calls gmsh for  
(re-)meshing of some simple geometries. I have gmsh installed in  
/opt/gmsh and I wrote this cmake file:

cmake_minimum_required(VERSION 2.8)
project(gmshdriver C CXX)

set(GMSH_ROOT /opt/gmsh)
if ( DEFINED GMSH_ROOT)
   find_path( GMSH_INCLUDE_DIR Gmsh.h PATHS ${GMSH_ROOT}/include/gmsh  
NO_DEFAULT_PATH )
endif()

find_path( GMSH_INCLUDE_DIR Gmsh.h )
include_directories( ${GMSH_INCLUDE_DIR} )

find_library( GMSH_LIB NAMES Gmsh PATHS ${GMSH_ROOT}/lib )

add_executable(test src/main.cpp)
target_link_libraries( test ${GMSH_LIB} )

I'm a wondering if this is sufficient in case I call gmsh functions  
which require third-party functionality (petsc, OpenCascade etc). I  
expect to run into linking problems.

One solution would be to modify the CMakeLists.txt of gmsh and add a  
subdirectory with my sources. Then I'll have access to cmake variables  
like ${EXTERNAL_LIBRARIES} and ${EXTERNAL_INCLUDES}.

Can you tell me what's the best way to do this? Any comments,  
suggestions or sample CMake files are welcome. Thank you very much.

  Best regards,

    Martin Vymazal


----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.