Created
September 4, 2009 21:32
-
-
Save kashif/181152 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Try to find MathLink from Wolfram Mathematica package | |
# | |
# See http://www.wolfram.com/solutions/mathlink/ | |
# | |
# Once run this will define: | |
# | |
# MathLink_FOUND | |
# MathLink_INCLUDE_DIR | |
# MathLink_LIBRARIES | |
# MathLink_MPREP_BINARY | |
# | |
# NOTES | |
# tested with Mathematica 5.2 (on Windows XP) | |
# | |
# AUTHOR | |
# Jan Woetzel <http://www.mip.informatik.uni-kiel.de/~jw> (03/2006) | |
# the precompiled MathLink library name depends on | |
# - version (1 or 2) - we always use 2 | |
# - compiler/linker - MS Visual studio, mingw, borland, cygwin ... | |
# | |
# Bart Janssen | |
# Support for MacOSX and Linux | |
# | |
# Roel Jordans | |
# Rewrite -> checking one mathematica version at a time | |
# | |
# Which versions of Mathematica should be checked? | |
if(APPLE OR WIN32) | |
# add "8.0" as soon as released | |
set(Mathematica_versions "7.0" "6.0.2" "6.0.1" "6.0" "5.2" "5.1") | |
else(APPLE OR WIN32) | |
set(Mathematica_versions "5.2" "6.0") | |
endif(APPLE OR WIN32) | |
foreach(version ${Mathematica_versions}) | |
find_path(MathLink_DIR | |
NAMES mathlink.h include/mathlink.h | |
PATHS | |
# Windows | |
"$ENV{ProgramFiles}/Wolfram Research/Mathematica/${version}/Files/CompilerAdditions/mldev32" | |
"$ENV{ProgramFiles}/Wolfram Research/Mathematica/${version}/SystemFiles/Links/MathLink/DeveloperKit/Windows/CompilerAdditions/mldev32" | |
"$ENV{ProgramFiles}/Wolfram Research/Mathematica/${version}/AddOns/MathLink/DeveloperKit/Windows/CompilerAdditions/mldev32" | |
# MacOSX | |
"/Applications/Mathematica.app/SystemFiles/Links/MathLink/DeveloperKit/CompilerAdditions" | |
# Linux | |
"/usr/local/Wolfram/Mathematica/${version}/SystemFiles/Links/MathLink/DeveloperKit/Linux-x86-64/CompilerAdditions" | |
"/usr/local/Wolfram/Mathematica/${version}/SystemFiles/Links/MathLink/DeveloperKit/Linux/CompilerAdditions" | |
"/usr/local/Wolfram/Mathematica/${version}/AddOns/MathLink/DeveloperKit/Linux-x86-64/CompilerAdditions" | |
) | |
find_path(MathLink_INCLUDE_DIR | |
NAMES mathlink.h | |
PATHS "${MathLink_DIR}" | |
"${MathLink_DIR}/include" | |
DOC "Mathematica MathLink include directory" | |
) | |
find_library(MathLink_LIBRARY | |
NAMES ML MLi3 ml32i3m ml32i2m ML32i3 | |
PATHS "${MathLink_DIR}" | |
"${MathLink_DIR}/lib" | |
DOC "Mathematica MathLink library" | |
) | |
find_program(MathLink_MPREP_BINARY | |
NAMES mprep | |
PATHS "${MathLink_DIR}" | |
"${MathLink_DIR}/bin" | |
DOC "Mathematica Mathlink mprep binary" | |
) | |
if(MathLink_INCLUDE_DIR AND MathLink_LIBRARY AND MathLink_MPREP_BINARY) | |
message(STATUS "Found MathLink: ${MathLink_DIR}") | |
break() | |
endif(MathLink_INCLUDE_DIR AND MathLink_LIBRARY AND MathLink_MPREP_BINARY) | |
endforeach(version) | |
# MESSAGE("DBG MathLink_INCLUDE_DIR=${MathLink_INCLUDE_DIR}") | |
# MESSAGE("DBG MathLink_LIBRARY=${MathLink_LIBRARY}") | |
# -------------------------------- | |
IF(MathLink_LIBRARY) | |
IF(WIN32 OR APPLE) | |
SET(MathLink_LIBRARIES ${MathLink_LIBRARY}) | |
ELSE(WIN32 OR APPLE) | |
SET(MathLink_LIBRARIES ${MathLink_LIBRARY} rt) | |
ENDIF(WIN32 OR APPLE) | |
ELSE(MathLink_LIBRARY) | |
MESSAGE(STATUS "MathLink_LIBRARY library not found.") | |
ENDIF(MathLink_LIBRARY) | |
IF(NOT MathLink_INCLUDE_DIR) | |
MESSAGE(STATUS "MathLink_INCLUDE_DIR include dir not found.") | |
ENDIF(NOT MathLink_INCLUDE_DIR) | |
IF(NOT MathLink_MPREP_BINARY) | |
MESSAGE(STATUS "MathLink_MPREP_BINARY not found.") | |
ENDIF(NOT MathLink_MPREP_BINARY) | |
IF(MathLink_LIBRARIES AND MathLink_INCLUDE_DIR) | |
SET(MathLink_FOUND TRUE) | |
ENDIF(MathLink_LIBRARIES AND MathLink_INCLUDE_DIR) | |
MARK_AS_ADVANCED( | |
MathLink_LIBRARY | |
MathLink_LIBRARIES | |
MathLink_INCLUDE_DIR | |
MathLink_MPREP_BINARY | |
MathLink_FOUND | |
) | |
# ========================================== | |
IF(NOT MathLink_FOUND) | |
# make FIND_PACKAGE friendly | |
IF(NOT MathLink_FIND_QUIETLY) | |
IF(MathLink_FIND_REQUIRED) | |
MESSAGE(FATAL_ERROR "MathLink required, please specify it's location.") | |
ELSE(MathLink_FIND_REQUIRED) | |
MESSAGE(STATUS "ERROR: MathLink was not found.") | |
ENDIF(MathLink_FIND_REQUIRED) | |
ENDIF(NOT MathLink_FIND_QUIETLY) | |
ENDIF(NOT MathLink_FOUND) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment