# Revision history [back]

Detail 4: Finding Matlab

The FindMatlab.cmake distributed with cmake by KitWare is woefully inadequate at finding any recent releases of Matlab. So it's time to write a new one. With a bit of crowd-sourcing I've been able to come up with the default install paths of Matlab on different architectures (in order of likelihood)

Linux: /usr/local /opt/local /usr /opt

Apple: /Applications /usr/local /opt/local /usr /opt

Windows: C:\Program Files C:\Program Files (x86)

In the case of Windows machines, assuming everything is in C: is a baaaad idea, so there are (gulp) recommended methods of hunting through the registry for paths:

execute_process(COMMAND reg query HKLM\\SOFTWARE\\MathWorks\\MATLAB /f * /k)


In the case of Unix derivatives, grep and regex are your friends.

OpenCV eschews the regular package finding convention of find_package(<package>) which locates a Find<package>.cmake file on the CMAKE_MODULE_PATH, in favour of having all the packages called OpenCV[Find/Detect]<package>.cmake and then simply including them in the root CMakeLists.txt as include(cmake/OpenCV[Find/Deteect]<package>.cmake). This is for one very simple and deliberate reason:

They want to make sure their own cmake files are loaded and not other ones on the system