1# - this module looks for Matlab 2# Defines: 3# MATLAB_INCLUDE_DIR: include path for mex.h, engine.h 4# MATLAB_LIBRARIES: required libraries: libmex, etc 5# MATLAB_MEX_LIBRARY: path to libmex.lib 6# MATLAB_MX_LIBRARY: path to libmx.lib 7# MATLAB_ENG_LIBRARY: path to libeng.lib 8 9#============================================================================= 10# Copyright 2005-2009 Kitware, Inc. 11# 12# Distributed under the OSI-approved BSD License (the "License"); 13# see contents of file Copyright.txt included below for details. 14# 15# This software is distributed WITHOUT ANY WARRANTY; without even the 16# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17# See the License for more information. 18#============================================================================= 19# (To distribute this file outside of CMake, substitute the full 20# License text for the above reference.) 21 22# Contents of Copyright.txt: 23# 24# CMake - Cross Platform Makefile Generator 25# Copyright 2000-2009 Kitware, Inc., Insight Software Consortium 26# All rights reserved. 27# 28# Redistribution and use in source and binary forms, with or without 29# modification, are permitted provided that the following conditions 30# are met: 31# 32# * Redistributions of source code must retain the above copyright 33# notice, this list of conditions and the following disclaimer. 34# 35# * Redistributions in binary form must reproduce the above copyright 36# notice, this list of conditions and the following disclaimer in the 37# documentation and/or other materials provided with the distribution. 38# 39# * Neither the names of Kitware, Inc., the Insight Software Consortium, 40# nor the names of their contributors may be used to endorse or promote 41# products derived from this software without specific prior written 42# permission. 43# 44# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 45# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 46# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 47# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 48# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 49# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 50# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 51# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 52# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 53# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 54# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 55 56# 04/30/2012, BMA: Modified for DAKOTA to have MATLAB_DIR option for Linux 57 58SET(MATLAB_FOUND 0) 59IF(WIN32) 60 IF(NOT MATLAB_DIR) 61 SET(MATLAB_DIR "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MathWorks\\MATLAB\\7.0;MATLABROOT]") 62 ENDIF(MATLAB_DIR) 63 IF(${CMAKE_GENERATOR} MATCHES "Visual Studio 6") 64 SET(MATLAB_ROOT "${MATLAB_DIR}/extern/lib/win32/microsoft/msvc60") 65 ELSE(${CMAKE_GENERATOR} MATCHES "Visual Studio 6") 66 IF(${CMAKE_GENERATOR} MATCHES "Visual Studio 7") 67 # Assume people are generally using 7.1, 68 # if using 7.0 need to link to: ../extern/lib/win32/microsoft/msvc70 69 SET(MATLAB_ROOT "${MATLAB_DIR}/extern/lib/win32/microsoft/msvc71") 70 ELSE(${CMAKE_GENERATOR} MATCHES "Visual Studio 7") 71 IF(${CMAKE_GENERATOR} MATCHES "Borland") 72 # Same here, there are also: bcc50 and bcc51 directories 73 SET(MATLAB_ROOT "${MATLAB_DIR}/extern/lib/win32/microsoft/bcc54") 74 ELSE(${CMAKE_GENERATOR} MATCHES "Borland") 75 IF(MATLAB_FIND_REQUIRED) 76 MESSAGE(FATAL_ERROR "Generator not compatible: ${CMAKE_GENERATOR}") 77 ENDIF(MATLAB_FIND_REQUIRED) 78 ENDIF(${CMAKE_GENERATOR} MATCHES "Borland") 79 ENDIF(${CMAKE_GENERATOR} MATCHES "Visual Studio 7") 80 ENDIF(${CMAKE_GENERATOR} MATCHES "Visual Studio 6") 81 FIND_LIBRARY(MATLAB_MEX_LIBRARY 82 libmex 83 ${MATLAB_ROOT} 84 ) 85 FIND_LIBRARY(MATLAB_MX_LIBRARY 86 libmx 87 ${MATLAB_ROOT} 88 ) 89 FIND_LIBRARY(MATLAB_ENG_LIBRARY 90 libeng 91 ${MATLAB_ROOT} 92 ) 93 94 FIND_PATH(MATLAB_INCLUDE_DIR 95 "mex.h" 96 "${MATLAB_DIR}/extern/include" 97 ) 98ELSE( WIN32 ) 99 IF( APPLE ) 100 IF(NOT MATLAB_DIR) 101 FILE(GLOB MATLAB_DIRS "/Applications/MATLAB_*.app") 102 LIST(REVERSE MATLAB_DIRS) 103 LIST(GET MATLAB_DIRS 0 MATLAB_DIR) 104 ENDIF(NOT MATLAB_DIR) 105 IF(CMAKE_SIZEOF_VOID_P EQUAL 4) 106 # Regular x86 107 SET(MATLAB_ROOT "${MATLAB_DIR}/bin/maci") 108 ELSE(CMAKE_SIZEOF_VOID_P EQUAL 4) 109 # AMD64: 110 SET(MATLAB_ROOT "${MATLAB_DIR}/bin/maci64") 111 ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 4) 112 ELSE( APPLE ) #UNIX case 113 IF(CMAKE_SIZEOF_VOID_P EQUAL 4) 114 # Regular x86 115 SET(MATLAB_ROOT 116 "${MATLAB_DIR}/bin/glnx86/" 117 /usr/local/matlab-7sp1/bin/glnx86/ 118 /opt/matlab-7sp1/bin/glnx86/ 119 $ENV{HOME}/matlab-7sp1/bin/glnx86/ 120 $ENV{HOME}/redhat-matlab/bin/glnx86/ 121 ) 122 ELSE(CMAKE_SIZEOF_VOID_P EQUAL 4) 123 # AMD64: 124 SET(MATLAB_ROOT 125 "${MATLAB_DIR}/bin/glnxa64/" 126 /usr/local/matlab-7sp1/bin/glnxa64/ 127 /opt/matlab-7sp1/bin/glnxa64/ 128 $ENV{HOME}/matlab7_64/bin/glnxa64/ 129 $ENV{HOME}/matlab-7sp1/bin/glnxa64/ 130 $ENV{HOME}/redhat-matlab/bin/glnxa64/ 131 ) 132 ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 4) 133 ENDIF(APPLE) 134 # This is common to Mac & UNIX: 135 FIND_LIBRARY(MATLAB_MEX_LIBRARY 136 mex 137 ${MATLAB_ROOT} 138 ) 139 # libmx is installed by default on some Mac systems. 140 # Search for it with NO_DEFAULT_PATH first so we are more likely to find 141 # the copy that shipped with MATLAB. 142 FIND_LIBRARY(MATLAB_MX_LIBRARY 143 mx 144 ${MATLAB_ROOT} 145 NO_DEFAULT_PATH 146 ) 147 FIND_LIBRARY(MATLAB_MX_LIBRARY 148 mx 149 ${MATLAB_ROOT} 150 ) 151 FIND_LIBRARY(MATLAB_ENG_LIBRARY 152 eng 153 ${MATLAB_ROOT} 154 ) 155 FIND_PATH(MATLAB_INCLUDE_DIR 156 "mex.h" 157 "${MATLAB_DIR}/extern/include/" 158 "/usr/local/matlab-7sp1/extern/include/" 159 "/opt/matlab-7sp1/extern/include/" 160 "$ENV{HOME}/matlab-7sp1/extern/include/" 161 "$ENV{HOME}/redhat-matlab/extern/include/" 162 ) 163ENDIF(WIN32) 164 165# This is common to UNIX and Win32 and Mac: 166SET(MATLAB_LIBRARIES 167 ${MATLAB_MEX_LIBRARY} 168 ${MATLAB_MX_LIBRARY} 169 ${MATLAB_ENG_LIBRARY} 170) 171 172IF(MATLAB_INCLUDE_DIR AND MATLAB_LIBRARIES) 173 SET(MATLAB_FOUND 1) 174ENDIF(MATLAB_INCLUDE_DIR AND MATLAB_LIBRARIES) 175 176MARK_AS_ADVANCED( 177 MATLAB_LIBRARIES 178 MATLAB_MEX_LIBRARY 179 MATLAB_MX_LIBRARY 180 MATLAB_ENG_LIBRARY 181 MATLAB_INCLUDE_DIR 182 MATLAB_FOUND 183 MATLAB_ROOT 184) 185 186