mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-04 05:10:10 -05:00
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
This commit is contained in:
committed by
Brad King
parent
ccd17a557c
commit
59fb9e89b2
@@ -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>
|
||||
)
|
||||
|
||||
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)
|
||||
# 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>
|
||||
)
|
||||
# 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()
|
||||
|
||||
@@ -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}")
|
||||
|
||||
|
||||
@@ -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)
|
||||
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)
|
||||
# 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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user