Made the search for the installed matlab a little more robust.

This commit is contained in:
Davis King 2016-01-22 12:25:47 -05:00
parent e0995a6740
commit 316099a93f

View File

@ -20,6 +20,14 @@ set(MATLAB_LIB_FOLDERS
"${MATLAB_HOME}/extern/lib/win64/microsoft" "${MATLAB_HOME}/extern/lib/win64/microsoft"
"${MATLAB_HOME}/bin/glnxa64" "${MATLAB_HOME}/bin/glnxa64"
) )
# If there is a MATLAB_HOME environment variable then look there as well.
if (DEFINED ENV{MATLAB_HOME})
set(MATLAB_LIB_FOLDERS
"$ENV{MATLAB_HOME}/extern/lib/win64/microsoft"
"$ENV{MATLAB_HOME}/bin/glnxa64"
${MATLAB_LIB_FOLDERS}
)
endif()
# Find the MATLAB libraries that need to get linked into the mex file # Find the MATLAB libraries that need to get linked into the mex file
if (WIN32) if (WIN32)
find_library(MATLAB_MEX_LIBRARY libmex PATHS ${MATLAB_LIB_FOLDERS} ) find_library(MATLAB_MEX_LIBRARY libmex PATHS ${MATLAB_LIB_FOLDERS} )
@ -31,14 +39,18 @@ else()
find_library(MATLAB_ENG_LIBRARY eng PATHS ${MATLAB_LIB_FOLDERS} ) find_library(MATLAB_ENG_LIBRARY eng PATHS ${MATLAB_LIB_FOLDERS} )
endif() endif()
set(MATLAB_LIBRARIES ${MATLAB_MEX_LIBRARY} ${MATLAB_MX_LIBRARY} ${MATLAB_ENG_LIBRARY}) set(MATLAB_LIBRARIES ${MATLAB_MEX_LIBRARY} ${MATLAB_MX_LIBRARY} ${MATLAB_ENG_LIBRARY})
INCLUDE_DIRECTORIES("${MATLAB_HOME}/extern/include") # Figure out the path to MATLAB's mex.h so we can add it to the include search path.
find_path(mex_header_path mex.h
PATHS "$ENV{MATLAB_HOME}/extern/include"
"${MATLAB_HOME}/extern/include"
)
INCLUDE_DIRECTORIES(${mex_header_path})
# Determine the path to cmake_mex_wrapper file so we can add it to the include search path.. # Determine the path to cmake_mex_wrapper file so we can add it to the include search path..
string(REGEX REPLACE "cmake_mex_wrapper$" "" dlib_matlab_binding_path ${CMAKE_CURRENT_LIST_FILE}) string(REGEX REPLACE "cmake_mex_wrapper$" "" dlib_matlab_binding_path ${CMAKE_CURRENT_LIST_FILE})
INCLUDE_DIRECTORIES("${dlib_matlab_binding_path}") INCLUDE_DIRECTORIES("${dlib_matlab_binding_path}")
# Also add dlib to the include search path
# Determine the path to dlib so we can add it to the include search path. INCLUDE_DIRECTORIES(${dlib_matlab_binding_path}/../..)
string(REGEX REPLACE "cmake_mex_wrapper$" "" dlib_path ${CMAKE_CURRENT_LIST_FILE})
INCLUDE_DIRECTORIES(${dlib_path}/../..)
ADD_DEFINITIONS(-DMATLAB_MEX_FILE) ADD_DEFINITIONS(-DMATLAB_MEX_FILE)