ENH: fix bug where sharedforward would not work if there was a space in the path...
[cmake.git] / Modules / FindMatlab.cmake
blob37619c22aa5f2c69fb8e0b6b2625dd9bd8cc67ba
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
10 SET(MATLAB_FOUND 0)
11 IF(WIN32)
12   IF(${CMAKE_GENERATOR} MATCHES "Visual Studio 6")
13     SET(MATLAB_ROOT "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MathWorks\\MATLAB\\7.0;MATLABROOT]/extern/lib/win32/microsoft/msvc60")
14   ELSE(${CMAKE_GENERATOR} MATCHES "Visual Studio 6")
15     IF(${CMAKE_GENERATOR} MATCHES "Visual Studio 7")
16       # Assume people are generally using 7.1,
17       # if using 7.0 need to link to: ../extern/lib/win32/microsoft/msvc70
18       SET(MATLAB_ROOT "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MathWorks\\MATLAB\\7.0;MATLABROOT]/extern/lib/win32/microsoft/msvc71")
19     ELSE(${CMAKE_GENERATOR} MATCHES "Visual Studio 7")
20       IF(${CMAKE_GENERATOR} MATCHES "Borland")
21         # Same here, there are also: bcc50 and bcc51 directories
22         SET(MATLAB_ROOT "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MathWorks\\MATLAB\\7.0;MATLABROOT]/extern/lib/win32/microsoft/bcc54")
23       ELSE(${CMAKE_GENERATOR} MATCHES "Borland")
24         IF(MATLAB_FIND_REQUIRED)
25           MESSAGE(FATAL_ERROR "Generator not compatible: ${CMAKE_GENERATOR}")
26         ENDIF(MATLAB_FIND_REQUIRED)
27       ENDIF(${CMAKE_GENERATOR} MATCHES "Borland")
28     ENDIF(${CMAKE_GENERATOR} MATCHES "Visual Studio 7")
29   ENDIF(${CMAKE_GENERATOR} MATCHES "Visual Studio 6")
30   FIND_LIBRARY(MATLAB_MEX_LIBRARY
31     libmex
32     ${MATLAB_ROOT}
33     )
34   FIND_LIBRARY(MATLAB_MX_LIBRARY
35     libmx
36     ${MATLAB_ROOT}
37     )
38   FIND_LIBRARY(MATLAB_ENG_LIBRARY
39     libeng
40     ${MATLAB_ROOT}
41     )
43   FIND_PATH(MATLAB_INCLUDE_DIR
44     "mex.h"
45     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MathWorks\\MATLAB\\7.0;MATLABROOT]/extern/include"
46     )
47 ELSE( WIN32 )
48   IF(CMAKE_SIZEOF_VOID_P EQUAL 4)
49     # Regular x86
50     SET(MATLAB_ROOT
51       /usr/local/matlab-7sp1/bin/glnx86/
52       /opt/matlab-7sp1/bin/glnx86/
53       $ENV{HOME}/matlab-7sp1/bin/glnx86/
54       $ENV{HOME}/redhat-matlab/bin/glnx86/
55       )
56   ELSE(CMAKE_SIZEOF_VOID_P EQUAL 4)
57     # AMD64:
58     SET(MATLAB_ROOT
59       /usr/local/matlab-7sp1/bin/glnxa64/
60       /opt/matlab-7sp1/bin/glnxa64/
61       $ENV{HOME}/matlab7_64/bin/glnxa64/
62       $ENV{HOME}/matlab-7sp1/bin/glnxa64/
63       $ENV{HOME}/redhat-matlab/bin/glnxa64/
64       )
65   ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 4)
66   FIND_LIBRARY(MATLAB_MEX_LIBRARY
67     mex
68     ${MATLAB_ROOT}
69     )
70   FIND_LIBRARY(MATLAB_MX_LIBRARY
71     mx
72     ${MATLAB_ROOT}
73     )
74   FIND_LIBRARY(MATLAB_ENG_LIBRARY
75     eng
76     ${MATLAB_ROOT}
77     )
78   FIND_PATH(MATLAB_INCLUDE_DIR
79     "mex.h"
80     "/usr/local/matlab-7sp1/extern/include/"
81     "/opt/matlab-7sp1/extern/include/"
82     "$ENV{HOME}/matlab-7sp1/extern/include/"
83     "$ENV{HOME}/redhat-matlab/extern/include/"
84     )
86 ENDIF(WIN32)
88 # This is common to UNIX and Win32:
89 SET(MATLAB_LIBRARIES
90   ${MATLAB_MEX_LIBRARY}
91   ${MATLAB_MX_LIBRARY}
92   ${MATLAB_ENG_LIBRARY}
95 IF(MATLAB_INCLUDE_DIR AND MATLAB_LIBRARIES)
96   SET(MATLAB_FOUND 1)
97 ENDIF(MATLAB_INCLUDE_DIR AND MATLAB_LIBRARIES)
99 MARK_AS_ADVANCED(
100   MATLAB_LIBRARIES
101   MATLAB_MEX_LIBRARY
102   MATLAB_MX_LIBRARY
103   MATLAB_ENG_LIBRARY
104   MATLAB_INCLUDE_DIR
105   MATLAB_FOUND
106   MATLAB_ROOT