FindMatlab: simplify mexext find logic

This eliminates an explicit for() loop
This commit is contained in:
scivision
2023-01-12 08:37:34 -05:00
parent df978c5aa8
commit 8dcd14bb87

View File

@@ -636,36 +636,20 @@ endfunction()
#]=======================================================================]
function(matlab_get_mex_suffix matlab_root mex_suffix)
# todo setup the extension properly. Currently I do not know if this is
# sufficient for all win32 distributions.
# there is also CMAKE_EXECUTABLE_SUFFIX that could be tweaked
# find_program does not consider script suffix .bat for Matlab mexext.bat on Windows
set(mexext_suffix "")
if(WIN32)
list(APPEND mexext_suffix ".bat")
set(mexext_suffix ".bat")
endif()
# we first try without suffix, since cmake does not understand a list with
# one empty string element
find_program(
Matlab_MEXEXTENSIONS_PROG
NAMES mexext
NAMES mexext mexext${mexext_suffix}
PATHS ${matlab_root}/bin
DOC "Matlab MEX extension provider"
NO_DEFAULT_PATH
)
foreach(current_mexext_suffix IN LISTS mexext_suffix)
if(NOT DEFINED Matlab_MEXEXTENSIONS_PROG OR NOT Matlab_MEXEXTENSIONS_PROG)
# this call should populate the cache automatically
find_program(
Matlab_MEXEXTENSIONS_PROG
"mexext${current_mexext_suffix}"
PATHS ${matlab_root}/bin
DOC "Matlab MEX extension provider"
NO_DEFAULT_PATH
)
endif()
endforeach(current_mexext_suffix)
if(MATLAB_FIND_DEBUG)
message(STATUS "[MATLAB] Determining mex files extensions from '${matlab_root}/bin' with program '${Matlab_MEXEXTENSIONS_PROG}'")
endif()