File: FindMatlab.cmake

package info (click to toggle)
libsbml 5.10.0+dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 141,800 kB
  • ctags: 98,793
  • sloc: cpp: 804,405; xml: 206,907; ansic: 66,144; cs: 52,916; java: 25,093; python: 23,449; sh: 9,847; perl: 8,414; makefile: 7,580; ruby: 4,760; csh: 3
file content (290 lines) | stat: -rw-r--r-- 11,726 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
# - this module looks for Matlab
# Defines:
#  MATLAB_INCLUDE_DIR: include path for mex.h, engine.h
#  MATLAB_LIBRARIES:   required libraries: libmex, etc
#  MATLAB_MEX_LIBRARY: path to libmex.lib
#  MATLAB_MX_LIBRARY:  path to libmx.lib
#  MATLAB_ENG_LIBRARY: path to libeng.lib

# This file is based on the one coming with the CMAKE distro, however it needed adapting!
# I added a new variable: 
#
# MATLAB_ROOT_PATH which is the path to the Matlab Directory it can also be specified by the users!
#

#=============================================================================
# Copyright 2005-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distributed this file outside of CMake, substitute the full
#  License text for the above reference.)

SET(MATLAB_FOUND 0)
SET(MATLAB_MEXOPTS_FILE)
SET(MATLAB_ROOT_PATH)
SET(MATLAB_MEXEXT)
#
if (NOT "${MATLAB_ROOT_PATH}")
	if(UNIX)
		if (APPLE)
			if(EXISTS "/Applications/MATLAB_R2013b.app/")
				set(MATLAB_ROOT_PATH "/Applications/MATLAB_R2013b.app/")	
			elseif(EXISTS "/Applications/MATLAB_R2013a.app/")
				set(MATLAB_ROOT_PATH "/Applications/MATLAB_R2013a.app/")	
			elseif(EXISTS "/Applications/MATLAB_R2012b.app/")
				set(MATLAB_ROOT_PATH "/Applications/MATLAB_R2012b.app/")	
			elseif(EXISTS "/Applications/MATLAB_R2012a.app/")
				set(MATLAB_ROOT_PATH "/Applications/MATLAB_R2012a.app/")	
			elseif(EXISTS "/Applications/MATLAB_R2011b.app/")
				set(MATLAB_ROOT_PATH "/Applications/MATLAB_R2011b.app/")	
			elseif(EXISTS "/Applications/MATLAB_R2011a.app/")
				set(MATLAB_ROOT_PATH "/Applications/MATLAB_R2011a.app/")	
			elseif (EXISTS "/Applications/MATLAB_R2010b.app/")
				set(MATLAB_ROOT_PATH "/Applications/MATLAB_R2010b.app/")
			elseif(EXISTS "/Applications/MATLAB_R2010a.app/")
				set(MATLAB_ROOT_PATH "/Applications/MATLAB_R2010a.app/")
			elseif(EXISTS "/Applications/MATLAB_R2009b.app/")
				set(MATLAB_ROOT_PATH "/Applications/MATLAB_R2009b.app/")
			elseif(EXISTS "/Applications/MATLAB_R2009a.app/")
				set(MATLAB_ROOT_PATH "/Applications/MATLAB_R2009a.app/")					
			elseif(EXISTS "/Applications/MATLAB_R2008b.app/")
				set(MATLAB_ROOT_PATH "/Applications/MATLAB_R2008b.app/")
			elseif(EXISTS "/Applications/MATLAB_R2008a.app/")
				set(MATLAB_ROOT_PATH "/Applications/MATLAB_R2008a.app/")	
			endif()
		else()
			if (EXISTS "/opt/matlab/")
				set(MATLAB_ROOT_PATH "/opt/matlab/")
			endif()
		endif()
	else()
		if (CMAKE_SIZEOF_VOID_P EQUAL 4)
			if (EXISTS "C:/Program Files (x86)/MATLAB/R2011b")
				set(MATLAB_ROOT_PATH "C:/Program Files (x86)/MATLAB/R2011b")
			elseif (EXISTS "C:/Program Files (x86)/MATLAB/R2011a")
				set(MATLAB_ROOT_PATH "C:/Program Files (x86)/MATLAB/R2011a")
			elseif (EXISTS "C:/Program Files (x86)/MATLAB/R2012b")
				set(MATLAB_ROOT_PATH "C:/Program Files (x86)/MATLAB/R2012b")
			elseif (EXISTS "C:/Program Files (x86)/MATLAB/R2012a")
				set(MATLAB_ROOT_PATH "C:/Program Files (x86)/MATLAB/R2012a")
			elseif (EXISTS "C:/Program Files (x86)/MATLAB/R2013b")
				set(MATLAB_ROOT_PATH "C:/Program Files (x86)/MATLAB/R2013b")
			elseif (EXISTS "C:/Program Files (x86)/MATLAB/R2013a")
				set(MATLAB_ROOT_PATH "C:/Program Files (x86)/MATLAB/R2013a")
			elseif (EXISTS "C:/Program Files (x86)/MATLAB/R2010b")
				set(MATLAB_ROOT_PATH "C:/Program Files (x86)/MATLAB/R2010b")
			elseif (EXISTS "C:/Program Files (x86)/MATLAB/R2010a")
				set(MATLAB_ROOT_PATH "C:/Program Files (x86)/MATLAB/R2010a")
			elseif (EXISTS "C:/Program Files (x86)/MATLAB/R2009b")
				set(MATLAB_ROOT_PATH "C:/Program Files (x86)/MATLAB/R2009b")
			elseif (EXISTS "C:/Program Files (x86)/MATLAB/R2009a")
				set(MATLAB_ROOT_PATH "C:/Program Files (x86)/MATLAB/R2009a")
			elseif (EXISTS "C:/Program Files (x86)/MATLAB/R2008b")
				set(MATLAB_ROOT_PATH "C:/Program Files (x86)/MATLAB/R2008b")
			elseif (EXISTS "C:/Program Files (x86)/MATLAB/R2008a")
				set(MATLAB_ROOT_PATH "C:/Program Files (x86)/MATLAB/R2008a")
			elseif (EXISTS "C:/Program Files/MATLAB/R2011b")
				set(MATLAB_ROOT_PATH "C:/Program Files/MATLAB/R2011b")
			elseif (EXISTS "C:/Program Files/MATLAB/R2011a")
				set(MATLAB_ROOT_PATH "C:/Program Files/MATLAB/R2011a")
			elseif (EXISTS "C:/Program Files/MATLAB/R2012b")
				set(MATLAB_ROOT_PATH "C:/Program Files/MATLAB/R2012b")
			elseif (EXISTS "C:/Program Files/MATLAB/R2012a")
				set(MATLAB_ROOT_PATH "C:/Program Files/MATLAB/R2012a")
			elseif (EXISTS "C:/Program Files/MATLAB/R2011b")
				set(MATLAB_ROOT_PATH "C:/Program Files/MATLAB/R2011b")
			elseif (EXISTS "C:/Program Files/MATLAB/R2011a")
				set(MATLAB_ROOT_PATH "C:/Program Files/MATLAB/R2011a")
			elseif (EXISTS "C:/Program Files/MATLAB/R2010b")
				set(MATLAB_ROOT_PATH "C:/Program Files/MATLAB/R2010b")
			elseif (EXISTS "C:/Program Files/MATLAB/R2010a")
				set(MATLAB_ROOT_PATH "C:/Program Files/MATLAB/R2010a")
			elseif (EXISTS "C:/Program Files/MATLAB/R2009b")
				set(MATLAB_ROOT_PATH "C:/Program Files/MATLAB/R2009b")
			elseif (EXISTS "C:/Program Files/MATLAB/R2009a")
				set(MATLAB_ROOT_PATH "C:/Program Files/MATLAB/R2009a")
			elseif (EXISTS "C:/Program Files/MATLAB/R2008b")
				set(MATLAB_ROOT_PATH "C:/Program Files/MATLAB/R2008b")
			elseif (EXISTS "C:/Program Files/MATLAB/R2008a")
				set(MATLAB_ROOT_PATH "C:/Program Files/MATLAB/R2008a")
			endif()
		else()
			if (EXISTS "C:/Program Files/MATLAB/R2011b")
				set(MATLAB_ROOT_PATH "C:/Program Files/MATLAB/R2011b")
			elseif (EXISTS "C:/Program Files/MATLAB/R2011a")
				set(MATLAB_ROOT_PATH "C:/Program Files/MATLAB/R2011a")
			elseif (EXISTS "C:/Program Files/MATLAB/R2012b")
				set(MATLAB_ROOT_PATH "C:/Program Files/MATLAB/R2012b")
			elseif (EXISTS "C:/Program Files/MATLAB/R2012a")
				set(MATLAB_ROOT_PATH "C:/Program Files/MATLAB/R2012a")
			elseif (EXISTS "C:/Program Files/MATLAB/R2013b")
				set(MATLAB_ROOT_PATH "C:/Program Files/MATLAB/R2013b")
			elseif (EXISTS "C:/Program Files/MATLAB/R2013a")
				set(MATLAB_ROOT_PATH "C:/Program Files/MATLAB/R2013a")
			elseif (EXISTS "C:/Program Files/MATLAB/R2010b")
				set(MATLAB_ROOT_PATH "C:/Program Files/MATLAB/R2010b")
			elseif (EXISTS "C:/Program Files/MATLAB/R2010a")
				set(MATLAB_ROOT_PATH "C:/Program Files/MATLAB/R2010a")
			elseif (EXISTS "C:/Program Files/MATLAB/R2009b")
				set(MATLAB_ROOT_PATH "C:/Program Files/MATLAB/R2009b")
			elseif (EXISTS "C:/Program Files/MATLAB/R2009a")
				set(MATLAB_ROOT_PATH "C:/Program Files/MATLAB/R2009a")
			elseif (EXISTS "C:/Program Files/MATLAB/R2008b")
				set(MATLAB_ROOT_PATH "C:/Program Files/MATLAB/R2008b")
			elseif (EXISTS "C:/Program Files/MATLAB/R2008a")
				set(MATLAB_ROOT_PATH "C:/Program Files/MATLAB/R2008a")
			endif()
		endif()
	endif()
