summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Modules/FindMatlab.cmake43
-rw-r--r--Tests/CMakeLists.txt1
-rw-r--r--Tests/FindMatlab/components_checks/CMakeLists.txt23
3 files changed, 47 insertions, 20 deletions
diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake
index 46285aab31..9f96fe693e 100644
--- a/Modules/FindMatlab.cmake
+++ b/Modules/FindMatlab.cmake
@@ -15,8 +15,8 @@
#
# The module supports the following components:
#
-# * ``MX_LIBRARY`` and ``ENG_LIBRARY`` respectively the MX and ENG libraries of
-# Matlab
+# * ``MX_LIBRARY``, ``ENG_LIBRARY`` and ``MAT_LIBRARY``: respectively the MX,
+# ENG and MAT libraries of Matlab
# * ``MAIN_PROGRAM`` the Matlab binary program.
#
# .. note::
@@ -93,6 +93,9 @@
# ``Matlab_ENG_LIBRARY``
# Matlab engine library. Available only if the component ``ENG_LIBRARY``
# is requested.
+# ``Matlab_MAT_LIBRARY``
+# Matlab matrix library. Available only if the component ``MAT_LIBRARY``
+# is requested.
# ``Matlab_LIBRARIES``
# the whole set of libraries of Matlab
# ``Matlab_MEX_COMPILER``
@@ -1213,6 +1216,7 @@ if(DEFINED Matlab_ROOT_DIR_LAST_CACHED)
Matlab_MAIN_PROGRAM
Matlab_MX_LIBRARY
Matlab_ENG_LIBRARY
+ Matlab_MAT_LIBRARY
Matlab_MEX_EXTENSION
# internal
@@ -1346,7 +1350,6 @@ _Matlab_find_library(
NO_DEFAULT_PATH
)
-
list(APPEND _matlab_required_variables Matlab_MEX_LIBRARY)
# the MEX extension is required
@@ -1355,7 +1358,6 @@ list(APPEND _matlab_required_variables Matlab_MEX_EXTENSION)
# the matlab root is required
list(APPEND _matlab_required_variables Matlab_ROOT_DIR)
-
# component Mex Compiler
list(FIND Matlab_FIND_COMPONENTS MEX_COMPILER _matlab_find_mex_compiler)
if(_matlab_find_mex_compiler GREATER -1)
@@ -1366,7 +1368,6 @@ if(_matlab_find_mex_compiler GREATER -1)
DOC "Matlab MEX compiler"
NO_DEFAULT_PATH
)
-
if(Matlab_MEX_COMPILER)
set(Matlab_MEX_COMPILER_FOUND TRUE)
endif()
@@ -1376,7 +1377,6 @@ unset(_matlab_find_mex_compiler)
# component Matlab program
list(FIND Matlab_FIND_COMPONENTS MAIN_PROGRAM _matlab_find_matlab_program)
if(_matlab_find_matlab_program GREATER -1)
-
find_program(
Matlab_MAIN_PROGRAM
matlab
@@ -1384,11 +1384,9 @@ if(_matlab_find_matlab_program GREATER -1)
DOC "Matlab main program"
NO_DEFAULT_PATH
)
-
if(Matlab_MAIN_PROGRAM)
set(Matlab_MAIN_PROGRAM_FOUND TRUE)
endif()
-
endif()
unset(_matlab_find_matlab_program)
@@ -1402,14 +1400,12 @@ if(_matlab_find_mx GREATER -1)
PATHS ${_matlab_lib_dir_for_search}
NO_DEFAULT_PATH
)
-
if(Matlab_MX_LIBRARY)
set(Matlab_MX_LIBRARY_FOUND TRUE)
endif()
endif()
unset(_matlab_find_mx)
-
# Component ENG library
list(FIND Matlab_FIND_COMPONENTS ENG_LIBRARY _matlab_find_eng)
if(_matlab_find_eng GREATER -1)
@@ -1426,15 +1422,26 @@ if(_matlab_find_eng GREATER -1)
endif()
unset(_matlab_find_eng)
-
-
+# Component MAT library
+list(FIND Matlab_FIND_COMPONENTS MAT_LIBRARY _matlab_find_mat)
+if(_matlab_find_mat GREATER -1)
+ _Matlab_find_library(
+ ${_matlab_lib_prefix_for_search}
+ Matlab_MAT_LIBRARY
+ mat
+ PATHS ${_matlab_lib_dir_for_search}
+ NO_DEFAULT_PATH
+ )
+ if(Matlab_MAT_LIBRARY)
+ set(Matlab_MAT_LIBRARY_FOUND TRUE)
+ endif()
+endif()
+unset(_matlab_find_mat)
unset(_matlab_lib_dir_for_search)
-
-set(Matlab_LIBRARIES ${Matlab_MEX_LIBRARY} ${Matlab_MX_LIBRARY} ${Matlab_ENG_LIBRARY})
-
+set(Matlab_LIBRARIES ${Matlab_MEX_LIBRARY} ${Matlab_MX_LIBRARY} ${Matlab_ENG_LIBRARY} ${Matlab_MAT_LIBRARY})
find_package_handle_standard_args(
Matlab
@@ -1453,18 +1460,14 @@ unset(_matlab_lib_prefix_for_search)
if(Matlab_INCLUDE_DIRS AND Matlab_LIBRARIES)
mark_as_advanced(
- #Matlab_LIBRARIES
Matlab_MEX_LIBRARY
Matlab_MX_LIBRARY
Matlab_ENG_LIBRARY
+ Matlab_MAT_LIBRARY
Matlab_INCLUDE_DIRS
Matlab_FOUND
- #Matlab_ROOT_DIR
- #Matlab_VERSION_STRING
Matlab_MAIN_PROGRAM
- #Matlab_MEX_EXTENSION
Matlab_MEXEXTENSIONS_PROG
Matlab_MEX_EXTENSION
- #Matlab_BINARIES_DIR
)
endif()
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index c119cfdcf1..32e53d0ed1 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1413,6 +1413,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
if(CMake_TEST_FindMatlab)
ADD_TEST_MACRO(FindMatlab.basic_checks ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>)
ADD_TEST_MACRO(FindMatlab.versions_checks ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>)
+ ADD_TEST_MACRO(FindMatlab.components_checks ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>)
endif()
find_package(GTK2 QUIET)
diff --git a/Tests/FindMatlab/components_checks/CMakeLists.txt b/Tests/FindMatlab/components_checks/CMakeLists.txt
new file mode 100644
index 0000000000..3dec0931cf
--- /dev/null
+++ b/Tests/FindMatlab/components_checks/CMakeLists.txt
@@ -0,0 +1,23 @@
+
+cmake_minimum_required (VERSION 2.8.12)
+enable_testing()
+project(component_checks)
+
+set(MATLAB_FIND_DEBUG TRUE)
+
+# the success of the following command is dependent on the current configuration:
+# - on 32bits builds (cmake is building with 32 bits), it looks for 32 bits Matlab
+# - on 64bits builds (cmake is building with 64 bits), it looks for 64 bits Matlab
+find_package(Matlab REQUIRED COMPONENTS MX_LIBRARY ENG_LIBRARY MAT_LIBRARY MAIN_PROGRAM)
+
+message(STATUS "FindMatlab libraries: ${Matlab_LIBRARIES}")
+
+matlab_add_mex(
+ # target name
+ NAME cmake_matlab_test_wrapper1
+ # output name
+ OUTPUT_NAME cmake_matlab_mex1
+ SRC ${CMAKE_CURRENT_SOURCE_DIR}/../matlab_wrapper1.cpp
+ DOCUMENTATION ${CMAKE_CURRENT_SOURCE_DIR}/../help_text1.m.txt
+ LINK_TO ${Matlab_LIBRARIES}
+ )