FindMatlab.cmake 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. # Copyright 2005-2009 Kitware, Inc.
  10. #
  11. # Distributed under the OSI-approved BSD License (the "License");
  12. # see accompanying file Copyright.txt for details.
  13. #
  14. # This software is distributed WITHOUT ANY WARRANTY; without even the
  15. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  16. # See the License for more information.
  17. #=============================================================================
  18. # (To distributed this file outside of CMake, substitute the full
  19. # License text for the above reference.)
  20. SET(MATLAB_FOUND 0)
  21. IF(WIN32)
  22. IF(${CMAKE_GENERATOR} MATCHES "Visual Studio 6")
  23. SET(MATLAB_ROOT "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MathWorks\\MATLAB\\7.0;MATLABROOT]/extern/lib/win32/microsoft/msvc60")
  24. ELSE(${CMAKE_GENERATOR} MATCHES "Visual Studio 6")
  25. IF(${CMAKE_GENERATOR} MATCHES "Visual Studio 7")
  26. # Assume people are generally using 7.1,
  27. # if using 7.0 need to link to: ../extern/lib/win32/microsoft/msvc70
  28. SET(MATLAB_ROOT "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MathWorks\\MATLAB\\7.0;MATLABROOT]/extern/lib/win32/microsoft/msvc71")
  29. ELSE(${CMAKE_GENERATOR} MATCHES "Visual Studio 7")
  30. IF(${CMAKE_GENERATOR} MATCHES "Borland")
  31. # Same here, there are also: bcc50 and bcc51 directories
  32. SET(MATLAB_ROOT "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MathWorks\\MATLAB\\7.0;MATLABROOT]/extern/lib/win32/microsoft/bcc54")
  33. ELSE(${CMAKE_GENERATOR} MATCHES "Borland")
  34. IF(MATLAB_FIND_REQUIRED)
  35. MESSAGE(FATAL_ERROR "Generator not compatible: ${CMAKE_GENERATOR}")
  36. ENDIF(MATLAB_FIND_REQUIRED)
  37. ENDIF(${CMAKE_GENERATOR} MATCHES "Borland")
  38. ENDIF(${CMAKE_GENERATOR} MATCHES "Visual Studio 7")
  39. ENDIF(${CMAKE_GENERATOR} MATCHES "Visual Studio 6")
  40. FIND_LIBRARY(MATLAB_MEX_LIBRARY
  41. libmex
  42. ${MATLAB_ROOT}
  43. )
  44. FIND_LIBRARY(MATLAB_MX_LIBRARY
  45. libmx
  46. ${MATLAB_ROOT}
  47. )
  48. FIND_LIBRARY(MATLAB_ENG_LIBRARY
  49. libeng
  50. ${MATLAB_ROOT}
  51. )
  52. FIND_PATH(MATLAB_INCLUDE_DIR
  53. "mex.h"
  54. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MathWorks\\MATLAB\\7.0;MATLABROOT]/extern/include"
  55. )
  56. ELSE( WIN32 )
  57. IF(CMAKE_SIZEOF_VOID_P EQUAL 4)
  58. # Regular x86
  59. SET(MATLAB_ROOT
  60. /usr/local/matlab-7sp1/bin/glnx86/
  61. /opt/matlab-7sp1/bin/glnx86/
  62. $ENV{HOME}/matlab-7sp1/bin/glnx86/
  63. $ENV{HOME}/redhat-matlab/bin/glnx86/
  64. )
  65. ELSE(CMAKE_SIZEOF_VOID_P EQUAL 4)
  66. # AMD64:
  67. SET(MATLAB_ROOT
  68. /usr/local/matlab-7sp1/bin/glnxa64/
  69. /opt/matlab-7sp1/bin/glnxa64/
  70. $ENV{HOME}/matlab7_64/bin/glnxa64/
  71. $ENV{HOME}/matlab-7sp1/bin/glnxa64/
  72. $ENV{HOME}/redhat-matlab/bin/glnxa64/
  73. )
  74. ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 4)
  75. FIND_LIBRARY(MATLAB_MEX_LIBRARY
  76. mex
  77. ${MATLAB_ROOT}
  78. )
  79. FIND_LIBRARY(MATLAB_MX_LIBRARY
  80. mx
  81. ${MATLAB_ROOT}
  82. )
  83. FIND_LIBRARY(MATLAB_ENG_LIBRARY
  84. eng
  85. ${MATLAB_ROOT}
  86. )
  87. FIND_PATH(MATLAB_INCLUDE_DIR
  88. "mex.h"
  89. "/usr/local/matlab-7sp1/extern/include/"
  90. "/opt/matlab-7sp1/extern/include/"
  91. "$ENV{HOME}/matlab-7sp1/extern/include/"
  92. "$ENV{HOME}/redhat-matlab/extern/include/"
  93. )
  94. ENDIF(WIN32)
  95. # This is common to UNIX and Win32:
  96. SET(MATLAB_LIBRARIES
  97. ${MATLAB_MEX_LIBRARY}
  98. ${MATLAB_MX_LIBRARY}
  99. ${MATLAB_ENG_LIBRARY}
  100. )
  101. IF(MATLAB_INCLUDE_DIR AND MATLAB_LIBRARIES)
  102. SET(MATLAB_FOUND 1)
  103. ENDIF(MATLAB_INCLUDE_DIR AND MATLAB_LIBRARIES)
  104. MARK_AS_ADVANCED(
  105. MATLAB_LIBRARIES
  106. MATLAB_MEX_LIBRARY
  107. MATLAB_MX_LIBRARY
  108. MATLAB_ENG_LIBRARY
  109. MATLAB_INCLUDE_DIR
  110. MATLAB_FOUND
  111. MATLAB_ROOT
  112. )