summaryrefslogtreecommitdiff
path: root/Tests/FindMatlab
diff options
context:
space:
mode:
authorRaffi Enficiaud <raffi.enficiaud@mines-paris.org>2017-04-29 20:31:58 +0200
committerBrad King <brad.king@kitware.com>2018-04-23 10:30:49 -0400
commit59fb9e89b2bd09a2edd5bbaecb01f43d6f3a2a7e (patch)
tree05897534fca0be23f67df31938a4c237a51f4c98 /Tests/FindMatlab
parentccd17a557cbf8ada18207a72eea78d2adcc9d752 (diff)
downloadcmake-59fb9e89b2bd09a2edd5bbaecb01f43d6f3a2a7e.tar.gz
FindMatlab: Matlab Runtime Compiler support
* Determining automatically the MCR version on OSX and Windows * Distinguishing between MCR and Matlab * Specific tests for the MCR * mexext on windows does not work properly: the mexext is hardcoded * Doc updates for the MCR Fixes: #16487
Diffstat (limited to 'Tests/FindMatlab')
-rw-r--r--Tests/FindMatlab/basic_checks/CMakeLists.txt86
-rw-r--r--Tests/FindMatlab/components_checks/CMakeLists.txt10
-rw-r--r--Tests/FindMatlab/failure_reports/CMakeLists.txt55
-rw-r--r--Tests/FindMatlab/versions_checks/CMakeLists.txt7
4 files changed, 103 insertions, 55 deletions
diff --git a/Tests/FindMatlab/basic_checks/CMakeLists.txt b/Tests/FindMatlab/basic_checks/CMakeLists.txt
index 951fcf2082..4a74d93f18 100644
--- a/Tests/FindMatlab/basic_checks/CMakeLists.txt
+++ b/Tests/FindMatlab/basic_checks/CMakeLists.txt
@@ -8,8 +8,23 @@ 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 MAIN_PROGRAM)
+if(IS_MCR)
+ set(components MX_LIBRARY)
+ set(RUN_UNIT_TESTS FALSE)
+else()
+ set(RUN_UNIT_TESTS TRUE)
+ set(components MX_LIBRARY MAIN_PROGRAM)
+endif()
+
+if(NOT "${MCR_ROOT}" STREQUAL "")
+ set(Matlab_ROOT_DIR "${MCR_ROOT}")
+ if(NOT EXISTS "${MCR_ROOT}")
+ message(FATAL_ERROR "MCR does not exist ${MCR_ROOT}")
+ endif()
+endif()
+
+find_package(Matlab REQUIRED COMPONENTS ${components})
matlab_add_mex(
@@ -21,38 +36,39 @@ matlab_add_mex(
DOCUMENTATION ${CMAKE_CURRENT_SOURCE_DIR}/../help_text1.m.txt
)
+if(RUN_UNIT_TESTS)
+ matlab_add_unit_test(
+ NAME ${PROJECT_NAME}_matlabtest-1
+ TIMEOUT 300
+ UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../cmake_matlab_unit_tests1.m
+ ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1>
+ )
+
+ # timeout tests, TIMEOUT set to very short on purpose
+ matlab_add_unit_test(
+ NAME ${PROJECT_NAME}_matlabtest-2
+ TIMEOUT 15
+ UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../cmake_matlab_unit_tests_timeout.m
+ ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1>
+ )
+ set_tests_properties(${PROJECT_NAME}_matlabtest-2 PROPERTIES WILL_FAIL TRUE)
+
+
+ # testing the test without the unittest framework of Matlab
+ matlab_add_unit_test(
+ NAME ${PROJECT_NAME}_matlabtest-3
+ TIMEOUT 300
+ NO_UNITTEST_FRAMEWORK
+ UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../cmake_matlab_unit_tests2.m
+ ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1>
+ )
-matlab_add_unit_test(
- NAME ${PROJECT_NAME}_matlabtest-1
- TIMEOUT 300
- UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../cmake_matlab_unit_tests1.m
- ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1>
- )
-
-# timeout tests, TIMEOUT set to very short on purpose
-matlab_add_unit_test(
- NAME ${PROJECT_NAME}_matlabtest-2
- TIMEOUT 15
- UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../cmake_matlab_unit_tests_timeout.m
- ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1>
- )
-set_tests_properties(${PROJECT_NAME}_matlabtest-2 PROPERTIES WILL_FAIL TRUE)
-
-
-# testing the test without the unittest framework of Matlab
-matlab_add_unit_test(
- NAME ${PROJECT_NAME}_matlabtest-3
- TIMEOUT 300
- NO_UNITTEST_FRAMEWORK
- UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../cmake_matlab_unit_tests2.m
- ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1>
- )
-
-matlab_add_unit_test(
- NAME ${PROJECT_NAME}_matlabtest-4
- TIMEOUT 300
- NO_UNITTEST_FRAMEWORK
- UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../cmake_matlab_unit_tests3.m
- ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1>
- )
-set_tests_properties(${PROJECT_NAME}_matlabtest-4 PROPERTIES WILL_FAIL TRUE)
+ matlab_add_unit_test(
+ NAME ${PROJECT_NAME}_matlabtest-4
+ TIMEOUT 300
+ NO_UNITTEST_FRAMEWORK
+ UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../cmake_matlab_unit_tests3.m
+ ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1>
+ )
+ set_tests_properties(${PROJECT_NAME}_matlabtest-4 PROPERTIES WILL_FAIL TRUE)
+endif()
diff --git a/Tests/FindMatlab/components_checks/CMakeLists.txt b/Tests/FindMatlab/components_checks/CMakeLists.txt
index 3dec0931cf..da6a2b00e2 100644
--- a/Tests/FindMatlab/components_checks/CMakeLists.txt
+++ b/Tests/FindMatlab/components_checks/CMakeLists.txt
@@ -5,10 +5,18 @@ project(component_checks)
set(MATLAB_FIND_DEBUG TRUE)
+if(NOT "${MCR_ROOT}" STREQUAL "")
+ set(Matlab_ROOT_DIR "${MCR_ROOT}")
+ if(NOT EXISTS "${MCR_ROOT}")
+ message(FATAL_ERROR "MCR does not exist ${MCR_ROOT}")
+ endif()
+endif()
+
# 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)
+find_package(Matlab REQUIRED COMPONENTS MX_LIBRARY ENG_LIBRARY MAT_LIBRARY
+ OPTIONAL_COMPONENTS MAIN_PROGRAM)
message(STATUS "FindMatlab libraries: ${Matlab_LIBRARIES}")
diff --git a/Tests/FindMatlab/failure_reports/CMakeLists.txt b/Tests/FindMatlab/failure_reports/CMakeLists.txt
index 1cf961323c..e597a4a054 100644
--- a/Tests/FindMatlab/failure_reports/CMakeLists.txt
+++ b/Tests/FindMatlab/failure_reports/CMakeLists.txt
@@ -7,7 +7,22 @@ project(failure_reports)
set(MATLAB_FIND_DEBUG TRUE)
-find_package(Matlab REQUIRED COMPONENTS MX_LIBRARY MAIN_PROGRAM)
+if(IS_MCR)
+ set(components MX_LIBRARY)
+ set(RUN_UNIT_TESTS FALSE)
+else()
+ set(RUN_UNIT_TESTS TRUE)
+ set(components MX_LIBRARY MAIN_PROGRAM)
+endif()
+
+if(NOT "${MCR_ROOT}" STREQUAL "")
+ set(Matlab_ROOT_DIR "${MCR_ROOT}")
+ if(NOT EXISTS "${MCR_ROOT}")
+ message(FATAL_ERROR "MCR does not exist ${MCR_ROOT}")
+ endif()
+endif()
+
+find_package(Matlab REQUIRED COMPONENTS ${components})
# main extensions for testing, same as other tests
matlab_add_mex(
@@ -19,21 +34,23 @@ matlab_add_mex(
DOCUMENTATION ${CMAKE_CURRENT_SOURCE_DIR}/../help_text1.m.txt
)
-# the unit test file does not exist: the failure should be properly reported
-matlab_add_unit_test(
- NAME ${PROJECT_NAME}_matlabtest-1
- TIMEOUT 300
- UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../nonexistantfile.m
- ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1>
- )
-set_tests_properties(${PROJECT_NAME}_matlabtest-1 PROPERTIES WILL_FAIL TRUE)
-
-# without the unit test framework
-matlab_add_unit_test(
- NAME ${PROJECT_NAME}_matlabtest-2
- TIMEOUT 300
- NO_UNITTEST_FRAMEWORK
- UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../nonexistantfile2.m
- ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1>
- )
-set_tests_properties(${PROJECT_NAME}_matlabtest-2 PROPERTIES WILL_FAIL TRUE)
+if(RUN_UNIT_TESTS)
+ # the unit test file does not exist: the failure should be properly reported
+ matlab_add_unit_test(
+ NAME ${PROJECT_NAME}_matlabtest-1
+ TIMEOUT 300
+ UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../nonexistantfile.m
+ ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1>
+ )
+ set_tests_properties(${PROJECT_NAME}_matlabtest-1 PROPERTIES WILL_FAIL TRUE)
+
+ # without the unit test framework
+ matlab_add_unit_test(
+ NAME ${PROJECT_NAME}_matlabtest-2
+ TIMEOUT 300
+ NO_UNITTEST_FRAMEWORK
+ UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../nonexistantfile2.m
+ ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1>
+ )
+ set_tests_properties(${PROJECT_NAME}_matlabtest-2 PROPERTIES WILL_FAIL TRUE)
+endif()
diff --git a/Tests/FindMatlab/versions_checks/CMakeLists.txt b/Tests/FindMatlab/versions_checks/CMakeLists.txt
index 5d20685c25..d015730b0b 100644
--- a/Tests/FindMatlab/versions_checks/CMakeLists.txt
+++ b/Tests/FindMatlab/versions_checks/CMakeLists.txt
@@ -7,6 +7,13 @@ set(MATLAB_FIND_DEBUG TRUE)
set(MATLAB_ADDITIONAL_VERSIONS
"dummy=14.9")
+if(NOT "${MCR_ROOT}" STREQUAL "")
+ set(Matlab_ROOT_DIR "${MCR_ROOT}")
+ if(NOT EXISTS "${MCR_ROOT}")
+ message(FATAL_ERROR "MCR does not exist ${MCR_ROOT}")
+ endif()
+endif()
+
# the success of the following command is dependent on the current configuration
# in this case, we are only interested in the version macros
find_package(Matlab)