This is a minimal standalone example of using Matlab's build system buildtool as configured by buildfile.m to build MEX targets and run tests. buildtool can be used instead of CMake or custom scripts to check code, build binaries and run tests, among other tasks including coverage tests and publishing documentation.
buildtool check
checks the syntax of Matlab script using CodeIssuesTask.
buildtool mex
builds MEX targets using MexTask.
buildtool test
runs tests using TestTask.
See several additional examples of more advanced Mex and Matlab Engine tasks. Matlab-stdlib is another substantial example of buildfile.m usage.