Files
CMake/Tests/FindMatlab/failure_reports/CMakeLists.txt
T
Brad King f53bd6f450 Tests: Bump CMake minimum required in tests to 3.5
CMake 3.27 deprecates compatibility with CMake < 3.5.  Update tests that
do not cover older interfaces to avoid the deprecation warning.

Follow the pattern from:

* commit 7b07ccdd2b (Tests/*Only: Update cmake_minimum_required versions,
                     2020-06-15, v3.19.0-rc1~629^2~1)

* commit 72e7c45e98 (Tests: Bump CMake minimum required in tests to 2.8.12,
                     2020-12-22, v3.20.0-rc1~224^2)

* commit f6b4db365a (Tests: bump cmake_minimum_required version to 2.8.12,
                     2021-04-04, v3.21.0-rc1~372^2)

Also remove explicit `cmake_policy` settings made redundant by the
version.
2023-03-01 16:36:54 -05:00

56 lines
1.6 KiB
CMake

cmake_minimum_required (VERSION 3.5)
enable_testing()
project(failure_reports)
# gather tests about proper failure reports
set(MATLAB_FIND_DEBUG TRUE)
if(IS_MCR)
set(RUN_UNIT_TESTS FALSE)
else()
set(RUN_UNIT_TESTS TRUE)
set(components 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(
# 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
)
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()