From d00f4e267b6c1de56f516bfbe1186f38bdfe5395 Mon Sep 17 00:00:00 2001 From: hbristow Date: Mon, 5 Aug 2013 17:37:48 +1000 Subject: [PATCH] Added Windows dll versioning and Debug library postfix checks. Dependent libraries now being found by linker :) --- modules/matlab/CMakeLists.txt | 8 ++++---- modules/matlab/compile.cmake | 7 ++++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/modules/matlab/CMakeLists.txt b/modules/matlab/CMakeLists.txt index 28a0f56540..f3330c0f69 100644 --- a/modules/matlab/CMakeLists.txt +++ b/modules/matlab/CMakeLists.txt @@ -57,7 +57,6 @@ set(HDR_PARSER_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../python/src2) # set mex compiler options prepend("-I" MEX_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include) prepend("-L" MEX_LIB_DIR ${LIBRARY_OUTPUT_PATH}/$(Configuration)) -prepend("-l" MEX_LIBS opencv_core) set(MEX_OPTS -largeArrayDims) if (BUILD_TESTS) @@ -76,9 +75,8 @@ foreach(opencv_module ${MATLAB_DEPS}) list(APPEND opencv_hdrs "${OPENCV_MODULE_${opencv_module}_LOCATION}/include/opencv2/${module}.hpp") list(APPEND ${the_module}_ACTUAL_DEPS ${opencv_module}) prepend("-I" MEX_INCLUDE_DIRS "${OPENCV_MODULE_${opencv_module}_LOCATION}/include") - if (NOT ${module} STREQUAL "core") - prepend("-l" MEX_LIBS ${opencv_module}) - endif() + prepend("-l" MEX_LIBS ${opencv_module}${OPENCV_DLLVERSION}) + prepend("-l" MEX_DEBUG_LIBS ${opencv_module}${OPENCV_DLLVERSION}${OPENCV_DEBUG_POSTFIX}) endif() endforeach() @@ -174,7 +172,9 @@ add_custom_command( -DMEX_CXXFLAGS=${MEX_CXXFLAGS} -DMEX_INCLUDE_DIRS="${MEX_INCLUDE_DIRS}" -DMEX_LIB_DIR=${MEX_LIB_DIR} + -DCONFIGURATION="$(Configuration)" -DMEX_LIBS="${MEX_LIBS}" + -DMEX_DEBUG_LIBS="${MEX_DEBUG_LIBS}" -P ${CMAKE_CURRENT_SOURCE_DIR}/compile.cmake COMMAND ${CMAKE_COMMAND} -E touch ${COMPILE_PROXY} COMMENT "Compiling Matlab source files. This could take a while..." diff --git a/modules/matlab/compile.cmake b/modules/matlab/compile.cmake index 1d4b311901..fd4ebd483c 100644 --- a/modules/matlab/compile.cmake +++ b/modules/matlab/compile.cmake @@ -3,7 +3,12 @@ macro(listify OUT_LIST IN_STRING) endmacro() listify(MEX_INCLUDE_DIRS_LIST ${MEX_INCLUDE_DIRS}) -listify(MEX_LIBS_LIST ${MEX_LIBS}) +if (${CONFIGURATION} MATCHES "Debug") + listify(MEX_LIBS_LIST ${MEX_DEBUG_LIBS}) +else() + listify(MEX_LIBS_LIST ${MEX_LIBS}) +endif() + file(GLOB SOURCE_FILES "${CMAKE_CURRENT_BINARY_DIR}/src/*.cpp") foreach(SOURCE_FILE ${SOURCE_FILES}) # strip out the filename