2013-06-23 08:26:27 +02:00
|
|
|
macro(listify OUT_LIST IN_STRING)
|
|
|
|
string(REPLACE " " ";" ${OUT_LIST} ${IN_STRING})
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
listify(MEX_INCLUDE_DIRS_LIST ${MEX_INCLUDE_DIRS})
|
2013-07-04 08:34:02 +02:00
|
|
|
set(MEX_CXXFLAGS "CXXFLAGS=\$CXXFLAGS -msse -msse2 -msse3 -msse4.1 -msse4.2 -pedantic -Wall -Wextra -Weffc++ -Wno-unused-parameter -Wold-style-cast -Wshadow -Wmissing-declarations -Wmissing-include-dirs -Wnon-virtual-dtor -Wno-newline-eof")
|
2013-06-23 08:26:27 +02:00
|
|
|
file(GLOB SOURCE_FILES "${CMAKE_CURRENT_BINARY_DIR}/src/*.cpp")
|
|
|
|
foreach(SOURCE_FILE ${SOURCE_FILES})
|
2013-06-23 18:44:26 +02:00
|
|
|
# strip out the filename
|
|
|
|
get_filename_component(FILENAME ${SOURCE_FILE} NAME_WE)
|
2013-06-30 01:30:17 +02:00
|
|
|
# compie the source file using mex
|
2013-06-27 09:25:48 +02:00
|
|
|
if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/+cv/${FILENAME}.${MATLAB_MEXEXT})
|
|
|
|
execute_process(
|
2013-06-30 01:30:17 +02:00
|
|
|
COMMAND ${MATLAB_MEX_SCRIPT} "${MEX_CXXFLAGS}" ${MEX_INCLUDE_DIRS_LIST}
|
2013-06-27 09:25:48 +02:00
|
|
|
${MEX_LIB_DIR} ${MEX_LIBS} ${SOURCE_FILE}
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/+cv
|
|
|
|
ERROR_VARIABLE FAILED
|
|
|
|
)
|
|
|
|
endif()
|
2013-06-23 18:44:26 +02:00
|
|
|
# TODO: If a mex file fails to cmpile, should we error out?
|
|
|
|
if (FAILED)
|
|
|
|
message(FATAL_ERROR "Failed to compile ${FILENAME}: ${FAILED}")
|
|
|
|
endif()
|
2013-06-23 08:26:27 +02:00
|
|
|
endforeach()
|