Added commenting to modules/matlab/CMakeLists.txt

This commit is contained in:
hbristow 2013-06-22 23:52:05 -07:00
parent 755ce9d654
commit 24d5adfd54

View File

@ -77,6 +77,14 @@ foreach(module ${OPENCV_MATLAB_MODULES})
endif() endif()
endforeach() endforeach()
# Configure checks
# Check to see whether the generator and the mex compiler are working.
# The checks currently test:
# - whether the python generator can be found
# - whether the python generator correctly outputs a file for a definition
# - whether the mex compiler can find the required headers
# - whether the mex compiler can compile a trivial definition
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("-- Trying to generate Matlab code")
execute_process( execute_process(
@ -113,16 +121,24 @@ if (MEX_ERROR)
else() else()
message("-- Trying to compile mex file - OK") message("-- Trying to compile mex file - OK")
endif() endif()
endif()
# if we make it here, mex works! # if we make it here, mex works!
set_property(GLOBAL PROPERTY MEX_WORKS TRUE) set_property(GLOBAL PROPERTY MEX_WORKS TRUE)
set(MEX_WORKS True CACHE BOOL ADVANCED)
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# Build time components # Build time components
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# proxies
# these proxies are used to trigger the add_custom_commands
# (which do the real work) only when they're outdated
set(GENERATE_PROXY ${CMAKE_CURRENT_BINARY_DIR}/generate.proxy) set(GENERATE_PROXY ${CMAKE_CURRENT_BINARY_DIR}/generate.proxy)
set(COMPILE_PROXY ${CMAKE_CURRENT_BINARY_DIR}/compile.proxy) set(COMPILE_PROXY ${CMAKE_CURRENT_BINARY_DIR}/compile.proxy)
# generate
# call the python executable to generate the Matlab gateways
add_custom_command( add_custom_command(
OUTPUT ${GENERATE_PROXY} OUTPUT ${GENERATE_PROXY}
COMMAND ${PYTHON_EXECUTABLE} COMMAND ${PYTHON_EXECUTABLE}
@ -132,6 +148,10 @@ add_custom_command(
COMMENT "Generating matlab source files" COMMENT "Generating matlab source files"
) )
# compile
# call the mex compiler to compile the gateways
# because we don't know the source files at configure-time, this
# has to be executed in a separate script in cmake's script processing mode
add_custom_command( add_custom_command(
OUTPUT ${COMPILE_PROXY} OUTPUT ${COMPILE_PROXY}
COMMAND ${CMAKE_COMMAND} -DMATLAB_MEX_SCRIPT=${MATLAB_MEX_SCRIPT} COMMAND ${CMAKE_COMMAND} -DMATLAB_MEX_SCRIPT=${MATLAB_MEX_SCRIPT}
@ -144,6 +164,8 @@ add_custom_command(
COMMENT "Compiling Matlab source files. This could take a while..." COMMENT "Compiling Matlab source files. This could take a while..."
) )
# targets
# 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)