summaryrefslogtreecommitdiff
path: root/Tests/RunCMake/FindMatlab
diff options
context:
space:
mode:
authorRaffi Enficiaud <raffi.enficiaud@tuebingen.mpg.de>2015-02-12 17:13:31 +0100
committerBrad King <brad.king@kitware.com>2015-03-17 09:47:04 -0400
commit49c8dcf7bb8ae9e7584286e552769a61bf23e61b (patch)
tree5f87e1b1974d15a6b23babdc730b321dde1c7f44 /Tests/RunCMake/FindMatlab
parent6390d5f5cb107dcc4a0bc6124ab5f17370dcadcd (diff)
downloadcmake-49c8dcf7bb8ae9e7584286e552769a61bf23e61b.tar.gz
FindMatlab: Rewrite module and provide a usage API
Implement a brand new FindMatlab module: - Add support for versions and components. - Find Matlab and its version in a more precise and multiplatform way. - Add API to create a new mex extension with documentation. - Add API to add matlab unit tests (with or without the unit test framework). - Find as much as possible based on a single Matlab_ROOT_DIR cache entry and allow the user to change it to re-find everything.
Diffstat (limited to 'Tests/RunCMake/FindMatlab')
-rw-r--r--Tests/RunCMake/FindMatlab/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/FindMatlab/MatlabTest1-result.txt1
-rw-r--r--Tests/RunCMake/FindMatlab/MatlabTest1-stderr.txt2
-rw-r--r--Tests/RunCMake/FindMatlab/MatlabTest1.cmake22
-rw-r--r--Tests/RunCMake/FindMatlab/RunCMakeTest.cmake3
-rw-r--r--Tests/RunCMake/FindMatlab/cmake_matlab_unit_tests2.m6
-rw-r--r--Tests/RunCMake/FindMatlab/matlab_wrapper1.cpp26
7 files changed, 63 insertions, 0 deletions
diff --git a/Tests/RunCMake/FindMatlab/CMakeLists.txt b/Tests/RunCMake/FindMatlab/CMakeLists.txt
new file mode 100644
index 0000000000..1b9a957882
--- /dev/null
+++ b/Tests/RunCMake/FindMatlab/CMakeLists.txt
@@ -0,0 +1,3 @@
+
+cmake_minimum_required(VERSION 2.8.12)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/FindMatlab/MatlabTest1-result.txt b/Tests/RunCMake/FindMatlab/MatlabTest1-result.txt
new file mode 100644
index 0000000000..d00491fd7e
--- /dev/null
+++ b/Tests/RunCMake/FindMatlab/MatlabTest1-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/FindMatlab/MatlabTest1-stderr.txt b/Tests/RunCMake/FindMatlab/MatlabTest1-stderr.txt
new file mode 100644
index 0000000000..95a787fa12
--- /dev/null
+++ b/Tests/RunCMake/FindMatlab/MatlabTest1-stderr.txt
@@ -0,0 +1,2 @@
+CMake Error at .*FindMatlab.cmake:[0-9]+ \(message\):
+ \[MATLAB\] This functionality needs the MAIN_PROGRAM component \(not default\)
diff --git a/Tests/RunCMake/FindMatlab/MatlabTest1.cmake b/Tests/RunCMake/FindMatlab/MatlabTest1.cmake
new file mode 100644
index 0000000000..1cbc1c2021
--- /dev/null
+++ b/Tests/RunCMake/FindMatlab/MatlabTest1.cmake
@@ -0,0 +1,22 @@
+
+cmake_minimum_required (VERSION 2.8.12)
+enable_testing()
+project(test_should_fail)
+
+find_package(Matlab REQUIRED COMPONENTS MX_LIBRARY)
+
+matlab_add_mex(
+ # target name
+ NAME cmake_matlab_test_wrapper1
+ # output name
+ OUTPUT_NAME cmake_matlab_mex1
+ SRC ${CMAKE_CURRENT_SOURCE_DIR}/matlab_wrapper1.cpp
+ )
+
+# this command should raise a FATAL_ERROR, component MAIN_PROGRAM is missing
+matlab_add_unit_test(
+ NAME ${PROJECT_NAME}_matlabtest-1
+ TIMEOUT 1
+ UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/cmake_matlab_unit_tests2.m
+ ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1>
+ )
diff --git a/Tests/RunCMake/FindMatlab/RunCMakeTest.cmake b/Tests/RunCMake/FindMatlab/RunCMakeTest.cmake
new file mode 100644
index 0000000000..33dbb772c4
--- /dev/null
+++ b/Tests/RunCMake/FindMatlab/RunCMakeTest.cmake
@@ -0,0 +1,3 @@
+
+include(RunCMake)
+run_cmake(MatlabTest1)
diff --git a/Tests/RunCMake/FindMatlab/cmake_matlab_unit_tests2.m b/Tests/RunCMake/FindMatlab/cmake_matlab_unit_tests2.m
new file mode 100644
index 0000000000..7a8a342dec
--- /dev/null
+++ b/Tests/RunCMake/FindMatlab/cmake_matlab_unit_tests2.m
@@ -0,0 +1,6 @@
+
+ret = cmake_matlab_mex1(rand(3,3));
+
+if(size(ret) ~= size(rand(3,3)))
+ error('Dimension mismatch!');
+end
diff --git a/Tests/RunCMake/FindMatlab/matlab_wrapper1.cpp b/Tests/RunCMake/FindMatlab/matlab_wrapper1.cpp
new file mode 100644
index 0000000000..4149bb954e
--- /dev/null
+++ b/Tests/RunCMake/FindMatlab/matlab_wrapper1.cpp
@@ -0,0 +1,26 @@
+
+// simple workaround to some compiler specific problems
+// see http://stackoverflow.com/questions/22367516/mex-compile-error-unknown-type-name-char16-t/23281916#23281916
+#include <algorithm>
+
+#include "mex.h"
+
+// this test should return a matrix of 10 x 10 and should check some of the arguments
+
+void mexFunction(const int nlhs, mxArray *plhs[], const int nrhs, const mxArray *prhs[])
+{
+ if(nrhs != 1)
+ {
+ mexErrMsgTxt("Incorrect arguments");
+ }
+
+ size_t dim1 = mxGetM(prhs[0]);
+ size_t dim2 = mxGetN(prhs[0]);
+
+ if(dim1 == 1 || dim2 == 1)
+ {
+ mexErrMsgIdAndTxt("cmake_matlab:configuration", "Incorrect arguments");
+ }
+
+ plhs[0] = mxCreateNumericMatrix(dim1, dim2, mxGetClassID(prhs[0]), mxREAL);
+}