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 checkchecks the syntax of Matlab script using CodeIssuesTask.
buildtool mexbuilds MEX targets using MexTask.
buildtool testruns 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.