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_MAT_LIBRARY: path to libmat.lib |
---|
6 | # MATLAB_MEX_LIBRARY: path to libmex.lib |
---|
7 | # MATLAB_MX_LIBRARY: path to libmx.lib |
---|
8 | # MATLAB_ENG_LIBRARY: path to libeng.lib |
---|
9 | |
---|
10 | |
---|
11 | SET(MATLAB_FOUND 0) |
---|
12 | IF(WIN32) |
---|
13 | IF(${CMAKE_GENERATOR} MATCHES "Visual Studio .*" OR ${CMAKE_GENERATOR} MATCHES "NMake Makefiles") |
---|
14 | SET(MATLAB_ROOT "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MathWorks\\MATLAB\\7.0;MATLABROOT]/extern/lib/win32/microsoft/") |
---|
15 | ELSE(${CMAKE_GENERATOR} MATCHES "Visual Studio .*" OR ${CMAKE_GENERATOR} MATCHES "NMake Makefiles") |
---|
16 | IF(${CMAKE_GENERATOR} MATCHES "Borland") |
---|
17 | # Same here, there are also: bcc50 and bcc51 directories |
---|
18 | SET(MATLAB_ROOT "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MathWorks\\MATLAB\\7.0;MATLABROOT]/extern/lib/win32/microsoft/bcc54") |
---|
19 | ELSE(${CMAKE_GENERATOR} MATCHES "Borland") |
---|
20 | MESSAGE(FATAL_ERROR "Generator not compatible: ${CMAKE_GENERATOR}") |
---|
21 | ENDIF(${CMAKE_GENERATOR} MATCHES "Borland") |
---|
22 | ENDIF(${CMAKE_GENERATOR} MATCHES "Visual Studio .*" OR ${CMAKE_GENERATOR} MATCHES "NMake Makefiles") |
---|
23 | FIND_LIBRARY(MATLAB_MEX_LIBRARY |
---|
24 | libmex |
---|
25 | ${MATLAB_ROOT} |
---|
26 | ) |
---|
27 | FIND_LIBRARY(MATLAB_MX_LIBRARY |
---|
28 | libmx |
---|
29 | ${MATLAB_ROOT} |
---|
30 | ) |
---|
31 | FIND_LIBRARY(MATLAB_ENG_LIBRARY |
---|
32 | libeng |
---|
33 | ${MATLAB_ROOT} |
---|
34 | ) |
---|
35 | FIND_LIBRARY(MATLAB_MAT_LIBRARY |
---|
36 | libmat |
---|
37 | ${MATLAB_ROOT} |
---|
38 | ) |
---|
39 | |
---|
40 | FIND_PATH(MATLAB_INCLUDE_DIR |
---|
41 | "mex.h" |
---|
42 | "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MathWorks\\MATLAB\\7.0;MATLABROOT]/extern/include" |
---|
43 | ) |
---|
44 | ELSE( WIN32 ) |
---|
45 | IF(NOT MATLAB_ROOT) |
---|
46 | IF($ENV{MATLAB_ROOT}) |
---|
47 | SET(MATLAB_ROOT $ENV{MATLAB_ROOT}) |
---|
48 | ELSE($ENV{MATLAB_ROOT}) |
---|
49 | SET(MATLAB_ROOT /opt/matlab) |
---|
50 | ENDIF($ENV{MATLAB_ROOT}) |
---|
51 | ENDIF(NOT MATLAB_ROOT) |
---|
52 | IF(CMAKE_SIZEOF_VOID_P EQUAL 4) |
---|
53 | # Regular x86 |
---|
54 | SET(MATLAB_SYS |
---|
55 | ${MATLAB_ROOT}/bin/glnx86 |
---|
56 | ) |
---|
57 | ELSE(CMAKE_SIZEOF_VOID_P EQUAL 4) |
---|
58 | # AMD64: |
---|
59 | SET(MATLAB_SYS |
---|
60 | ${MATLAB_ROOT}/bin/glnxa64 |
---|
61 | ) |
---|
62 | ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 4) |
---|
63 | FIND_LIBRARY(MATLAB_MEX_LIBRARY |
---|
64 | mex |
---|
65 | ${MATLAB_SYS} |
---|
66 | ) |
---|
67 | FIND_LIBRARY(MATLAB_MX_LIBRARY |
---|
68 | mx |
---|
69 | ${MATLAB_SYS} |
---|
70 | ) |
---|
71 | FIND_LIBRARY(MATLAB_MAT_LIBRARY |
---|
72 | mat |
---|
73 | ${MATLAB_SYS} |
---|
74 | ) |
---|
75 | FIND_LIBRARY(MATLAB_ENG_LIBRARY |
---|
76 | eng |
---|
77 | ${MATLAB_SYS} |
---|
78 | ) |
---|
79 | FIND_PATH(MATLAB_INCLUDE_DIR |
---|
80 | "mex.h" |
---|
81 | ${MATLAB_ROOT}/extern/include |
---|
82 | ) |
---|
83 | |
---|
84 | ENDIF(WIN32) |
---|
85 | |
---|
86 | # This is common to UNIX and Win32: |
---|
87 | SET(MATLAB_LIBRARIES |
---|
88 | ${MATLAB_MEX_LIBRARY} |
---|
89 | ${MATLAB_MX_LIBRARY} |
---|
90 | ${MATLAB_ENG_LIBRARY} |
---|
91 | ) |
---|
92 | |
---|
93 | IF(MATLAB_INCLUDE_DIR |
---|
94 | AND MATLAB_MEX_LIBRARY |
---|
95 | AND MATLAB_MAT_LIBRARY |
---|
96 | AND MATLAB_ENG_LIBRARY |
---|
97 | AND MATLAB_MX_LIBRARY) |
---|
98 | SET(MATLAB_LIBRARIES ${MATLAB_MX_LIBRARY} ${MATLAB_MEX_LIBRARY} ${MATLAB_ENG_LIBRARY} ${MATLAB_MAT_LIBRARY}) |
---|
99 | ENDIF(MATLAB_INCLUDE_DIR |
---|
100 | AND MATLAB_MEX_LIBRARY |
---|
101 | AND MATLAB_MAT_LIBRARY |
---|
102 | AND MATLAB_ENG_LIBRARY |
---|
103 | AND MATLAB_MX_LIBRARY) |
---|
104 | |
---|
105 | MARK_AS_ADVANCED( |
---|
106 | MATLAB_MEX_LIBRARY |
---|
107 | MATLAB_MX_LIBRARY |
---|
108 | MATLAB_ENG_LIBRARY |
---|
109 | MATLAB_INCLUDE_DIR |
---|
110 | MATLAB_ROOT |
---|
111 | ) |
---|
112 | |
---|
113 | INCLUDE(FindPackageHandleStandardArgs) |
---|
114 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(Matlab |
---|
115 | MATLAB_INCLUDE_DIR |
---|
116 | MATLAB_MEX_LIBRARY |
---|
117 | MATLAB_MAT_LIBRARY |
---|
118 | MATLAB_ENG_LIBRARY |
---|
119 | MATLAB_MX_LIBRARY ) |
---|