diff --git a/src/matlab/CMakeLists.txt b/src/matlab/CMakeLists.txt old mode 100644 new mode 100755 index ebacaea..da544e5 --- a/src/matlab/CMakeLists.txt +++ b/src/matlab/CMakeLists.txt @@ -63,19 +63,6 @@ if(MEX_CMD AND MEXEXT_CMD) set(BUILD_MATLAB_BINDINGS OFF) endif() elseif(OCT_CMD) - SET(MEX_FILE ${CMAKE_CURRENT_BINARY_DIR}/${MEX_NAME}.oct) - ADD_CUSTOM_COMMAND( - OUTPUT ${MEX_FILE} - COMMAND ${OCT_CMD} - ARGS ${CMAKE_CURRENT_SOURCE_DIR}/${MEX_NAME}.cpp -I${PROJECT_SOURCE_DIR}/src/cpp -L${PROJECT_BINARY_DIR}/lib -DFLANN_STATIC -lflann_s -lgomp - DEPENDS flann_s ${CMAKE_CURRENT_SOURCE_DIR}/${MEX_NAME}.cpp - COMMENT "Building MEX extension ${MEX_FILE}" - ) - - ADD_CUSTOM_TARGET(mex_${MEX_NAME} ALL DEPENDS ${MEX_FILE}) - - FILE(GLOB MATLAB_SOURCES *.m) - find_program(OCTAVE_CONFIG_EXECUTABLE NAMES octave-config) if (OCTAVE_CONFIG_EXECUTABLE) @@ -87,8 +74,25 @@ elseif(OCT_CMD) OUTPUT_VARIABLE OCTAVE_OCT_SITE_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process (COMMAND ${OCTAVE_CONFIG_EXECUTABLE} -p OCTLIBDIR + OUTPUT_VARIABLE OCTAVE_OCT_LIB_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE) + endif() + SET(MEX_FILE ${CMAKE_CURRENT_BINARY_DIR}/${MEX_NAME}.oct) + ADD_CUSTOM_COMMAND( + OUTPUT ${MEX_FILE} + COMMAND ${OCT_CMD} + ARGS ${CMAKE_CURRENT_SOURCE_DIR}/${MEX_NAME}.cpp -I${PROJECT_SOURCE_DIR}/src/cpp -L${PROJECT_BINARY_DIR}/lib -DFLANN_STATIC -lflann_s -lgomp -L${OCTAVE_OCT_LIB_DIR} + DEPENDS flann_s ${CMAKE_CURRENT_SOURCE_DIR}/${MEX_NAME}.cpp + COMMENT "Building MEX extension ${MEX_FILE}" + ) + + ADD_CUSTOM_TARGET(mex_${MEX_NAME} ALL DEPENDS ${MEX_FILE}) + + FILE(GLOB MATLAB_SOURCES *.m) + INSTALL (FILES ${MEX_FILE} DESTINATION ${OCTAVE_OCT_SITE_DIR}) INSTALL (FILES ${MATLAB_SOURCES} DESTINATION ${OCTAVE_M_SITE_DIR}) else()