diff options
author | Sean Warren <s.warren@garvan.org.au> | 2018-09-26 05:15:37 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-09-26 11:53:50 (GMT) |
commit | 6c57f6b347f2acf19ef043e38463ac03919594f3 (patch) | |
tree | 6681b0f37485b0e26b35b5dcd33bc076bb7891b5 /Modules/FindMatlab.cmake | |
parent | fe751ad1fb6b4c54f7662b01777142f2c598c958 (diff) | |
download | CMake-6c57f6b347f2acf19ef043e38463ac03919594f3.zip CMake-6c57f6b347f2acf19ef043e38463ac03919594f3.tar.gz CMake-6c57f6b347f2acf19ef043e38463ac03919594f3.tar.bz2 |
FindMatlab: Optionally allow linking to MatlabEngine and MatlabDataArray
Fixes: #17971
Diffstat (limited to 'Modules/FindMatlab.cmake')
-rw-r--r-- | Modules/FindMatlab.cmake | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake index 12a2f75..4565076 100644 --- a/Modules/FindMatlab.cmake +++ b/Modules/FindMatlab.cmake @@ -21,6 +21,8 @@ # # * ``MX_LIBRARY``, ``ENG_LIBRARY`` and ``MAT_LIBRARY``: respectively the ``MX``, # ``ENG`` and ``MAT`` libraries of Matlab +# * ``ENGINE_LIBRARY``, ``DATAARRAY_LIBRARY``: respectively the ``MatlabEngine`` +# and ``MatlabDataArray`` libraries of Matlab (Matlab 2018a and later) # * ``MAIN_PROGRAM`` the Matlab binary program. Note that this component is not # available on the MCR version, and will yield an error if the MCR is found # instead of the regular Matlab installation. @@ -107,6 +109,12 @@ # ``Matlab_MAT_LIBRARY`` # Matlab matrix library. Available only if the component ``MAT_LIBRARY`` # is requested. +# ``Matlab_ENGINE_LIBRARY`` +# Matlab C++ engine library. Available only if the component ``ENGINE_LIBRARY`` +# is requested. +# ``Matlab_DATAARRAY_LIBRARY`` +# Matlab C++ data array library. Available only if the component ``DATAARRAY_LIBRARY`` +# is requested. # ``Matlab_LIBRARIES`` # the whole set of libraries of Matlab # ``Matlab_MEX_COMPILER`` @@ -960,6 +968,14 @@ function(matlab_add_mex) target_link_libraries(${${prefix}_NAME} ${Matlab_MX_LIBRARY}) endif() + if(DEFINED Matlab_ENGINE_LIBRARY) + target_link_libraries(${${prefix}_NAME} ${Matlab_ENGINE_LIBRARY}) + endif() + + if(DEFINED Matlab_DATAARRAY_LIBRARY) + target_link_libraries(${${prefix}_NAME} ${Matlab_DATAARRAY_LIBRARY}) + endif() + target_link_libraries(${${prefix}_NAME} ${Matlab_MEX_LIBRARY} ${${prefix}_LINK_TO}) set_target_properties(${${prefix}_NAME} PROPERTIES @@ -1416,6 +1432,8 @@ if(DEFINED Matlab_ROOT_DIR_LAST_CACHED) Matlab_MX_LIBRARY Matlab_ENG_LIBRARY Matlab_MAT_LIBRARY + Matlab_ENGINE_LIBRARY + Matlab_DATAARRAY_LIBRARY Matlab_MEX_EXTENSION Matlab_SIMULINK_INCLUDE_DIR @@ -1668,10 +1686,52 @@ if(_matlab_find_mcc_compiler GREATER -1) endif() unset(_matlab_find_mcc_compiler) +# component MatlabEngine +list(FIND Matlab_FIND_COMPONENTS ENGINE_LIBRARY _matlab_find_matlab_engine) +if(_matlab_find_matlab_engine GREATER -1) + _Matlab_find_library( + ${_matlab_lib_prefix_for_search} + Matlab_ENGINE_LIBRARY + MatlabEngine + PATHS ${_matlab_lib_dir_for_search} + DOC "MatlabEngine Library" + NO_DEFAULT_PATH + ) + if(Matlab_ENGINE_LIBRARY) + set(Matlab_ENGINE_LIBRARY_FOUND TRUE) + endif() +endif() +unset(_matlab_find_matlab_engine) + +# component MatlabDataArray +list(FIND Matlab_FIND_COMPONENTS DATAARRAY_LIBRARY _matlab_find_matlab_dataarray) +if(_matlab_find_matlab_dataarray GREATER -1) + _Matlab_find_library( + ${_matlab_lib_prefix_for_search} + Matlab_DATAARRAY_LIBRARY + MatlabDataArray + PATHS ${_matlab_lib_dir_for_search} + DOC "MatlabDataArray Library" + NO_DEFAULT_PATH + ) + if(Matlab_DATAARRAY_LIBRARY) + set(Matlab_DATAARRAY_LIBRARY_FOUND TRUE) + endif() +endif() +unset(_matlab_find_matlab_dataarray) + unset(_matlab_lib_dir_for_search) set(Matlab_LIBRARIES ${Matlab_MEX_LIBRARY} ${Matlab_MX_LIBRARY} ${Matlab_ENG_LIBRARY} ${Matlab_MAT_LIBRARY}) +if(Matlab_DATAARRAY_LIBRARY_FOUND) + set(Matlab_LIBRARIES ${Matlab_LIBRARIES} ${Matlab_DATAARRAY_LIBRARY}) +endif() + +if(Matlab_ENGINE_LIBRARY_FOUND) + set(Matlab_LIBRARIES ${Matlab_LIBRARIES} ${Matlab_ENGINE_LIBRARY}) +endif() + find_package_handle_standard_args( Matlab FOUND_VAR Matlab_FOUND @@ -1692,6 +1752,8 @@ if(Matlab_INCLUDE_DIRS AND Matlab_LIBRARIES) Matlab_MEX_LIBRARY Matlab_MX_LIBRARY Matlab_ENG_LIBRARY + Matlab_ENGINE_LIBRARY + Matlab_DATAARRAY_LIBRARY Matlab_MAT_LIBRARY Matlab_INCLUDE_DIRS Matlab_FOUND |