Commit 82b25be8 authored by Brad King's avatar Brad King Committed by Kitware Robot
Browse files

Merge topic 'FindMatlab-MCR'

9c360b9e FindMatlab: Fix search for MCR
bda5e2ac

 FindMatlab: Only include engine and dataarray libraries if they are found
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !5600
parents fedfe763 9c360b9e
Pipeline #204982 failed with stages
in 41 minutes and 5 seconds
...@@ -409,12 +409,12 @@ function(matlab_extract_all_installed_versions_from_registry win64 matlab_versio ...@@ -409,12 +409,12 @@ function(matlab_extract_all_installed_versions_from_registry win64 matlab_versio
set(matlabs_from_registry) set(matlabs_from_registry)
foreach(_installation_type IN ITEMS "MATLAB" "MATLAB Runtime") foreach(_installation_type IN ITEMS "MATLAB" "MATLAB Runtime" "MATLAB Compiler Runtime")
# /reg:64 should be added on 64 bits capable OSs in order to enable the # /reg:64 should be added on 64 bits capable OSs in order to enable the
# redirection of 64 bits applications # redirection of 64 bits applications
execute_process( execute_process(
COMMAND reg query HKEY_LOCAL_MACHINE\\SOFTWARE\\Mathworks\\${_installation_type} /f * /k ${APPEND_REG} COMMAND reg query "HKEY_LOCAL_MACHINE\\SOFTWARE\\Mathworks\\${_installation_type}" /f * /k ${APPEND_REG}
RESULT_VARIABLE resultMatlab RESULT_VARIABLE resultMatlab
OUTPUT_VARIABLE varMatlab OUTPUT_VARIABLE varMatlab
ERROR_VARIABLE errMatlab ERROR_VARIABLE errMatlab
...@@ -425,12 +425,12 @@ function(matlab_extract_all_installed_versions_from_registry win64 matlab_versio ...@@ -425,12 +425,12 @@ function(matlab_extract_all_installed_versions_from_registry win64 matlab_versio
if(resultMatlab EQUAL 0) if(resultMatlab EQUAL 0)
string( string(
REGEX MATCHALL "MATLAB\\\\([0-9]+(\\.[0-9]+)?)" REGEX MATCHALL "${_installation_type}\\\\([0-9]+(\\.[0-9]+)?)"
matlab_versions_regex ${varMatlab}) matlab_versions_regex ${varMatlab})
foreach(match IN LISTS matlab_versions_regex) foreach(match IN LISTS matlab_versions_regex)
string( string(
REGEX MATCH "MATLAB\\\\(([0-9]+)(\\.([0-9]+))?)" REGEX MATCH "${_installation_type}\\\\(([0-9]+)(\\.([0-9]+))?)"
current_match ${match}) current_match ${match})
set(_matlab_current_version ${CMAKE_MATCH_1}) set(_matlab_current_version ${CMAKE_MATCH_1})
...@@ -537,7 +537,7 @@ function(matlab_get_all_valid_matlab_roots_from_registry matlab_versions matlab_ ...@@ -537,7 +537,7 @@ function(matlab_get_all_valid_matlab_roots_from_registry matlab_versions matlab_
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\MathWorks\\MATLAB\\${_matlab_current_version};MATLABROOT]" "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MathWorks\\MATLAB\\${_matlab_current_version};MATLABROOT]"
ABSOLUTE) ABSOLUTE)
if(EXISTS ${current_MATLAB_ROOT}) if(EXISTS "${current_MATLAB_ROOT}")
list(APPEND _matlab_roots_list "MATLAB" ${_matlab_current_version} ${current_MATLAB_ROOT}) list(APPEND _matlab_roots_list "MATLAB" ${_matlab_current_version} ${current_MATLAB_ROOT})
endif() endif()
...@@ -553,7 +553,23 @@ function(matlab_get_all_valid_matlab_roots_from_registry matlab_versions matlab_ ...@@ -553,7 +553,23 @@ function(matlab_get_all_valid_matlab_roots_from_registry matlab_versions matlab_
# remove the dot # remove the dot
string(REPLACE "." "" _matlab_current_version_without_dot "${_matlab_current_version}") string(REPLACE "." "" _matlab_current_version_without_dot "${_matlab_current_version}")
if(EXISTS ${current_MATLAB_ROOT}) if(EXISTS "${current_MATLAB_ROOT}")
list(APPEND _matlab_roots_list "MCR" ${_matlab_current_version} "${current_MATLAB_ROOT}/v${_matlab_current_version_without_dot}")
endif()
endforeach()
# Check for old MCR installations
foreach(_matlab_current_version ${matlab_versions})
get_filename_component(
current_MATLAB_ROOT
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\MathWorks\\MATLAB Compiler Runtime\\${_matlab_current_version};MATLABROOT]"
ABSOLUTE)
# remove the dot
string(REPLACE "." "" _matlab_current_version_without_dot "${_matlab_current_version}")
if(EXISTS "${current_MATLAB_ROOT}")
list(APPEND _matlab_roots_list "MCR" ${_matlab_current_version} "${current_MATLAB_ROOT}/v${_matlab_current_version_without_dot}") list(APPEND _matlab_roots_list "MCR" ${_matlab_current_version} "${current_MATLAB_ROOT}/v${_matlab_current_version_without_dot}")
endif() endif()
...@@ -1067,7 +1083,12 @@ function(matlab_add_mex) ...@@ -1067,7 +1083,12 @@ function(matlab_add_mex)
target_include_directories(${${prefix}_NAME} PRIVATE ${Matlab_INCLUDE_DIRS}) target_include_directories(${${prefix}_NAME} PRIVATE ${Matlab_INCLUDE_DIRS})
if(Matlab_HAS_CPP_API) if(Matlab_HAS_CPP_API)
target_link_libraries(${${prefix}_NAME} ${Matlab_ENGINE_LIBRARY} ${Matlab_DATAARRAY_LIBRARY}) if(Matlab_ENGINE_LIBRARY)
target_link_libraries(${${prefix}_NAME} ${Matlab_ENGINE_LIBRARY})
endif()
if(Matlab_DATAARRAY_LIBRARY)
target_link_libraries(${${prefix}_NAME} ${Matlab_DATAARRAY_LIBRARY})
endif()
endif() endif()
target_link_libraries(${${prefix}_NAME} ${Matlab_MEX_LIBRARY} ${Matlab_MX_LIBRARY} ${${prefix}_LINK_TO}) target_link_libraries(${${prefix}_NAME} ${Matlab_MEX_LIBRARY} ${Matlab_MX_LIBRARY} ${${prefix}_LINK_TO})
...@@ -1687,32 +1708,34 @@ find_path( ...@@ -1687,32 +1708,34 @@ find_path(
) )
list(APPEND _matlab_required_variables Matlab_INCLUDE_DIRS) list(APPEND _matlab_required_variables Matlab_INCLUDE_DIRS)
_Matlab_find_library( if(Matlab_Or_MCR STREQUAL "MATLAB" OR Matlab_Or_MCR STREQUAL "UNKNOWN")
${_matlab_lib_prefix_for_search} _Matlab_find_library(
Matlab_MEX_LIBRARY ${_matlab_lib_prefix_for_search}
mex Matlab_MEX_LIBRARY
PATHS ${_matlab_lib_dir_for_search} mex
NO_DEFAULT_PATH PATHS ${_matlab_lib_dir_for_search}
) NO_DEFAULT_PATH
list(APPEND _matlab_required_variables Matlab_MEX_LIBRARY) )
list(APPEND _matlab_required_variables Matlab_MEX_LIBRARY)
# the MEX extension is required # the MEX extension is required
list(APPEND _matlab_required_variables Matlab_MEX_EXTENSION) list(APPEND _matlab_required_variables Matlab_MEX_EXTENSION)
# the matlab root is required # the matlab root is required
list(APPEND _matlab_required_variables Matlab_ROOT_DIR) list(APPEND _matlab_required_variables Matlab_ROOT_DIR)
# The MX library is required # The MX library is required
_Matlab_find_library( _Matlab_find_library(
${_matlab_lib_prefix_for_search} ${_matlab_lib_prefix_for_search}
Matlab_MX_LIBRARY Matlab_MX_LIBRARY
mx mx
PATHS ${_matlab_lib_dir_for_search} PATHS ${_matlab_lib_dir_for_search}
NO_DEFAULT_PATH NO_DEFAULT_PATH
) )
list(APPEND _matlab_required_variables Matlab_MX_LIBRARY) list(APPEND _matlab_required_variables Matlab_MX_LIBRARY)
if(Matlab_MX_LIBRARY) if(Matlab_MX_LIBRARY)
set(Matlab_MX_LIBRARY_FOUND TRUE) set(Matlab_MX_LIBRARY_FOUND TRUE)
endif()
endif() endif()
if(Matlab_HAS_CPP_API) if(Matlab_HAS_CPP_API)
...@@ -1726,7 +1749,6 @@ if(Matlab_HAS_CPP_API) ...@@ -1726,7 +1749,6 @@ if(Matlab_HAS_CPP_API)
DOC "MatlabEngine Library" DOC "MatlabEngine Library"
NO_DEFAULT_PATH NO_DEFAULT_PATH
) )
list(APPEND _matlab_required_variables Matlab_ENGINE_LIBRARY)
if(Matlab_ENGINE_LIBRARY) if(Matlab_ENGINE_LIBRARY)
set(Matlab_ENGINE_LIBRARY_FOUND TRUE) set(Matlab_ENGINE_LIBRARY_FOUND TRUE)
endif() endif()
...@@ -1740,7 +1762,6 @@ if(Matlab_HAS_CPP_API) ...@@ -1740,7 +1762,6 @@ if(Matlab_HAS_CPP_API)
DOC "MatlabDataArray Library" DOC "MatlabDataArray Library"
NO_DEFAULT_PATH NO_DEFAULT_PATH
) )
list(APPEND _matlab_required_variables Matlab_DATAARRAY_LIBRARY)
if(Matlab_DATAARRAY_LIBRARY) if(Matlab_DATAARRAY_LIBRARY)
set(Matlab_DATAARRAY_LIBRARY_FOUND TRUE) set(Matlab_DATAARRAY_LIBRARY_FOUND TRUE)
endif() endif()
......
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