summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-09-14 13:42:31 (GMT)
committerKitware Robot <kwrobot@kitware.com>2021-09-14 13:42:50 (GMT)
commit8f67d42671942aebfe345a574c563f59efe931d0 (patch)
tree220f311fab6caabf56f288af5282b52aa56df596 /Modules
parentfdeb9e075188b15ffc136cffe435002a28f422f8 (diff)
parent161990b92135c6b464ce696692f742667832b6e3 (diff)
downloadCMake-8f67d42671942aebfe345a574c563f59efe931d0.zip
CMake-8f67d42671942aebfe345a574c563f59efe931d0.tar.gz
CMake-8f67d42671942aebfe345a574c563f59efe931d0.tar.bz2
Merge topic 'find-matlab-imported-targets'
161990b921 FindMatlab: Add imported targets Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: Ben Boeckel <ben.boeckel@kitware.com> Merge-request: !6488
Diffstat (limited to 'Modules')
-rw-r--r--Modules/FindMatlab.cmake53
1 files changed, 53 insertions, 0 deletions
diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake
index c8df670..12a5fde 100644
--- a/Modules/FindMatlab.cmake
+++ b/Modules/FindMatlab.cmake
@@ -93,6 +93,33 @@ behavior:
additional versions of Matlab for the automatic retrieval of the installed
versions.
+Imported targets
+^^^^^^^^^^^^^^^^
+
+.. versionadded:: 3.22
+
+This module defines the following :prop_tgt:`IMPORTED` targets:
+
+``Matlab::mex``
+ The ``mex`` library, always available.
+
+``Matlab::mx``
+ The mx library of Matlab (arrays), always available.
+
+``Matlab::eng``
+ Matlab engine library. Available only if the ``ENG_LIBRARY`` component
+ is requested.
+
+``Matlab::mat``
+ Matlab matrix library. Available only if the ``MAT_LIBRARY`` component
+ is requested.
+
+``Matlab::MatlabEngine``
+ Matlab C++ engine library, always available for R2018a and newer.
+
+``Matlab::MatlabDataArray``
+ Matlab C++ data array library, always available for R2018a and newer.
+
Variables defined by the module
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -1865,6 +1892,32 @@ if(Matlab_DATAARRAY_LIBRARY)
list(APPEND Matlab_LIBRARIES ${Matlab_DATAARRAY_LIBRARY})
endif()
+# internal
+# This small stub permits to add imported targets for the found MATLAB libraries
+function(_Matlab_add_imported_target _matlab_library_variable_name _matlab_library_target_name)
+ if(Matlab_${_matlab_library_variable_name}_LIBRARY)
+ if(NOT TARGET Matlab::${_matlab_library_target_name})
+ add_library(Matlab::${_matlab_library_target_name} UNKNOWN IMPORTED)
+ set_target_properties(Matlab::${_matlab_library_target_name} PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${Matlab_INCLUDE_DIRS}"
+ IMPORTED_LOCATION "${Matlab_${_matlab_library_variable_name}_LIBRARY}")
+ if(_matlab_library_target_name STREQUAL "mex" OR
+ _matlab_library_target_name STREQUAL "eng" OR
+ _matlab_library_target_name STREQUAL "mat")
+ set_target_properties(Matlab::${_matlab_library_target_name} PROPERTIES
+ INTERFACE_LINK_LIBRARIES Matlab::mx)
+ endif()
+ endif()
+ endif()
+endfunction()
+
+_Matlab_add_imported_target(MX mx)
+_Matlab_add_imported_target(MEX mex)
+_Matlab_add_imported_target(ENG eng)
+_Matlab_add_imported_target(MAT mat)
+_Matlab_add_imported_target(ENGINE MatlabEngine)
+_Matlab_add_imported_target(DATAARRAY MatlabDataArray)
+
find_package_handle_standard_args(
Matlab
FOUND_VAR Matlab_FOUND