CMakeLists.txt 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. cmake_minimum_required (VERSION 3.5)
  2. enable_testing()
  3. project(targets_checks)
  4. set(MATLAB_FIND_DEBUG TRUE)
  5. if(NOT "${MCR_ROOT}" STREQUAL "")
  6. set(Matlab_ROOT_DIR "${MCR_ROOT}")
  7. if(NOT EXISTS "${MCR_ROOT}")
  8. message(FATAL_ERROR "MCR does not exist ${MCR_ROOT}")
  9. endif()
  10. endif()
  11. # the success of the following command is dependent on the current configuration:
  12. # - on 32bits builds (cmake is building with 32 bits), it looks for 32 bits Matlab
  13. # - on 64bits builds (cmake is building with 64 bits), it looks for 64 bits Matlab
  14. find_package(Matlab REQUIRED COMPONENTS ENG_LIBRARY MAT_LIBRARY
  15. OPTIONAL_COMPONENTS MAIN_PROGRAM)
  16. if(NOT TARGET Matlab::mx)
  17. message(FATAL_ERROR "Matlab::mx target does not exist")
  18. endif()
  19. if(NOT TARGET Matlab::mex)
  20. message(FATAL_ERROR "Matlab::mex target does not exist")
  21. endif()
  22. if(NOT TARGET Matlab::eng)
  23. message(FATAL_ERROR "Matlab::eng target does not exist")
  24. endif()
  25. if(NOT TARGET Matlab::mat)
  26. message(FATAL_ERROR "Matlab::mat target does not exist")
  27. endif()
  28. matlab_add_mex(
  29. # target name
  30. NAME cmake_matlab_test_wrapper1
  31. # output name
  32. OUTPUT_NAME cmake_matlab_mex1
  33. SRC ${CMAKE_CURRENT_SOURCE_DIR}/../matlab_wrapper1.cpp
  34. DOCUMENTATION ${CMAKE_CURRENT_SOURCE_DIR}/../help_text1.m.txt
  35. LINK_TO Matlab::mex
  36. )