summaryrefslogtreecommitdiffstats
path: root/Modules/FindMatlab.cmake
diff options
context:
space:
mode:
authorRaffi Enficiaud <raffi.enficiaud@mines-paris.org>2019-07-14 23:34:18 (GMT)
committerRaffi Enficiaud <raffi.enficiaud@mines-paris.org>2019-07-14 23:52:07 (GMT)
commitcd6bd8391a4198a1ac9dc3146603d095e8a01d0d (patch)
tree5e7899cb6e1d4c10bb9e0443f4d791cdb1afcff3 /Modules/FindMatlab.cmake
parent9e6206c59bc00be53351cd87ad569896686aeb89 (diff)
downloadCMake-cd6bd8391a4198a1ac9dc3146603d095e8a01d0d.zip
CMake-cd6bd8391a4198a1ac9dc3146603d095e8a01d0d.tar.gz
CMake-cd6bd8391a4198a1ac9dc3146603d095e8a01d0d.tar.bz2
FindMatlab: code comment and ordering of the finders
Diffstat (limited to 'Modules/FindMatlab.cmake')
-rw-r--r--Modules/FindMatlab.cmake142
1 files changed, 69 insertions, 73 deletions
diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake
index 4325623..c8cae2e 100644
--- a/Modules/FindMatlab.cmake
+++ b/Modules/FindMatlab.cmake
@@ -1537,7 +1537,9 @@ if(MATLAB_FIND_DEBUG)
message(STATUS "[MATLAB] Current version is ${Matlab_VERSION_STRING} located ${Matlab_ROOT_DIR}")
endif()
-if(NOT ${Matlab_VERSION_STRING} VERSION_LESS "9.4") # MATLAB 9.4 (R2018a) and newer have a new C++ API
+# MATLAB 9.4 (R2018a) and newer have a new C++ API
+# This API pulls additional required libraries.
+if(NOT ${Matlab_VERSION_STRING} VERSION_LESS "9.4")
set(Matlab_HAS_CPP_API 1)
endif()
@@ -1623,6 +1625,10 @@ endfunction()
set(_matlab_required_variables)
+# Order is as follow:
+# - unconditionally required libraries/headers first
+# - then library components
+# - then program components
# the MEX library/header are required
find_path(
@@ -1648,34 +1654,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
-if("MEX_COMPILER" IN_LIST Matlab_FIND_COMPONENTS)
- find_program(
- Matlab_MEX_COMPILER
- "mex"
- PATHS ${Matlab_BINARIES_DIR}
- DOC "Matlab MEX compiler"
- NO_DEFAULT_PATH
- )
- if(Matlab_MEX_COMPILER)
- set(Matlab_MEX_COMPILER_FOUND TRUE)
- endif()
-endif()
-
-# component Matlab program
-if("MAIN_PROGRAM" IN_LIST Matlab_FIND_COMPONENTS)
- find_program(
- Matlab_MAIN_PROGRAM
- matlab
- PATHS ${Matlab_ROOT_DIR} ${Matlab_ROOT_DIR}/bin
- DOC "Matlab main program"
- NO_DEFAULT_PATH
- )
- if(Matlab_MAIN_PROGRAM)
- set(Matlab_MAIN_PROGRAM_FOUND TRUE)
- endif()
-endif()
-
# The MX library is required
_Matlab_find_library(
${_matlab_lib_prefix_for_search}
@@ -1689,9 +1667,40 @@ if(Matlab_MX_LIBRARY)
set(Matlab_MX_LIBRARY_FOUND TRUE)
endif()
+if(Matlab_HAS_CPP_API)
+
+ # The MatlabEngine library is required for R2018a+
+ _Matlab_find_library(
+ ${_matlab_lib_prefix_for_search}
+ Matlab_ENGINE_LIBRARY
+ MatlabEngine
+ PATHS ${_matlab_lib_dir_for_search}
+ DOC "MatlabEngine Library"
+ NO_DEFAULT_PATH
+ )
+ list(APPEND _matlab_required_variables Matlab_ENGINE_LIBRARY)
+ if(Matlab_ENGINE_LIBRARY)
+ set(Matlab_ENGINE_LIBRARY_FOUND TRUE)
+ endif()
+
+ # The MatlabDataArray library is required for R2018a+
+ _Matlab_find_library(
+ ${_matlab_lib_prefix_for_search}
+ Matlab_DATAARRAY_LIBRARY
+ MatlabDataArray
+ PATHS ${_matlab_lib_dir_for_search}
+ DOC "MatlabDataArray Library"
+ NO_DEFAULT_PATH
+ )
+ list(APPEND _matlab_required_variables Matlab_DATAARRAY_LIBRARY)
+ if(Matlab_DATAARRAY_LIBRARY)
+ set(Matlab_DATAARRAY_LIBRARY_FOUND TRUE)
+ endif()
+
+endif()
+
# Component ENG library
-list(FIND Matlab_FIND_COMPONENTS ENG_LIBRARY _matlab_find_eng)
-if(_matlab_find_eng GREATER -1)
+if("ENG_LIBRARY" IN_LIST Matlab_FIND_COMPONENTS)
_Matlab_find_library(
${_matlab_lib_prefix_for_search}
Matlab_ENG_LIBRARY
@@ -1703,11 +1712,9 @@ if(_matlab_find_eng GREATER -1)
set(Matlab_ENG_LIBRARY_FOUND TRUE)
endif()
endif()
-unset(_matlab_find_eng)
# Component MAT library
-list(FIND Matlab_FIND_COMPONENTS MAT_LIBRARY _matlab_find_mat)
-if(_matlab_find_mat GREATER -1)
+if("MAT_LIBRARY" IN_LIST Matlab_FIND_COMPONENTS)
_Matlab_find_library(
${_matlab_lib_prefix_for_search}
Matlab_MAT_LIBRARY
@@ -1719,11 +1726,9 @@ if(_matlab_find_mat GREATER -1)
set(Matlab_MAT_LIBRARY_FOUND TRUE)
endif()
endif()
-unset(_matlab_find_mat)
# Component Simulink
-list(FIND Matlab_FIND_COMPONENTS SIMULINK _matlab_find_simulink)
-if(_matlab_find_simulink GREATER -1)
+if("SIMULINK" IN_LIST Matlab_FIND_COMPONENTS)
find_path(
Matlab_SIMULINK_INCLUDE_DIR
simstruc.h
@@ -1735,58 +1740,49 @@ if(_matlab_find_simulink GREATER -1)
list(APPEND Matlab_INCLUDE_DIRS "${Matlab_SIMULINK_INCLUDE_DIR}")
endif()
endif()
-unset(_matlab_find_simulink)
-# component MCC Compiler
-list(FIND Matlab_FIND_COMPONENTS MCC_COMPILER _matlab_find_mcc_compiler)
-if(_matlab_find_mcc_compiler GREATER -1)
+# component Matlab program
+if("MAIN_PROGRAM" IN_LIST Matlab_FIND_COMPONENTS)
find_program(
- Matlab_MCC_COMPILER
- "mcc"
- PATHS ${Matlab_BINARIES_DIR}
- DOC "Matlab MCC compiler"
+ Matlab_MAIN_PROGRAM
+ matlab
+ PATHS ${Matlab_ROOT_DIR} ${Matlab_ROOT_DIR}/bin
+ DOC "Matlab main program"
NO_DEFAULT_PATH
)
- if(Matlab_MCC_COMPILER)
- set(Matlab_MCC_COMPILER_FOUND TRUE)
+ if(Matlab_MAIN_PROGRAM)
+ set(Matlab_MAIN_PROGRAM_FOUND TRUE)
endif()
endif()
-unset(_matlab_find_mcc_compiler)
-
-if(Matlab_HAS_CPP_API)
- # The MatlabEngine library is required for R2018a+
- _Matlab_find_library(
- ${_matlab_lib_prefix_for_search}
- Matlab_ENGINE_LIBRARY
- MatlabEngine
- PATHS ${_matlab_lib_dir_for_search}
- DOC "MatlabEngine Library"
+# component Mex Compiler
+if("MEX_COMPILER" IN_LIST Matlab_FIND_COMPONENTS)
+ find_program(
+ Matlab_MEX_COMPILER
+ "mex"
+ PATHS ${Matlab_BINARIES_DIR}
+ DOC "Matlab MEX compiler"
NO_DEFAULT_PATH
)
- list(APPEND _matlab_required_variables Matlab_ENGINE_LIBRARY)
- if(Matlab_ENGINE_LIBRARY)
- set(Matlab_ENGINE_LIBRARY_FOUND TRUE)
+ if(Matlab_MEX_COMPILER)
+ set(Matlab_MEX_COMPILER_FOUND TRUE)
endif()
+endif()
- # The MatlabDataArray library is required for R2018a+
- _Matlab_find_library(
- ${_matlab_lib_prefix_for_search}
- Matlab_DATAARRAY_LIBRARY
- MatlabDataArray
- PATHS ${_matlab_lib_dir_for_search}
- DOC "MatlabDataArray Library"
+# component MCC Compiler
+if("MCC_COMPILER" IN_LIST Matlab_FIND_COMPONENTS)
+ find_program(
+ Matlab_MCC_COMPILER
+ "mcc"
+ PATHS ${Matlab_BINARIES_DIR}
+ DOC "Matlab MCC compiler"
NO_DEFAULT_PATH
)
- list(APPEND _matlab_required_variables Matlab_DATAARRAY_LIBRARY)
- if(Matlab_DATAARRAY_LIBRARY)
- set(Matlab_DATAARRAY_LIBRARY_FOUND TRUE)
+ if(Matlab_MCC_COMPILER)
+ set(Matlab_MCC_COMPILER_FOUND TRUE)
endif()
-
endif()
-unset(_matlab_lib_dir_for_search)
-
set(Matlab_LIBRARIES
${Matlab_MEX_LIBRARY} ${Matlab_MX_LIBRARY}
${Matlab_ENG_LIBRARY} ${Matlab_MAT_LIBRARY}