endif() 

if (NOT EXISTS "${MATLAB_ROOT_PATH}")
	message(FATAL_ERROR "The Matlab installation could not be found, please specify the MATLAB_ROOT_PATH.")
else()
	set(MATLAB_ROOT_PATH "${MATLAB_ROOT_PATH}" CACHE PATH "Matlab directory")
endif()

SET(MATLAB_MEX_COMMAND)
SET(MATLAB_MATLAB_COMMAND)
IF(WIN32)
  IF(${CMAKE_GENERATOR} MATCHES "Visual Studio 6")
    SET(MATLAB_ROOT "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MathWorks\\MATLAB\\7.0;MATLABROOT]/extern/lib/win32/microsoft/msvc60")
	if(NOT EXISTS "${MATLAB_ROOT}")
		SET(MATLAB_ROOT "${MATLAB_ROOT_PATH}/extern/lib/win32/microsoft/msvc60")
	endif()
  ELSE(${CMAKE_GENERATOR} MATCHES "Visual Studio 6")
    IF(${CMAKE_GENERATOR} MATCHES "Visual Studio 7")
      # Assume people are generally using 7.1,
      # if using 7.0 need to link to: ../extern/lib/win32/microsoft/msvc70
      SET(MATLAB_ROOT "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MathWorks\\MATLAB\\7.0;MATLABROOT]/extern/lib/win32/microsoft/msvc71")
	  if(NOT EXISTS "${MATLAB_ROOT}")
		SET(MATLAB_ROOT "${MATLAB_ROOT_PATH}/extern/lib/win32/microsoft/msvc71")
	  endif()
    ELSE(${CMAKE_GENERATOR} MATCHES "Visual Studio 7")
      IF(${CMAKE_GENERATOR} MATCHES "Borland")
        # Same here, there are also: bcc50 and bcc51 directories
        SET(MATLAB_ROOT "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MathWorks\\MATLAB\\7.0;MATLABROOT]/extern/lib/win32/microsoft/bcc54")
		if(NOT EXISTS "${MATLAB_ROOT}")
			SET(MATLAB_ROOT "${MATLAB_ROOT_PATH}/extern/lib/win32/microsoft/bcc54")
		endif()
      ELSE(${CMAKE_GENERATOR} MATCHES "Borland")
        IF(MATLAB_FIND_REQUIRED)
          MESSAGE(FATAL_ERROR "Generator not compatible: ${CMAKE_GENERATOR}")
        ENDIF(MATLAB_FIND_REQUIRED)
      ENDIF(${CMAKE_GENERATOR} MATCHES "Borland")
    ENDIF(${CMAKE_GENERATOR} MATCHES "Visual Studio 7")
  ENDIF(${CMAKE_GENERATOR} MATCHES "Visual Studio 6")
  
  # unfortunately this won't find matlab R2010b on my machine
  if (NOT "${MATLAB_ROOT}")
		SET(MATLAB_MEX_COMMAND "${MATLAB_ROOT_PATH}/bin/mex.bat")
		if (CMAKE_SIZEOF_VOID_P EQUAL 4)
			SET(MATLAB_ROOT "${MATLAB_ROOT_PATH}/extern/lib/win32/microsoft/")
		else()
			SET(MATLAB_ROOT "${MATLAB_ROOT_PATH}/extern/lib/win64/microsoft/")
		endif()
  endif()
  SET(MATLAB_MEXEXT "${MATLAB_ROOT_PATH}/bin/mexext.bat")
  SET(MATLAB_MATLAB_COMMAND "${MATLAB_ROOT_PATH}/bin/matlab.bat")
