2013-06-23 14:26:27 +08:00
|
|
|
macro(listify OUT_LIST IN_STRING)
|
|
|
|
string(REPLACE " " ";" ${OUT_LIST} ${IN_STRING})
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
listify(MEX_INCLUDE_DIRS_LIST ${MEX_INCLUDE_DIRS})
|
2013-08-05 15:37:48 +08:00
|
|
|
if (${CONFIGURATION} MATCHES "Debug")
|
|
|
|
listify(MEX_LIBS_LIST ${MEX_DEBUG_LIBS})
|
|
|
|
else()
|
|
|
|
listify(MEX_LIBS_LIST ${MEX_LIBS})
|
|
|
|
endif()
|
|
|
|
|
2013-06-23 14:26:27 +08:00
|
|
|
file(GLOB SOURCE_FILES "${CMAKE_CURRENT_BINARY_DIR}/src/*.cpp")
|
|
|
|
foreach(SOURCE_FILE ${SOURCE_FILES})
|
2013-06-24 00:44:26 +08:00
|
|
|
# strip out the filename
|
|
|
|
get_filename_component(FILENAME ${SOURCE_FILE} NAME_WE)
|
2013-06-30 07:30:17 +08:00
|
|
|
# compie the source file using mex
|
2013-06-27 15:25:48 +08:00
|
|
|
if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/+cv/${FILENAME}.${MATLAB_MEXEXT})
|
|
|
|
execute_process(
|
2013-08-04 22:44:38 +08:00
|
|
|
COMMAND ${MATLAB_MEX_SCRIPT} ${MEX_OPTS} "CXXFLAGS=\$CXXFLAGS ${MEX_CXXFLAGS}" ${MEX_INCLUDE_DIRS_LIST}
|
2013-08-05 12:49:12 +08:00
|
|
|
${MEX_LIB_DIR} ${MEX_LIBS_LIST} ${SOURCE_FILE}
|
2013-06-27 15:25:48 +08:00
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/+cv
|
2013-08-04 22:44:38 +08:00
|
|
|
OUTPUT_QUIET
|
2013-06-27 15:25:48 +08:00
|
|
|
ERROR_VARIABLE FAILED
|
|
|
|
)
|
|
|
|
endif()
|
2013-08-04 22:44:38 +08:00
|
|
|
# TODO: If a mex file fails to compile, should we error out?
|
2013-06-24 00:44:26 +08:00
|
|
|
if (FAILED)
|
|
|
|
message(FATAL_ERROR "Failed to compile ${FILENAME}: ${FAILED}")
|
|
|
|
endif()
|
2013-06-23 14:26:27 +08:00
|
|
|
endforeach()
|