« Back

Building Tecplot Add-ons with CMake

Tecplot add-ons are a powerful way to customize and extend Tecplot’s capabilities. Unfortunately, building cross-platform add-ons can be a pain: there are two completely different methods of building (Visual Studio on Windows, “make” on other platforms), which means maintaining two separate build systems (Visual Studio project files and Makefiles). One solution to this problem is

CMake, which allows you to write a single set of cross-platform build files.

Using CMake to build a Tecplot add-on is straightforward. From a build perspective, an add-on is simply:

  • A shared library
  • that is compiled against the Tecplot headers,
  • and links against Tecplot’s libtec library.

This is expressed in CMake like this:

find_package (Tecplot REQUIRED)
include_directories ("${TECPLOT_INCLUDE_DIR}")
add_library (example_addon SHARED src/main.cpp
target_link_libraries (${PROJECT_NAME} ${TECPLOT_LIBS})

Much of the work happens in the find_package command, which creates CMake variables with the location of Tecplot’s headers and libraries (you can examine FindTecplot.cmake to see how this is done). The include_directories command adds the Tecplot include directory to the list of include paths for the project. Finally, add_library specifies that we are building a shared library called “example_addon “, and target_link_libraries establishes the Tecplot libraries as linker dependencies.

So, how do you run this? Fire up CMake, point it at the directory containing your CMakeLists.txt file, then hit Configure. Make sure the TECPLOT_INSTALL_DIR variable is set correctly, click Configure again, then Generate. You should end up with a screen like this:

Once you’ve generated the build files, you use your platform’s native tool chain to build the add-on.