Commit d9cea3b8 authored by hbristow's avatar hbristow

Compiling matlab from sources now appears as a single target

parent 0c726a3f
......@@ -46,6 +46,9 @@ ocv_add_module(matlab BINDINGS opencv_core opencv_imgproc
opencv_highgui opencv_ml opencv_calib3d opencv_photo
opencv_nonfree opencv_calib)
set(HDR_PARSER_PATH ${OPENCV_MODULE_opencv_python_LOCATION}/src2)
prepend("-I" MEX_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/include)
if (BUILD_TESTS)
add_subdirectory(test)
endif()
......@@ -53,9 +56,6 @@ endif()
# ----------------------------------------------------------------------------
# Configure time components
# ----------------------------------------------------------------------------
set(HDR_PARSER_PATH ${OPENCV_MODULE_opencv_python_LOCATION}/src2)
prepend("-I" MEX_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/include)
message("-- Trying to generate Matlab code")
execute_process(
COMMAND ${PYTHON_EXECUTABLE}
......@@ -102,7 +102,6 @@ string(REPLACE "opencv_" "" OPENCV_MATLAB_MODULES "${OPENCV_MODULE_${the_module}
foreach(module ${OPENCV_MATLAB_MODULES})
if (HAVE_opencv_${module})
list(APPEND opencv_hdrs "${OPENCV_MODULE_opencv_${module}_LOCATION}/include/opencv2/${module}.hpp")
prepend("-I" MEX_INCLUDES "${OPENCV_MODULE_opencv_${module}_LOCATION}/include")
endif()
endforeach()
......@@ -113,15 +112,15 @@ add_custom_target(opencv_matlab_sources ALL
${opencv_hdrs} ${CMAKE_CURRENT_BINARY_DIR}
)
# get the matlab sources
# compile the matlab sources to mex
add_custom_target(opencv_matlab ALL)
file(GLOB SOURCE_FILES "${CMAKE_CURRENT_BINARY_DIR}/src/*.cpp")
foreach(SOURCE_FILE ${SOURCE_FILES})
get_filename_component(FILENAME ${SOURCE_FILE} NAME_WE)
# compile the source file using mex
add_custom_target("opencv_matlab_${FILENAME}" ALL
COMMAND "/usr/bin/true"
#COMMAND ${MATLAB_MEX_SCRIPT} ${MEX_INCLUDES}
# ${SOURCE_FILE}
add_custom_command(TARGET opencv_matlab PRE_BUILD
COMMAND echo ${MATLAB_MEX_SCRIPT} ${MEX_INCLUDES}
${SOURCE_FILE}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/src
DEPENDS opencv_matlab_sources
)
......
This diff is collapsed.
......@@ -34,7 +34,7 @@ std::vector<Bridge> {{function.name}}({{clss.name}}& inst, const std::vector<Bri
} catch(std::exception& e) {
mexErrMsgTxt(std::string("std::exception caught: ").append(e.what()).c_str());
} catch(...) {
mexErrMsgTxt("Uncaught exception occurred in {{fun.name}}");
mexErrMsgTxt("Uncaught exception occurred in {{function.name}}");
}
......
# 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}
)
......@@ -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!");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment