diff --git a/dlib/matlab/cmake_mex_wrapper b/dlib/matlab/cmake_mex_wrapper index 67729ff70..5091e4e5b 100644 --- a/dlib/matlab/cmake_mex_wrapper +++ b/dlib/matlab/cmake_mex_wrapper @@ -70,7 +70,14 @@ INCLUDE(InstallRequiredSystemLibraries) MACRO(add_mex_function name ) - ADD_LIBRARY(${name} MODULE ${name}.cpp ) + if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${name}.C") + ADD_LIBRARY(${name} MODULE ${name}.C) + elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${name}.c") + ADD_LIBRARY(${name} MODULE ${name}.c) + else() + ADD_LIBRARY(${name} MODULE ${name}.cpp ) + endif() + target_compile_definitions(${name} PRIVATE -DMEX_FILENAME=${name}) if (UNIX) # Doing this prevents our mex function from exporting any symbols