-
Notifications
You must be signed in to change notification settings - Fork 6
/
FindMatlab.cmake
152 lines (139 loc) · 3.85 KB
/
FindMatlab.cmake
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
# - this module looks for Matlab
# Defines:
# MATLAB_INCLUDE_DIR: include path for mex.h, engine.h
# MATLAB_LIBRARIES: required libraries: libmex, etc
# MATLAB_MAT_LIBRARY: path to libmat.lib
# MATLAB_MEX_LIBRARY: path to libmex.lib
# MATLAB_MX_LIBRARY: path to libmx.lib
# MATLAB_ENG_LIBRARY: path to libeng.lib
set(MATLAB_ROOT "" CACHE PATH "Directory containing matlab.")
if(NOT MATLAB_ROOT)
if(WIN32)
if(${CMAKE_GENERATOR} MATCHES "Visual Studio .*" OR ${CMAKE_GENERATOR} MATCHES "NMake Makefiles")
set(MATLAB_ROOT "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MathWorks\\MATLAB\\7.0;MATLABROOT]/extern/lib/win32/microsoft/")
else(${CMAKE_GENERATOR} MATCHES "Visual Studio .*" OR ${CMAKE_GENERATOR} MATCHES "NMake Makefiles")
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")
else(${CMAKE_GENERATOR} MATCHES "Borland")
message(FATAL_ERROR "Generator not compatible: ${CMAKE_GENERATOR}")
endif(${CMAKE_GENERATOR} MATCHES "Borland")
endif(${CMAKE_GENERATOR} MATCHES "Visual Studio .*" OR ${CMAKE_GENERATOR} MATCHES "NMake Makefiles")
else( WIN32 )
if(NOT MATLAB_ROOT)
if($ENV{MATLAB_ROOT})
set(MATLAB_ROOT $ENV{MATLAB_ROOT})
else($ENV{MATLAB_ROOT})
set(MATLAB_ROOT /opt/matlab)
endif($ENV{MATLAB_ROOT})
endif(NOT MATLAB_ROOT)
endif(WIN32)
endif(NOT MATLAB_ROOT)
set(MATLAB_FOUND 0)
if(WIN32)
find_library(MATLAB_MEX_LIBRARY
libmex
${MATLAB_ROOT}
)
find_library(MATLAB_MX_LIBRARY
libmx
${MATLAB_ROOT}
)
find_library(MATLAB_ENG_LIBRARY
libeng
${MATLAB_ROOT}
)
find_library(MATLAB_MAT_LIBRARY
libmat
${MATLAB_ROOT}
)
find_path(MATLAB_INCLUDE_DIR
"mex.h"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\MathWorks\\MATLAB\\7.0;MATLABROOT]/extern/include"
)
else( WIN32 )
if(APPLE)
if(CMAKE_OSX_ARCHITECTURES MATCHES i386)
# mac intel
set(MATLAB_SYS
${MATLAB_ROOT}/bin/maci
)
else(CMAKE_OSX_ARCHITECTURES MATCHES i386)
# mac powerpc
set(MATLAB_SYS
${MATLAB_ROOT}/bin/mac
)
endif(CMAKE_OSX_ARCHITECTURES MATCHES i386)
else(APPLE)
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
# Regular x86
set(MATLAB_SYS
${MATLAB_ROOT}/bin/glnx86
)
else(CMAKE_SIZEOF_VOID_P EQUAL 4)
# AMD64:
set(MATLAB_SYS
${MATLAB_ROOT}/bin/glnxa64
)
endif(CMAKE_SIZEOF_VOID_P EQUAL 4)
endif(APPLE)
find_library(MATLAB_MEX_LIBRARY
mex
PATHS
${MATLAB_SYS}
NO_DEFAULT_PATH
)
find_library(MATLAB_MX_LIBRARY
mx
PATHS
${MATLAB_SYS}
NO_DEFAULT_PATH
)
find_library(MATLAB_MAT_LIBRARY
mat
PATHS
${MATLAB_SYS}
NO_DEFAULT_PATH
)
find_library(MATLAB_ENG_LIBRARY
eng
PATHS
${MATLAB_SYS}
NO_DEFAULT_PATH
)
find_path(MATLAB_INCLUDE_DIR
"mex.h"
${MATLAB_ROOT}/extern/include
)
endif(WIN32)
# 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_MEX_LIBRARY
AND MATLAB_MAT_LIBRARY
AND MATLAB_ENG_LIBRARY
AND MATLAB_MX_LIBRARY)
set(MATLAB_LIBRARIES ${MATLAB_MX_LIBRARY} ${MATLAB_MEX_LIBRARY} ${MATLAB_ENG_LIBRARY} ${MATLAB_MAT_LIBRARY})
endif(MATLAB_INCLUDE_DIR
AND MATLAB_MEX_LIBRARY
AND MATLAB_MAT_LIBRARY
AND MATLAB_ENG_LIBRARY
AND MATLAB_MX_LIBRARY)
mark_as_advanced(
MATLAB_MAT_LIBRARY
MATLAB_MEX_LIBRARY
MATLAB_MX_LIBRARY
MATLAB_ENG_LIBRARY
MATLAB_INCLUDE_DIR
)
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Matlab
MATLAB_INCLUDE_DIR
MATLAB_MEX_LIBRARY
MATLAB_MAT_LIBRARY
MATLAB_ENG_LIBRARY
MATLAB_MX_LIBRARY )