Compiling matlab from sources now appears as a single target

This commit is contained in:
hbristow
2013-06-19 17:37:41 +10:00
parent 0c726a3fbe
commit d9cea3b8b0
5 changed files with 375 additions and 16 deletions

View File

@@ -1,5 +1,28 @@
# compile the test sources
file(GLOB SOURCE_FILES "*.cpp")
add_custom_target(opencv_test_matlab_sources ALL)
foreach(SOURCE_FILE ${SOURCE_FILES})
get_filename_component(FILENAME ${SOURCE_FILE} NAME_WE)
# compile the source file using mex
add_custom_command(TARGET opencv_test_matlab_sources PRE_BUILD
COMMAND echo ${MATLAB_MEX_SCRIPT} ${MEX_INCLUDES}
${SOURCE_FILE}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
endforeach()
# copy the test files into the build dir
file(GLOB TEST_FILES "*.m")
foreach(TEST_FILE ${TEST_FILES})
add_custom_command(TARGET opencv_test_matlab_sources PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E
copy ${TEST_FILE} ${CMAKE_CURRENT_BINARY_DIR}
)
endforeach()
# run the matlab test suite
add_test(opencv_matlab_test
add_test(opencv_test_matlab
COMMAND ${MATLAB_BIN} "-nodisplay" "-r" "testsuite.m"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)

View File

@@ -7,7 +7,7 @@
* Copyright 2013 The OpenCV Foundation
*/
#include <exception>
#include <opencv2/core.hpp>
//#include <opencv2/core.hpp>
#include "mex.h"
/*
@@ -24,9 +24,9 @@ void mexFunction(int nlhs, mxArray* plhs[],
// call the opencv function
// [out =] namespace.fun(src1, ..., srcn, dst1, ..., dstn, opt1, ..., optn);
try {
throw cv::exception;
} catch(cv::exception& e) {
mexErrMsgTxt(e.what());
// throw cv::exception;
//} catch(cv::exception& e) {
// mexErrMsgTxt(e.what());
} catch(...) {
mexErrMsgTxt("Incorrect exception caught!");
}