Commit 032e5e3f authored by Davis King's avatar Davis King

merged

parents dd603855 64c7e966
...@@ -49,44 +49,46 @@ if (UNIX) ...@@ -49,44 +49,46 @@ if (UNIX)
include(CheckLibraryExists) include(CheckLibraryExists)
# Don't try to use the Intel MKL when we are building a MATLAB mex file # Search for the needed libraries from the MKL. We will try to link against the mkl_rt
# since it will usually conflict with MATLAB's copy of the MKL and cause # file first since this way avoids linking bugs in some cases.
# problems. find_library(mkl_rt mkl_rt ${mkl_search_path})
if (NOT BUILDING_MATLAB_MEX_FILE) mark_as_advanced( mkl_rt )
# Search for the needed libraries from the MKL. We will try to link against the mkl_rt # if we found the MKL
# file first since this way avoids linking bugs in some cases. if ( mkl_rt)
find_library(mkl_rt mkl_rt ${mkl_search_path}) set(blas_libraries ${mkl_rt} )
mark_as_advanced( mkl_rt ) set(lapack_libraries ${mkl_rt} )
# if we found the MKL set(blas_found 1)
if ( mkl_rt) set(lapack_found 1)
set(blas_libraries ${mkl_rt} ) set(found_intel_mkl 1)
set(lapack_libraries ${mkl_rt} ) message(STATUS "Found Intel MKL BLAS/LAPACK library")
if (BUILDING_MATLAB_MEX_FILE)
message(STATUS "\n!!!! Don't forget to set the BLAS_VERSION and LAPACK_VERSION environment variables to !!!!\n!!!! ${blas_libraries} so MATLAB doesn't explode when you run this mex file !!!!\n")
endif()
endif()
if (BUILDING_MATLAB_MEX_FILE)
return()
endif()
if (NOT found_intel_mkl)
# Search for the needed libraries from the MKL. This time try looking for a different
# set of MKL files and try to link against those.
find_library(mkl_core mkl_core ${mkl_search_path})
find_library(mkl_thread mkl_intel_thread ${mkl_search_path})
find_library(mkl_iomp iomp5 ${mkl_search_path})
find_library(mkl_pthread pthread ${mkl_search_path})
mark_as_advanced( mkl_intel mkl_core mkl_thread mkl_iomp mkl_pthread)
# If we found the MKL
if (mkl_intel AND mkl_core AND mkl_thread AND mkl_iomp AND mkl_pthread)
set(blas_libraries ${mkl_intel} ${mkl_core} ${mkl_thread} ${mkl_iomp} ${mkl_pthread})
set(lapack_libraries ${mkl_intel} ${mkl_core} ${mkl_thread} ${mkl_iomp} ${mkl_pthread})
set(blas_found 1) set(blas_found 1)
set(lapack_found 1) set(lapack_found 1)
set(found_intel_mkl 1) set(found_intel_mkl 1)
message(STATUS "Found Intel MKL BLAS/LAPACK library") message(STATUS "Found Intel MKL BLAS/LAPACK library")
endif() endif()
endif()
if (NOT found_intel_mkl)
# Search for the needed libraries from the MKL. This time try looking for a different
# set of MKL files and try to link against those.
find_library(mkl_core mkl_core ${mkl_search_path})
find_library(mkl_thread mkl_intel_thread ${mkl_search_path})
find_library(mkl_iomp iomp5 ${mkl_search_path})
find_library(mkl_pthread pthread ${mkl_search_path})
mark_as_advanced( mkl_intel mkl_core mkl_thread mkl_iomp mkl_pthread)
# If we found the MKL
if (mkl_intel AND mkl_core AND mkl_thread AND mkl_iomp AND mkl_pthread)
set(blas_libraries ${mkl_intel} ${mkl_core} ${mkl_thread} ${mkl_iomp} ${mkl_pthread})
set(lapack_libraries ${mkl_intel} ${mkl_core} ${mkl_thread} ${mkl_iomp} ${mkl_pthread})
set(blas_found 1)
set(lapack_found 1)
set(found_intel_mkl 1)
message(STATUS "Found Intel MKL BLAS/LAPACK library")
endif()
endif()
endif()
# try to find some other LAPACK libraries if we didn't find the MKL # try to find some other LAPACK libraries if we didn't find the MKL
......
...@@ -8,6 +8,14 @@ ...@@ -8,6 +8,14 @@
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
void check_for_ctrl_c();
/*!
ensures
- If the user of MATLAB has pressed ctrl+c then this function will throw an
exception.
!*/
// ----------------------------------------------------------------------------------------
class matlab_struct class matlab_struct
{ {
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
cmake_minimum_required(VERSION 2.8.4) cmake_minimum_required(VERSION 2.8.4)
set(BUILDING_MATLAB_MEX_FILE true) set(BUILDING_MATLAB_MEX_FILE true)
set(CMAKE_POSITION_INDEPENDENT_CODE True)
# Find MATLAB's include directory and needed libraries # Find MATLAB's include directory and needed libraries
find_program(MATLAB_EXECUTABLE matlab PATHS find_program(MATLAB_EXECUTABLE matlab PATHS
...@@ -67,6 +68,7 @@ INCLUDE(InstallRequiredSystemLibraries) ...@@ -67,6 +68,7 @@ INCLUDE(InstallRequiredSystemLibraries)
MACRO(add_mex_function name ) MACRO(add_mex_function name )
ADD_LIBRARY(${name} MODULE ${name}.cpp ) ADD_LIBRARY(${name} MODULE ${name}.cpp )
# Change the output file extension to a mex extension. # Change the output file extension to a mex extension.
if (WIN32) if (WIN32)
set_target_properties(${name} PROPERTIES SUFFIX ".mexw64") set_target_properties(${name} PROPERTIES SUFFIX ".mexw64")
......
...@@ -253,6 +253,8 @@ namespace mex_binding ...@@ -253,6 +253,8 @@ namespace mex_binding
// ------------------------------------------------------- // -------------------------------------------------------
struct user_hit_ctrl_c {};
struct invalid_args_exception struct invalid_args_exception
{ {
invalid_args_exception(const std::string& msg_): msg(msg_) {} invalid_args_exception(const std::string& msg_): msg(msg_) {}
...@@ -897,7 +899,7 @@ namespace mex_binding ...@@ -897,7 +899,7 @@ namespace mex_binding
} }
else if (is_same_type<dlib::rgb_pixel, type>::value) else if (is_same_type<dlib::rgb_pixel, type>::value)
{ {
mwSize dims[3] = {(unsigned long)item.nr(), (unsigned long)item.nc(), 3}; mwSize dims[3] = {(mwSize)item.nr(), (mwSize)item.nc(), 3};
plhs = mxCreateNumericArray(3, dims, mxUINT8_CLASS, mxREAL); plhs = mxCreateNumericArray(3, dims, mxUINT8_CLASS, mxREAL);
assign_image_to_matlab((dlib::uint8*)mxGetData(plhs), item); assign_image_to_matlab((dlib::uint8*)mxGetData(plhs), item);
...@@ -1573,6 +1575,10 @@ namespace mex_binding ...@@ -1573,6 +1575,10 @@ namespace mex_binding
mexErrMsgIdAndTxt("mex_function:validate_and_populate_arg", mexErrMsgIdAndTxt("mex_function:validate_and_populate_arg",
("Input" + e.msg).c_str()); ("Input" + e.msg).c_str());
} }
catch (user_hit_ctrl_c& )
{
// do nothing, just return to matlab
}
catch (dlib::error& e) catch (dlib::error& e)
{ {
mexErrMsgIdAndTxt("mex_function:error", mexErrMsgIdAndTxt("mex_function:error",
...@@ -2371,6 +2377,14 @@ void call_matlab ( ...@@ -2371,6 +2377,14 @@ void call_matlab (
call_matlab("feval", funct); call_matlab("feval", funct);
} }
extern "C" bool utIsInterruptPending();
void check_for_ctrl_c(
)
{
if (utIsInterruptPending())
throw mex_binding::user_hit_ctrl_c();
}
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
......
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