ELSE (WIN32)
	SET(MATLAB_MEX_COMMAND "${MATLAB_ROOT_PATH}/bin/mex")
	SET(MATLAB_MEXEXT "${CMAKE_SOURCE_DIR}/debian/bin/mexext")
	SET(MATLAB_MATLAB_COMMAND "${MATLAB_ROOT_PATH}/bin/matlab")
	MESSAGE(STATUS ${MATLAB_ROOT_PATH}/bin/maci64/)
	if(APPLE)
		SET(MATLAB_ROOT 
			${MATLAB_ROOT_PATH}/extern/lib/maci64/
			${MATLAB_ROOT_PATH}/bin/maci64/
		)
	else()

		IF(CMAKE_SIZEOF_VOID_P EQUAL 4)
		# Regular x86
		SET(MATLAB_ROOT
		/usr/local/matlab-7sp1/bin/glnx86/
		/opt/matlab-7sp1/bin/glnx86/
		$ENV{HOME}/matlab-7sp1/bin/glnx86/
		$ENV{HOME}/redhat-matlab/bin/glnx86/
		${MATLAB_ROOT_PATH}/bin/glnx86/
		)
		ELSE(CMAKE_SIZEOF_VOID_P EQUAL 4)
		# AMD64:
		SET(MATLAB_ROOT
		/usr/local/matlab-7sp1/bin/glnxa64/
		/opt/matlab-7sp1/bin/glnxa64/
		$ENV{HOME}/matlab7_64/bin/glnxa64/
		$ENV{HOME}/matlab-7sp1/bin/glnxa64/
		$ENV{HOME}/redhat-matlab/bin/glnxa64/
		${MATLAB_ROOT_PATH}/bin/glnxa64/
		)
		ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 4)
	endif()
