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 ...@@ -46,6 +46,9 @@ ocv_add_module(matlab BINDINGS opencv_core opencv_imgproc
opencv_highgui opencv_ml opencv_calib3d opencv_photo opencv_highgui opencv_ml opencv_calib3d opencv_photo
opencv_nonfree opencv_calib) 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) if (BUILD_TESTS)
add_subdirectory(test) add_subdirectory(test)
endif() endif()
...@@ -53,9 +56,6 @@ endif() ...@@ -53,9 +56,6 @@ endif()
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# Configure time components # 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") message("-- Trying to generate Matlab code")
execute_process( execute_process(
COMMAND ${PYTHON_EXECUTABLE} COMMAND ${PYTHON_EXECUTABLE}
...@@ -102,7 +102,6 @@ string(REPLACE "opencv_" "" OPENCV_MATLAB_MODULES "${OPENCV_MODULE_${the_module} ...@@ -102,7 +102,6 @@ string(REPLACE "opencv_" "" OPENCV_MATLAB_MODULES "${OPENCV_MODULE_${the_module}
foreach(module ${OPENCV_MATLAB_MODULES}) foreach(module ${OPENCV_MATLAB_MODULES})
if (HAVE_opencv_${module}) if (HAVE_opencv_${module})
list(APPEND opencv_hdrs "${OPENCV_MODULE_opencv_${module}_LOCATION}/include/opencv2/${module}.hpp") list(APPEND opencv_hdrs "${OPENCV_MODULE_opencv_${module}_LOCATION}/include/opencv2/${module}.hpp")
prepend("-I" MEX_INCLUDES "${OPENCV_MODULE_opencv_${module}_LOCATION}/include")
endif() endif()
endforeach() endforeach()
...@@ -113,15 +112,15 @@ add_custom_target(opencv_matlab_sources ALL ...@@ -113,15 +112,15 @@ add_custom_target(opencv_matlab_sources ALL
${opencv_hdrs} ${CMAKE_CURRENT_BINARY_DIR} ${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") file(GLOB SOURCE_FILES "${CMAKE_CURRENT_BINARY_DIR}/src/*.cpp")
foreach(SOURCE_FILE ${SOURCE_FILES}) foreach(SOURCE_FILE ${SOURCE_FILES})
get_filename_component(FILENAME ${SOURCE_FILE} NAME_WE) get_filename_component(FILENAME ${SOURCE_FILE} NAME_WE)
# compile the source file using mex # compile the source file using mex
add_custom_target("opencv_matlab_${FILENAME}" ALL add_custom_command(TARGET opencv_matlab PRE_BUILD
COMMAND "/usr/bin/true" COMMAND echo ${MATLAB_MEX_SCRIPT} ${MEX_INCLUDES}
#COMMAND ${MATLAB_MEX_SCRIPT} ${MEX_INCLUDES} ${SOURCE_FILE}
# ${SOURCE_FILE}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/src WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/src
DEPENDS opencv_matlab_sources DEPENDS opencv_matlab_sources
) )
......
This diff is collapsed.
...@@ -34,7 +34,7 @@ std::vector<Bridge> {{function.name}}({{clss.name}}& inst, const std::vector<Bri ...@@ -34,7 +34,7 @@ std::vector<Bridge> {{function.name}}({{clss.name}}& inst, const std::vector<Bri
} catch(std::exception& e) { } catch(std::exception& e) {
mexErrMsgTxt(std::string("std::exception caught: ").append(e.what()).c_str()); mexErrMsgTxt(std::string("std::exception caught: ").append(e.what()).c_str());
} catch(...) { } 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 # run the matlab test suite
add_test(opencv_matlab_test add_test(opencv_test_matlab
COMMAND ${MATLAB_BIN} "-nodisplay" "-r" "testsuite.m" COMMAND ${MATLAB_BIN} "-nodisplay" "-r" "testsuite.m"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
) )
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Copyright 2013 The OpenCV Foundation * Copyright 2013 The OpenCV Foundation
*/ */
#include <exception> #include <exception>
#include <opencv2/core.hpp> //#include <opencv2/core.hpp>
#include "mex.h" #include "mex.h"
/* /*
...@@ -24,9 +24,9 @@ void mexFunction(int nlhs, mxArray* plhs[], ...@@ -24,9 +24,9 @@ void mexFunction(int nlhs, mxArray* plhs[],
// call the opencv function // call the opencv function
// [out =] namespace.fun(src1, ..., srcn, dst1, ..., dstn, opt1, ..., optn); // [out =] namespace.fun(src1, ..., srcn, dst1, ..., dstn, opt1, ..., optn);
try { try {
throw cv::exception; // throw cv::exception;
} catch(cv::exception& e) { //} catch(cv::exception& e) {
mexErrMsgTxt(e.what()); // mexErrMsgTxt(e.what());
} catch(...) { } catch(...) {
mexErrMsgTxt("Incorrect exception caught!"); 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