summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorSilvio Traversaro <silvio.traversaro@iit.it>2021-08-28 10:12:09 (GMT)
committerBrad King <brad.king@kitware.com>2021-09-13 16:12:05 (GMT)
commit161990b92135c6b464ce696692f742667832b6e3 (patch)
tree66d89458140cc0cf60e5c7e3e4540351cf3614e3 /Tests
parentce6820fe215b8257bff7dc30fe5c57d8210adb09 (diff)
downloadCMake-161990b92135c6b464ce696692f742667832b6e3.zip
CMake-161990b92135c6b464ce696692f742667832b6e3.tar.gz
CMake-161990b92135c6b464ce696692f742667832b6e3.tar.bz2
FindMatlab: Add imported targets
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CMakeLists.txt2
-rw-r--r--Tests/FindMatlab/targets_checks/CMakeLists.txt44
2 files changed, 46 insertions, 0 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 76c6c05..4ccbfeb 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1551,6 +1551,8 @@ if(BUILD_TESTING)
ADD_TEST_MACRO(FindMatlab.failure_reports ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>)
set(FindMatlab.r2018a_check_BUILD_OPTIONS ${FindMatlab_additional_test_options})
ADD_TEST_MACRO(FindMatlab.r2018a_check ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>)
+ set(FindMatlab.targets_checks_BUILD_OPTIONS ${FindMatlab_additional_test_options})
+ ADD_TEST_MACRO(FindMatlab.targets_checks ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>)
endif()
add_test(ExternalProject ${CMAKE_CTEST_COMMAND}
diff --git a/Tests/FindMatlab/targets_checks/CMakeLists.txt b/Tests/FindMatlab/targets_checks/CMakeLists.txt
new file mode 100644
index 0000000..4af7cc3
--- /dev/null
+++ b/Tests/FindMatlab/targets_checks/CMakeLists.txt
@@ -0,0 +1,44 @@
+cmake_minimum_required (VERSION 2.8.12)
+enable_testing()
+project(targets_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 ENG_LIBRARY MAT_LIBRARY
+ OPTIONAL_COMPONENTS MAIN_PROGRAM)
+
+if(NOT TARGET Matlab::mx)
+ message(FATAL_ERROR "Matlab::mx target does not exist")
+endif()
+
+if(NOT TARGET Matlab::mex)
+ message(FATAL_ERROR "Matlab::mex target does not exist")
+endif()
+
+if(NOT TARGET Matlab::eng)
+ message(FATAL_ERROR "Matlab::eng target does not exist")
+endif()
+
+if(NOT TARGET Matlab::mat)
+ message(FATAL_ERROR "Matlab::mat target does not exist")
+endif()
+
+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::mex
+ )