diff options
author | Brad King <brad.king@kitware.com> | 2023-01-13 13:57:35 +0000 |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2023-01-13 08:57:43 -0500 |
commit | be4dcdf10098e5877e5a2c1ec20da7621b3e5390 (patch) | |
tree | cb7a2e2cd04b198dc11edd387ccea436418cbdaf | |
parent | 5dddc49e035cbc449f47ed9c7526a56873a9d0a8 (diff) | |
parent | 1bc9b0f256dc65d43a994ac2307775151f194c72 (diff) | |
download | cmake-be4dcdf10098e5877e5a2c1ec20da7621b3e5390.tar.gz |
Merge topic 'FindMatlab-macos-rosetta'
1bc9b0f256 FindMatlab: accommodate Matlab running under Rosetta
8dcd14bb87 FindMatlab: simplify mexext find logic
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !8063
-rw-r--r-- | Modules/FindMatlab.cmake | 49 |
1 files changed, 17 insertions, 32 deletions
diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake index fe8f198242..0f1e45180d 100644 --- a/Modules/FindMatlab.cmake +++ b/Modules/FindMatlab.cmake @@ -636,42 +636,26 @@ 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() # the program has been found? - if((NOT Matlab_MEXEXTENSIONS_PROG) OR (NOT EXISTS ${Matlab_MEXEXTENSIONS_PROG})) + if(NOT Matlab_MEXEXTENSIONS_PROG) if(MATLAB_FIND_DEBUG) message(WARNING "[MATLAB] Cannot found mexext program. Matlab root is ${matlab_root}") endif() @@ -722,7 +706,6 @@ function(matlab_get_mex_suffix matlab_root mex_suffix) message(STATUS "[MATLAB] '${Matlab_MEXEXTENSIONS_PROG}' : determined extension '${_matlab_mex_extension}' and error string is '${_matlab_mex_extension_error}'") endif() - unset(Matlab_MEXEXTENSIONS_PROG CACHE) set(${mex_suffix} ${_matlab_mex_extension} PARENT_SCOPE) endfunction() @@ -1763,12 +1746,24 @@ else() set(_matlab_64Build TRUE) endif() + +if(NOT DEFINED Matlab_MEX_EXTENSION) + set(_matlab_mex_extension "") + matlab_get_mex_suffix("${Matlab_ROOT_DIR}" _matlab_mex_extension) + + # This variable goes to the cache. + set(Matlab_MEX_EXTENSION ${_matlab_mex_extension} CACHE STRING "Extensions for the mex targets (automatically given by Matlab)") + unset(_matlab_mex_extension) +endif() + if(APPLE) set(_matlab_bin_prefix "mac") # i should be for intel set(_matlab_bin_suffix_32bits "i") - if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64") + if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64" AND Matlab_MEX_EXTENSION MATCHES "a64$") + # native Apple Silicon Matlab set(_matlab_bin_suffix_64bits "a64") else() + # Intel Mac OR Apple Silicon using Rosetta for Matlab set(_matlab_bin_suffix_64bits "i64") endif() elseif(UNIX) @@ -1812,16 +1807,6 @@ endif() unset(_matlab_64Build) -if(NOT DEFINED Matlab_MEX_EXTENSION) - set(_matlab_mex_extension "") - matlab_get_mex_suffix("${Matlab_ROOT_DIR}" _matlab_mex_extension) - - # This variable goes to the cache. - set(Matlab_MEX_EXTENSION ${_matlab_mex_extension} CACHE STRING "Extensions for the mex targets (automatically given by Matlab)") - unset(_matlab_mex_extension) -endif() - - if(MATLAB_FIND_DEBUG) message(STATUS "[MATLAB] [DEBUG]_matlab_lib_prefix_for_search = ${_matlab_lib_prefix_for_search} | _matlab_lib_dir_for_search = ${_matlab_lib_dir_for_search}") endif() |