Skip to content

sakra/FindMathematica

Repository files navigation

FindMathematica

FindMathematica is a CMake module that tries to find a Wolfram Language installation and provides CMake functions for its C/C++ interface.

Features

  • Works with Windows, Linux and OS X versions of the Wolfram Language.
  • Supports Wolfram Language versions from 5.2 to 12.0.
  • Supports Wolfram Language implementations Wolfram Mathematica, Wolfram|One, Wolfram Engine and Wolfram gridMathematica.
  • Finds include directories and libraries for LibraryLink (version 8 or later).
  • Finds include directories and libraries for WSTP (version 10 or later).
  • Finds installation directory and JAR file of J/Link.
  • Finds include directories and libraries for MathLink.
  • Finds installation directory of Wolfram MUnit testing package.
  • Provides exact version info for the Wolfram Language, LibraryLink, WSTP, MathLink, J/Link and MUnit.
  • Allows for running Wolfram Language code during CMake configure or build time.
  • Allows for running Wolfram Language code as a pre-link, pre-build or post-build action.
  • Allows for running Wolfram Language code in CMake test targets.
  • Allows for running Wolfram Language MUnit test files and suites as CMake test targets.
  • Supports generating C code from WSTP template files using wsprp executable.
  • Supports generating C code from MathLink template files using mprep executable.
  • Supports building dynamic libraries loadable with LibraryLink.
  • Supports generating stand-alone C code from Wolfram Language code with CCodeGenerator.
  • Provides CMake interface to Wolfram Language's Encode function.
  • Supports generating Wolfram Language documentation with the DocumentationBuild package.
  • Fully leverages CMake's cross-compiling support.

Requirements

Installation

Copy the directory CMake/Mathematica to the root directory of your CMake project. In the top-level CMakeList.txt file, add the module directory to the CMake module search path:

set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake/Mathematica" ${CMAKE_MODULE_PATH})

Usage

To find the newest Wolfram Language installation in a CMake list file, run the find_package command:

find_package(Mathematica)

See the FindMathematica manual for more information.