From 33e71127f782197bebb7246377508ef4fbe7ec0d Mon Sep 17 00:00:00 2001 From: Alexander Shishkov Date: Mon, 30 May 2011 13:32:57 +0000 Subject: [PATCH] fixed problem with VideoInput on Windows when OpenCV compiled statically (ticket #573) --- CMakeLists.txt | 17 +++++++++++++++++ modules/python/CMakeLists.txt | 4 ++++ samples/c/CMakeLists.txt | 4 +++- samples/cpp/CMakeLists.txt | 3 +++ samples/gpu/CMakeLists.txt | 3 +++ 5 files changed, 30 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 05fe10bf3..b7af6fdc1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -139,6 +139,12 @@ else() set(OPENCV_SVNVERSION "") endif() +# ---------------------------------------------------------------------------- +# Detect Microsoft compiler: +# ---------------------------------------------------------------------------- +if(CMAKE_CL_64) + set(MSVC64 1) +endif() # ---------------------------------------------------------------------------- # Detect GNU version: @@ -805,6 +811,17 @@ if(WIN32) if (MSVC) set(HIGHGUI_LIBRARIES ${HIGHGUI_LIBRARIES} vfw32) + if (NOT BUILD_SHARED_LIBS) + if (MSVC64) + if(HAVE_VIDEOINPUT) + set(HIGHGUI_LIBRARIES ${HIGHGUI_LIBRARIES} ${CMAKE_SOURCE_DIR}/3rdparty/lib/videoInput64.lib strmiids) + endif() + elseif (MSVC) + if(HAVE_VIDEOINPUT) + set(HIGHGUI_LIBRARIES ${HIGHGUI_LIBRARIES} ${CMAKE_SOURCE_DIR}/3rdparty/lib/videoInput.lib strmiids) + endif() + endif() + endif() endif() if(MINGW) diff --git a/modules/python/CMakeLists.txt b/modules/python/CMakeLists.txt index 751a28530..bd4cdac32 100644 --- a/modules/python/CMakeLists.txt +++ b/modules/python/CMakeLists.txt @@ -60,6 +60,10 @@ execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import distutils.sysconfig; pri set_target_properties(${cv_target} PROPERTIES SUFFIX ${CVPY_SUFFIX}) +if (MSVC AND NOT BUILD_SHARED_LIBS) + set_target_properties(${cv_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG") +endif() + set(cvpymodules ${cv_target}) if(PYTHON_USE_NUMPY) diff --git a/samples/c/CMakeLists.txt b/samples/c/CMakeLists.txt index ce07827a8..713624686 100644 --- a/samples/c/CMakeLists.txt +++ b/samples/c/CMakeLists.txt @@ -43,8 +43,10 @@ if (BUILD_EXAMPLES) if(ENABLE_SOLUTION_FOLDERS) set_target_properties(${the_target} PROPERTIES FOLDER "samples//c") endif() - if(WIN32) + if (MSVC AND NOT BUILD_SHARED_LIBS) + set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG") + endif() install(TARGETS ${the_target} RUNTIME DESTINATION "samples/c" COMPONENT main) endif() diff --git a/samples/cpp/CMakeLists.txt b/samples/cpp/CMakeLists.txt index 85e825848..3fde7b7fd 100644 --- a/samples/cpp/CMakeLists.txt +++ b/samples/cpp/CMakeLists.txt @@ -45,6 +45,9 @@ if (BUILD_EXAMPLES) endif() if(WIN32) + if (MSVC AND NOT BUILD_SHARED_LIBS) + set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG") + endif() install(TARGETS ${the_target} RUNTIME DESTINATION "samples/cpp" COMPONENT main) endif() diff --git a/samples/gpu/CMakeLists.txt b/samples/gpu/CMakeLists.txt index d3ac2c479..f84ae9935 100644 --- a/samples/gpu/CMakeLists.txt +++ b/samples/gpu/CMakeLists.txt @@ -47,6 +47,9 @@ if (BUILD_EXAMPLES) endif() if(WIN32) + if (MSVC AND NOT BUILD_SHARED_LIBS) + set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG") + endif() install(TARGETS ${the_target} RUNTIME DESTINATION "samples/gpu" COMPONENT main) endif()