ENDIF(WIN32)
    
  FIND_LIBRARY(MATLAB_MEX_LIBRARY
    NAMES libmex mex  libmex.dylib
    PATHS
	${MATLAB_ROOT}
	${MATLAB_ROOT_PATH}/bin/maci64/
    )
  FIND_LIBRARY(MATLAB_MX_LIBRARY
    NAMES libmx mx  libmx.dylib
	PATHS
    ${MATLAB_ROOT}
	${MATLAB_ROOT_PATH}/bin/maci64/
    )
  FIND_LIBRARY(MATLAB_ENG_LIBRARY
    NAMES libeng eng libeng.dylib
	PATHS
    ${MATLAB_ROOT}
	${MATLAB_ROOT_PATH}/bin/maci64/
    )

  FIND_PATH(MATLAB_INCLUDE_DIR
    "mex.h"
	PATHS
    "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MathWorks\\MATLAB\\7.0;MATLABROOT]/extern/include"
	"C:/Program Files (x86)/MATLAB/R2010b/extern/include"
	"C:/Program Files/MATLAB/R2010b/extern/include"
	"/Applications/MATLAB_R2010b.app/extern/include"
    "${MATLAB_ROOT_PATH}/extern/include"
    "/usr/local/matlab-7sp1/extern/include/"
    "/opt/matlab-7sp1/extern/include/"
    "$ENV{HOME}/matlab-7sp1/extern/include/"
    "$ENV{HOME}/redhat-matlab/extern/include/"
    )

# This is common to UNIX and Win32:
SET(MATLAB_LIBRARIES
  ${MATLAB_MEX_LIBRARY}
  ${MATLAB_MX_LIBRARY}
  ${MATLAB_ENG_LIBRARY}
)

IF(MATLAB_INCLUDE_DIR AND MATLAB_LIBRARIES)
  SET(MATLAB_FOUND 1)
ENDIF(MATLAB_INCLUDE_DIR AND MATLAB_LIBRARIES)



execute_process(COMMAND ${MATLAB_MEXEXT} OUTPUT_VARIABLE MATLAB_MEX_EXT)
STRING(STRIP "${MATLAB_MEX_EXT}" MATLAB_MEX_EXT)

MARK_AS_ADVANCED(
  MATLAB_LIBRARIES
  MATLAB_MEX_LIBRARY
  MATLAB_MX_LIBRARY
  MATLAB_ENG_LIBRARY
  MATLAB_INCLUDE_DIR
  MATLAB_FOUND
  MATLAB_MATLAB_COMMAND
  MATLAB_ROOT
  MATLAB_ROOT_PATH
)