Improved dependency checking

pull/1384/head
hbristow 12 years ago
parent 24d5adfd54
commit 3b77fa5e8c
  1. 29
      modules/matlab/CMakeLists.txt
  2. 7
      modules/matlab/compile.cmake

@ -67,13 +67,14 @@ endif()
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# Configure time components # Configure time components
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
string(REPLACE "opencv_" "" OPENCV_MATLAB_MODULES "${OPENCV_MODULE_${the_module}_REQ_DEPS}; set(MATLAB_DEPS ${OPENCV_MODULE_${the_module}_REQ_DEPS} ${OPENCV_MODULE_${the_module}_OPT_DEPS})
${OPENCV_MODULE_${the_module}_OPT_DEPS}") foreach(opencv_module ${MATLAB_DEPS})
foreach(module ${OPENCV_MATLAB_MODULES}) if (HAVE_${opencv_module})
if (HAVE_opencv_${module}) string(REPLACE "opencv_" "" module ${opencv_module})
list(APPEND opencv_hdrs "${OPENCV_MODULE_opencv_${module}_LOCATION}/include/opencv2/${module}.hpp") list(APPEND opencv_hdrs "${OPENCV_MODULE_${opencv_module}_LOCATION}/include/opencv2/${module}.hpp")
prepend("-I" MEX_INCLUDE_DIRS "${OPENCV_MODULE_opencv_${module}_LOCATION}/include") list(APPEND ${the_module}_ACTUAL_DEPS ${opencv_module})
prepend("-l" MEX_LIBS "opencv_${module}") prepend("-I" MEX_INCLUDE_DIRS "${OPENCV_MODULE_${opencv_module}_LOCATION}/include")
prepend("-l" MEX_LIBS ${opencv_module})
endif() endif()
endforeach() endforeach()
@ -86,7 +87,7 @@ endforeach()
# - whether the mex compiler can compile a trivial definition # - whether the mex compiler can compile a trivial definition
if (NOT MEX_WORKS) if (NOT MEX_WORKS)
# attempt to generate a gateway for a function # attempt to generate a gateway for a function
message("-- Trying to generate Matlab code") message(STATUS "Trying to generate Matlab code")
execute_process( execute_process(
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_SOURCE_DIR}/test/trigger.cpp COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_SOURCE_DIR}/test/trigger.cpp
COMMAND ${PYTHON_EXECUTABLE} COMMAND ${PYTHON_EXECUTABLE}
@ -98,14 +99,14 @@ if (NOT MEX_WORKS)
if (GEN_ERROR) if (GEN_ERROR)
message(${GEN_ERROR}) message(${GEN_ERROR})
message("-- Error generating Matlab code. Disabling Matlab bindings...") message(STATUS "Error generating Matlab code. Disabling Matlab bindings...")
return() return()
else() else()
message("-- Trying to generate Matlab code - OK") message(STATUS "Trying to generate Matlab code - OK")
endif() endif()
# attempt to compile a gateway using mex # attempt to compile a gateway using mex
message("-- Trying to compile mex file") message(STATUS "Trying to compile mex file")
execute_process( execute_process(
COMMAND ${MATLAB_MEX_SCRIPT} ${MEX_OPTS} ${MEX_INCLUDE_DIRS} COMMAND ${MATLAB_MEX_SCRIPT} ${MEX_OPTS} ${MEX_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/test/test_compiler.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test/test_compiler.cpp
@ -116,10 +117,10 @@ if (NOT MEX_WORKS)
if (MEX_ERROR) if (MEX_ERROR)
message(${MEX_ERROR}) message(${MEX_ERROR})
message("-- Error compiling mex file. Disabling Matlab bindings...") message(STATUS "Error compiling mex file. Disabling Matlab bindings...")
return() return()
else() else()
message("-- Trying to compile mex file - OK") message(STATUS "Trying to compile mex file - OK")
endif() endif()
endif() endif()
@ -168,7 +169,7 @@ add_custom_command(
# opencv_matlab_sources --> opencv_matlab_compile # opencv_matlab_sources --> opencv_matlab_compile
add_custom_target(${the_module}_sources ALL DEPENDS ${GENERATE_PROXY}) add_custom_target(${the_module}_sources ALL DEPENDS ${GENERATE_PROXY})
add_custom_target(${the_module} ALL DEPENDS ${COMPILE_PROXY}) add_custom_target(${the_module} ALL DEPENDS ${COMPILE_PROXY})
add_dependencies(${the_module} ${the_module}_sources) add_dependencies(${the_module} ${the_module}_sources ${${the_module}_ACTUAL_DEPS})
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# Install time components # Install time components

@ -5,10 +5,17 @@ endmacro()
listify(MEX_INCLUDE_DIRS_LIST ${MEX_INCLUDE_DIRS}) listify(MEX_INCLUDE_DIRS_LIST ${MEX_INCLUDE_DIRS})
file(GLOB SOURCE_FILES "${CMAKE_CURRENT_BINARY_DIR}/src/*.cpp") file(GLOB SOURCE_FILES "${CMAKE_CURRENT_BINARY_DIR}/src/*.cpp")
foreach(SOURCE_FILE ${SOURCE_FILES}) foreach(SOURCE_FILE ${SOURCE_FILES})
# strip out the filename
get_filename_component(FILENAME ${SOURCE_FILE} NAME_WE)
# compile the source file using mex # compile the source file using mex
execute_process( execute_process(
COMMAND ${MATLAB_MEX_SCRIPT} ${MEX_OPTS} ${MEX_INCLUDE_DIRS_LIST} COMMAND ${MATLAB_MEX_SCRIPT} ${MEX_OPTS} ${MEX_INCLUDE_DIRS_LIST}
${MEX_LIB_DIR} ${MEX_LIBS} ${SOURCE_FILE} ${MEX_LIB_DIR} ${MEX_LIBS} ${SOURCE_FILE}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/src WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/src
ERROR_VARIABLE FAILED
) )
# TODO: If a mex file fails to cmpile, should we error out?
if (FAILED)
message(FATAL_ERROR "Failed to compile ${FILENAME}: ${FAILED}")
endif()
endforeach() endforeach()

Loading…
Cancel
Save