Fixed Android build
authorAndrey Kamaev <no@email>
Fri, 8 Jun 2012 08:11:17 +0000 (08:11 +0000)
committerAndrey Kamaev <no@email>
Fri, 8 Jun 2012 08:11:17 +0000 (08:11 +0000)
22 files changed:
3rdparty/libjpeg/CMakeLists.txt
3rdparty/libpng/CMakeLists.txt
3rdparty/libtiff/CMakeLists.txt
cmake/OpenCVCompilerOptions.cmake
cmake/OpenCVGenHeaders.cmake
cmake/OpenCVUtils.cmake
modules/highgui/src/window.cpp
modules/highgui/test/test_gui.cpp
modules/java/CMakeLists.txt
modules/java/src/cpp/jni_part.cpp
modules/stitching/perf/perf_stich.cpp
modules/stitching/src/stitcher.cpp
modules/stitching/test/test_matchers.cpp
modules/videostab/include/opencv2/videostab/global_motion.hpp
modules/videostab/include/opencv2/videostab/optical_flow.hpp
modules/videostab/include/opencv2/videostab/wobble_suppression.hpp
modules/videostab/src/global_motion.cpp
modules/videostab/src/inpainting.cpp
modules/videostab/src/optical_flow.cpp
modules/videostab/src/wobble_suppression.cpp
samples/android/CMakeLists.txt
samples/cpp/videostab.cpp

index 3438544..79d8991 100644 (file)
@@ -25,6 +25,8 @@ if(CMAKE_COMPILER_IS_GNUCXX)
   set_source_files_properties(jcdctmgr.c PROPERTIES COMPILE_FLAGS "-O1")
 endif()
 
+ocv_warnings_disable(CMAKE_C_FLAGS -Wcast-align)
+
 set_target_properties(${JPEG_LIBRARY}
   PROPERTIES OUTPUT_NAME ${JPEG_LIBRARY}
   DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
index 449971b..bfbf501 100644 (file)
@@ -21,6 +21,8 @@ if(UNIX)
   endif()
 endif()
 
+ocv_warnings_disable(CMAKE_C_FLAGS -Wcast-align)
+
 set_target_properties(${PNG_LIBRARY}
   PROPERTIES OUTPUT_NAME ${PNG_LIBRARY}
   DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
index dc55a6a..c3fda69 100644 (file)
@@ -90,7 +90,7 @@ if(WIN32)
   list(APPEND lib_srcs tif_win32.c)
 endif(WIN32)
 
-ocv_warnings_disable(CMAKE_C_FLAGS -Wno-unused-but-set-variable -Wmissing-prototypes -Wmissing-declarations -Wundef)
+ocv_warnings_disable(CMAKE_C_FLAGS -Wno-unused-but-set-variable -Wmissing-prototypes -Wmissing-declarations -Wundef -Wcast-align)
 ocv_warnings_disable(CMAKE_CXX_FLAGS -Wmissing-declarations)
 
 if(UNIX AND (CMAKE_COMPILER_IS_GNUCXX OR CV_ICC))
index 3a45b6d..905ef6c 100644 (file)
@@ -21,76 +21,102 @@ if(MSVC)
   endif()
 endif()
 
+set(OPENCV_EXTRA_FLAGS "")
 set(OPENCV_EXTRA_C_FLAGS "")
-set(OPENCV_EXTRA_C_FLAGS_RELEASE "")
-set(OPENCV_EXTRA_C_FLAGS_DEBUG "")
+set(OPENCV_EXTRA_CXX_FLAGS "")
+set(OPENCV_EXTRA_FLAGS_RELEASE "")
+set(OPENCV_EXTRA_FLAGS_DEBUG "")
 set(OPENCV_EXTRA_EXE_LINKER_FLAGS "")
 set(OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEASE "")
 set(OPENCV_EXTRA_EXE_LINKER_FLAGS_DEBUG "")
 
+macro(add_extra_compiler_option option)
+  ocv_check_flag_support(CXX "${option}" _varname ${ARGN})
+  if(${_varname})
+    set(OPENCV_EXTRA_CXX_FLAGS "${OPENCV_EXTRA_CXX_FLAGS} ${option}")
+  endif()
+
+  ocv_check_flag_support(C "${option}" _varname ${ARGN})
+  if(${_varname})
+    set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} ${option}")
+  endif()
+endmacro()
+
 if(MINGW)
   # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40838
   # here we are trying to workaround the problem
   include(CheckCXXCompilerFlag)
   CHECK_CXX_COMPILER_FLAG(-mstackrealign HAVE_STACKREALIGN_FLAG)
   if(HAVE_STACKREALIGN_FLAG)
-    set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} -mstackrealign")
+    set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} -mstackrealign")
   else()
     CHECK_CXX_COMPILER_FLAG(-mpreferred-stack-boundary=2 HAVE_PREFERRED_STACKBOUNDARY_FLAG)
     if(HAVE_PREFERRED_STACKBOUNDARY_FLAG)
-      set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} -mstackrealign")
+      set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} -mstackrealign")
     endif()
   endif()
 endif()
 
 if(CMAKE_COMPILER_IS_GNUCXX)
   # High level of warnings.
-  set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} -Wall")
-
-  set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Werror=format-security")
-  set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} -Wmissing-declarations -Wcast-align -Wundef -Winit-self -Wpointer-arith") #-Wstrict-aliasing=2
+  add_extra_compiler_option(-Wall)
+  add_extra_compiler_option(-Werror=return-type)
+  add_extra_compiler_option(-Werror=non-virtual-dtor)
+  add_extra_compiler_option(-Werror=address)
+  add_extra_compiler_option(-Werror=sequence-point)
+  add_extra_compiler_option(-Wformat)
+  add_extra_compiler_option(-Werror=format-security -Wformat)
+  add_extra_compiler_option(-Wmissing-declarations)
+  add_extra_compiler_option(-Wmissing-prototypes)
+  add_extra_compiler_option(-Wstrict-prototypes)
+  add_extra_compiler_option(-Wundef)
+  add_extra_compiler_option(-Winit-self)
+  add_extra_compiler_option(-Wpointer-arith)
+  #add_extra_compiler_option(-Wcast-align)
+  #add_extra_compiler_option(-Wstrict-aliasing=2)
+  #add_extra_compiler_option(-Wshadow)
 
   # The -Wno-long-long is required in 64bit systems when including sytem headers.
   if(X86_64)
-    set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} -Wno-long-long")
+    add_extra_compiler_option(-Wno-long-long)
   endif()
 
   # We need pthread's
   if(UNIX AND NOT ANDROID)
-    set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} -pthread")
+    add_extra_compiler_option(-pthread)
   endif()
 
   if(OPENCV_WARNINGS_ARE_ERRORS)
-    set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} -Werror")
+    add_extra_compiler_option(-Werror)
   endif()
 
   if(X86 AND NOT MINGW64 AND NOT X86_64 AND NOT APPLE)
-    set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} -march=i686")
+    add_extra_compiler_option(-march=i686)
   endif()
 
   # Other optimizations
   if(ENABLE_OMIT_FRAME_POINTER)
-    set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} -fomit-frame-pointer")
+    add_extra_compiler_option(-fomit-frame-pointer)
   else()
-    set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} -fno-omit-frame-pointer")
+    add_extra_compiler_option(-fno-omit-frame-pointer)
   endif()
   if(ENABLE_FAST_MATH)
-    set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} -ffast-math")
+    add_extra_compiler_option(-ffast-math)
   endif()
   if(ENABLE_POWERPC)
-    set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} -mcpu=G3 -mtune=G5")
+    add_extra_compiler_option("-mcpu=G3 -mtune=G5")
   endif()
   if(ENABLE_SSE)
-    set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} -msse")
+    add_extra_compiler_option(-msse)
   endif()
   if(ENABLE_SSE2)
-    set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} -msse2")
+    add_extra_compiler_option(-msse2)
   endif()
 
   # SSE3 and further should be disabled under MingW because it generates compiler errors
   if(NOT MINGW)
     if(ENABLE_SSE3)
-      set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} -msse3")
+      add_extra_compiler_option(-msse3)
     endif()
 
     if(${CMAKE_OPENCV_GCC_VERSION_NUM} GREATER 402)
@@ -102,14 +128,14 @@ if(CMAKE_COMPILER_IS_GNUCXX)
 
     if(HAVE_GCC42_OR_NEWER OR APPLE)
       if(ENABLE_SSSE3)
-        set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} -mssse3")
+        add_extra_compiler_option(-mssse3)
       endif()
       if(HAVE_GCC43_OR_NEWER)
         if(ENABLE_SSE41)
-           set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} -msse4.1")
+           add_extra_compiler_option(-msse4.1)
         endif()
         if(ENABLE_SSE42)
-           set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} -msse4.2")
+           add_extra_compiler_option(-msse4.2)
         endif()
       endif()
     endif()
@@ -117,39 +143,40 @@ if(CMAKE_COMPILER_IS_GNUCXX)
 
   if(X86 OR X86_64)
     if(NOT APPLE AND CMAKE_SIZEOF_VOID_P EQUAL 4)
-       if(ENABLE_SSE2)
-         set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} -mfpmath=sse")# !! important - be on the same wave with x64 compilers
-       else()
-         set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} -mfpmath=387")
-       endif()
+      if(ENABLE_SSE2)
+        add_extra_compiler_option(-mfpmath=sse)# !! important - be on the same wave with x64 compilers
+      else()
+        add_extra_compiler_option(-mfpmath=387)
+      endif()
     endif()
   endif()
 
   # Profiling?
   if(ENABLE_PROFILING)
-    set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} -pg -g")
+    add_extra_compiler_option("-pg -g")
     # turn off incompatible options
-    foreach(flags CMAKE_CXX_FLAGS CMAKE_C_FLAGS CMAKE_CXX_FLAGS_RELEASE CMAKE_C_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG CMAKE_C_FLAGS_DEBUG OPENCV_EXTRA_C_FLAGS_RELEASE)
+    foreach(flags CMAKE_CXX_FLAGS CMAKE_C_FLAGS CMAKE_CXX_FLAGS_RELEASE CMAKE_C_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG CMAKE_C_FLAGS_DEBUG
+                  OPENCV_EXTRA_FLAGS_RELEASE OPENCV_EXTRA_FLAGS_DEBUG OPENCV_EXTRA_C_FLAGS OPENCV_EXTRA_CXX_FLAGS)
       string(REPLACE "-fomit-frame-pointer" "" ${flags} "${${flags}}")
       string(REPLACE "-ffunction-sections" "" ${flags} "${${flags}}")
     endforeach()
   elseif(NOT APPLE AND NOT ANDROID)
     # Remove unreferenced functions: function level linking
-    set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} -ffunction-sections")
+    add_extra_compiler_option(-ffunction-sections)
   endif()
 
-  set(OPENCV_EXTRA_C_FLAGS_RELEASE "${OPENCV_EXTRA_C_FLAGS_RELEASE} -DNDEBUG")
-  set(OPENCV_EXTRA_C_FLAGS_DEBUG "${OPENCV_EXTRA_C_FLAGS_DEBUG} -O0 -DDEBUG -D_DEBUG")
+  set(OPENCV_EXTRA_FLAGS_RELEASE "${OPENCV_EXTRA_FLAGS_RELEASE} -DNDEBUG")
+  set(OPENCV_EXTRA_FLAGS_DEBUG "${OPENCV_EXTRA_FLAGS_DEBUG} -O0 -DDEBUG -D_DEBUG")
   if(BUILD_WITH_DEBUG_INFO)
-    set(OPENCV_EXTRA_C_FLAGS_DEBUG "${OPENCV_EXTRA_C_FLAGS_DEBUG} -ggdb3")
+    set(OPENCV_EXTRA_FLAGS_DEBUG "${OPENCV_EXTRA_FLAGS_DEBUG} -ggdb3")
   endif()
 endif()
 
 if(MSVC)
-  set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS")
+  set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS")
   # 64-bit portability warnings, in MSVC80
   if(MSVC80)
-    set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} /Wp64")
+    set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /Wp64")
   endif()
 
   if(BUILD_WITH_DEBUG_INFO)
@@ -157,38 +184,38 @@ if(MSVC)
   endif()
 
   # Remove unreferenced functions: function level linking
-  set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} /Gy")
+  set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /Gy")
   if(NOT MSVC_VERSION LESS 1400)
-    set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} /bigobj")
+    set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /bigobj")
   endif()
   if(BUILD_WITH_DEBUG_INFO)
-    set(OPENCV_EXTRA_C_FLAGS_RELEASE "${OPENCV_EXTRA_C_FLAGS_RELEASE} /Zi")
+    set(OPENCV_EXTRA_FLAGS_RELEASE "${OPENCV_EXTRA_FLAGS_RELEASE} /Zi")
   endif()
 
   if(NOT MSVC64)
     # 64-bit MSVC compiler uses SSE/SSE2 by default
     if(ENABLE_SSE)
-      set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} /arch:SSE")
+      set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:SSE")
     endif()
     if(ENABLE_SSE2)
-      set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} /arch:SSE2")
+      set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:SSE2")
     endif()
   endif()
 
   if(ENABLE_SSE3)
-    set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} /arch:SSE3")
+    set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:SSE3")
   endif()
   if(ENABLE_SSE4_1)
-    set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} /arch:SSE4.1")
+    set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:SSE4.1")
   endif()
 
   if(ENABLE_SSE OR ENABLE_SSE2 OR ENABLE_SSE3 OR ENABLE_SSE4_1)
-    set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} /Oi")
+    set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /Oi")
   endif()
 
   if(X86 OR X86_64)
     if(CMAKE_SIZEOF_VOID_P EQUAL 4 AND ENABLE_SSE2)
-      set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} /fp:fast")# !! important - be on the same wave with x64 compilers
+      set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /fp:fast")# !! important - be on the same wave with x64 compilers
     endif()
   endif()
 endif()
@@ -197,33 +224,31 @@ endif()
 if(NOT BUILD_SHARED_LIBS AND CMAKE_COMPILER_IS_GNUCXX AND NOT ANDROID)
   # Android does not need these settings because they are already set by toolchain file
   set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} stdc++)
-  set(OPENCV_EXTRA_C_FLAGS "-fPIC ${OPENCV_EXTRA_C_FLAGS}")
+  set(OPENCV_EXTRA_FLAGS "-fPIC ${OPENCV_EXTRA_FLAGS}")
 endif()
 
 # Add user supplied extra options (optimization, etc...)
 # ==========================================================
-set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS}" CACHE INTERNAL "Extra compiler options")
-set(OPENCV_EXTRA_C_FLAGS_RELEASE "${OPENCV_EXTRA_C_FLAGS_RELEASE}" CACHE INTERNAL "Extra compiler options for Release build")
-set(OPENCV_EXTRA_C_FLAGS_DEBUG "${OPENCV_EXTRA_C_FLAGS_DEBUG}" CACHE INTERNAL "Extra compiler options for Debug build")
+set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS}" CACHE INTERNAL "Extra compiler options")
+set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS}" CACHE INTERNAL "Extra compiler options for C sources")
+set(OPENCV_EXTRA_CXX_FLAGS "${OPENCV_EXTRA_CXX_FLAGS}" CACHE INTERNAL "Extra compiler options for C++ sources")
+set(OPENCV_EXTRA_FLAGS_RELEASE "${OPENCV_EXTRA_FLAGS_RELEASE}" CACHE INTERNAL "Extra compiler options for Release build")
+set(OPENCV_EXTRA_FLAGS_DEBUG "${OPENCV_EXTRA_FLAGS_DEBUG}" CACHE INTERNAL "Extra compiler options for Debug build")
 set(OPENCV_EXTRA_EXE_LINKER_FLAGS "${OPENCV_EXTRA_EXE_LINKER_FLAGS}" CACHE INTERNAL "Extra linker flags")
 set(OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEASE "${OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEASE}" CACHE INTERNAL "Extra linker flags for Release build")
 set(OPENCV_EXTRA_EXE_LINKER_FLAGS_DEBUG "${OPENCV_EXTRA_EXE_LINKER_FLAGS_DEBUG}" CACHE INTERNAL "Extra linker flags for Debug build")
 
 #combine all "extra" options
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OPENCV_EXTRA_C_FLAGS}")
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPENCV_EXTRA_C_FLAGS}")
-set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}  ${OPENCV_EXTRA_C_FLAGS_RELEASE}")
-set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${OPENCV_EXTRA_C_FLAGS_RELEASE}")
-set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${OPENCV_EXTRA_C_FLAGS_DEBUG}")
-set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${OPENCV_EXTRA_C_FLAGS_DEBUG}")
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OPENCV_EXTRA_FLAGS} ${OPENCV_EXTRA_C_FLAGS}")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPENCV_EXTRA_FLAGS} ${OPENCV_EXTRA_CXX_FLAGS}")
+set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${OPENCV_EXTRA_FLAGS_RELEASE}")
+set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${OPENCV_EXTRA_FLAGS_RELEASE}")
+set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${OPENCV_EXTRA_FLAGS_DEBUG}")
+set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${OPENCV_EXTRA_FLAGS_DEBUG}")
 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OPENCV_EXTRA_EXE_LINKER_FLAGS}")
 set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} ${OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEASE}")
 set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${OPENCV_EXTRA_EXE_LINKER_FLAGS_DEBUG}")
 
-if(CMAKE_COMPILER_IS_GNUCXX)
-  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-prototypes -Wstrict-prototypes")
-endif()
-
 if(MSVC)
   # avoid warnings from MSVC about overriding the /W* option
   # we replace /W3 with /W4 only for C++ files,
index f342c63..e37f436 100644 (file)
@@ -20,17 +20,17 @@ set(OPENCV_MOD_LIST ${OPENCV_MODULES_PUBLIC})
 ocv_list_sort(OPENCV_MOD_LIST)
 foreach(m ${OPENCV_MOD_LIST})
   string(TOUPPER "${m}" m)
-  set(OPENCV_MODULE_DEFINITIONS_CONFIGMAKE "${OPENCV_MODULE_DEFINITIONS_CONFIGMAKE}#define HAVE_${m} 1\n")
+  set(OPENCV_MODULE_DEFINITIONS_CONFIGMAKE "${OPENCV_MODULE_DEFINITIONS_CONFIGMAKE}#define HAVE_${m}\n")
 endforeach()
 
 set(OPENCV_MODULE_DEFINITIONS_CONFIGMAKE "${OPENCV_MODULE_DEFINITIONS_CONFIGMAKE}\n")
 
-set(OPENCV_MOD_LIST ${OPENCV_MODULES_DISABLED_USER} ${OPENCV_MODULES_DISABLED_AUTO})
-ocv_list_sort(OPENCV_MOD_LIST)
-foreach(m ${OPENCV_MOD_LIST})
-  string(TOUPPER "${m}" m)
-  set(OPENCV_MODULE_DEFINITIONS_CONFIGMAKE "${OPENCV_MODULE_DEFINITIONS_CONFIGMAKE}#undef HAVE_${m}\n")
-endforeach()
+#set(OPENCV_MOD_LIST ${OPENCV_MODULES_DISABLED_USER} ${OPENCV_MODULES_DISABLED_AUTO} ${OPENCV_MODULES_DISABLED_FORCE})
+#ocv_list_sort(OPENCV_MOD_LIST)
+#foreach(m ${OPENCV_MOD_LIST})
+#  string(TOUPPER "${m}" m)
+#  set(OPENCV_MODULE_DEFINITIONS_CONFIGMAKE "${OPENCV_MODULE_DEFINITIONS_CONFIGMAKE}#undef HAVE_${m}\n")
+#endforeach()
 
 configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/opencv_modules.hpp.in" "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/opencv2/opencv_modules.hpp")
 install(FILES "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/opencv2/opencv_modules.hpp" DESTINATION ${OPENCV_INCLUDE_PREFIX}/opencv2 COMPONENT main)
index 9eed4c3..fd63354 100644 (file)
@@ -47,12 +47,12 @@ macro(ocv_check_flag_support lang flag varname)
 
   string(TOUPPER "${flag}" ${varname})
   string(REGEX REPLACE "^(/|-)" "HAVE_${_lang}_" ${varname} "${${varname}}")
-  string(REPLACE "-" "_" ${varname} "${${varname}}")
+  string(REGEX REPLACE " -|-|=| |\\." "_" ${varname} "${${varname}}")
 
   if(_lang STREQUAL "CXX")
-    CHECK_CXX_COMPILER_FLAG(${flag} ${${varname}})
+    CHECK_CXX_COMPILER_FLAG("${ARGN} ${flag}" ${${varname}})
   elseif(_lang STREQUAL "C")
-    CHECK_C_COMPILER_FLAG("${flag}" ${${varname}})
+    CHECK_C_COMPILER_FLAG("${ARGN} ${flag}" ${${varname}})
   else()
     set(${varname} FALSE)
   endif()
index 9e107d4..8d85f94 100644 (file)
@@ -724,10 +724,10 @@ CV_IMPL void cvSaveWindowParameters(const char* name)
     CV_NO_GUI_ERROR("cvSaveWindowParameters");
 }
 
-CV_IMPL void cvLoadWindowParameterss(const char* name)
-{
-    CV_NO_GUI_ERROR("cvLoadWindowParameters");
-}
+// CV_IMPL void cvLoadWindowParameterss(const char* name)
+// {
+//     CV_NO_GUI_ERROR("cvLoadWindowParameters");
+// }
 
 CV_IMPL int cvCreateButton(const char*, void (*)(int, void*), void*, int, int)
 {
index 00fa20e..11aa3f9 100644 (file)
@@ -43,7 +43,7 @@
 #include "test_precomp.hpp"
 #include "opencv2/highgui/highgui.hpp"
 
-#if defined HAVE_GTK  || defined HAVE_QT || defined WIN32 || defined _WIN32 || HAVE_CARBON || HAVE_COCOA
+#if defined HAVE_GTK  || defined HAVE_QT || defined WIN32 || defined _WIN32 || defined HAVE_CARBON || defined HAVE_COCOA
 
 using namespace cv;
 using namespace std;
index 2bcc397..23b93c5 100644 (file)
@@ -162,6 +162,8 @@ else()
 endif()
 add_dependencies(${the_module} ${api_target})
 
+ocv_warnings_disable(CMAKE_CXX_FLAGS -Wmissing-declarations)
+
 # Additional target properties
 set_target_properties(${the_module} PROPERTIES
     OUTPUT_NAME "${the_module}"
index def3b3d..4a0df4f 100644 (file)
@@ -1,5 +1,23 @@
 #include <jni.h>
 
+#include "opencv2/opencv_modules.hpp"
+
+#ifdef HAVE_OPENCV_NONFREE
+#  include "opencv2/nonfree/nonfree.hpp"
+#endif
+
+#ifdef HAVE_OPENCV_FEATURES2D
+#  include "opencv2/features2d/features2d.hpp"
+#endif
+
+#ifdef HAVE_OPENCV_VIDEO
+#  include "opencv2/video/video.hpp"
+#endif
+
+#ifdef HAVE_OPENCV_ML
+#  include "opencv2/ml/ml.hpp"
+#endif
+
 extern "C" {
 
 JNIEXPORT jint JNICALL
@@ -9,6 +27,23 @@ JNI_OnLoad(JavaVM* vm, void* reserved)
     if (vm->GetEnv((void**) &env, JNI_VERSION_1_6) != JNI_OK)
         return -1;
 
+    bool init = true;
+#ifdef HAVE_OPENCV_NONFREE
+    init &= cv::initModule_nonfree();
+#endif
+#ifdef HAVE_OPENCV_FEATURES2D
+    init &= cv::initModule_features2d();
+#endif
+#ifdef HAVE_OPENCV_VIDEO
+    init &= cv::initModule_video();
+#endif
+#ifdef HAVE_OPENCV_ML
+    init &= cv::initModule_ml();
+#endif
+
+    if(!init)
+        return -1;
+
     /* get class with (*env)->FindClass */
     /* register methods with (*env)->RegisterNatives */
 
@@ -21,16 +56,4 @@ JNI_OnUnload(JavaVM *vm, void *reserved)
   //do nothing
 }
 
-} // extern "C"
-
-#include "opencv2/opencv_modules.hpp"
-
-#if HAVE_OPENCV_MODULES_NONFREE
-#include "opencv2/nonfree/nonfree.hpp"
-static bool makeUseOfNonfree = initModule_nonfree();
-#endif
-
-#if HAVE_OPENCV_MODULES_FEATURES2D
-#include "opencv2/features2d/features2d.hpp"
-static bool makeUseOfNonfree = initModule_features2d();
-#endif
\ No newline at end of file
+} // extern "C"
\ No newline at end of file
index 4051e92..4c734b1 100644 (file)
@@ -18,7 +18,7 @@ using std::tr1::get;
 typedef TestBaseWithParam<String> stitch;\r
 typedef TestBaseWithParam<String> match;\r
 \r
-#if HAVE_OPENCV_NONFREE\r
+#ifdef HAVE_OPENCV_NONFREE\r
 #define TEST_DETECTORS testing::Values("surf", "orb")\r
 #else\r
 #define TEST_DETECTORS testing::Values<String>("orb")\r
index b332535..41c395b 100644 (file)
@@ -61,7 +61,7 @@ Stitcher Stitcher::createDefault(bool try_use_gpu)
 #ifdef HAVE_OPENCV_GPU
     if (try_use_gpu && gpu::getCudaEnabledDeviceCount() > 0)
     {
-#if HAVE_OPENCV_NONFREE
+#ifdef HAVE_OPENCV_NONFREE
         stitcher.setFeaturesFinder(new detail::SurfFeaturesFinderGpu());
 #else
         stitcher.setFeaturesFinder(new detail::OrbFeaturesFinder());
@@ -72,7 +72,7 @@ Stitcher Stitcher::createDefault(bool try_use_gpu)
     else
 #endif
     {
-#if HAVE_OPENCV_NONFREE
+#ifdef HAVE_OPENCV_NONFREE
         stitcher.setFeaturesFinder(new detail::SurfFeaturesFinder());
 #else
         stitcher.setFeaturesFinder(new detail::OrbFeaturesFinder());
index 04d0ee2..dcf6843 100644 (file)
@@ -42,7 +42,7 @@
 #include "test_precomp.hpp"\r
 #include "opencv2/opencv_modules.hpp"\r
 \r
-#if HAVE_OPENCV_NONFREE\r
+#ifdef HAVE_OPENCV_NONFREE\r
 \r
 using namespace cv;\r
 using namespace std;\r
@@ -57,7 +57,7 @@ TEST(SurfFeaturesFinder, CanFindInROIs)
     rois.push_back(Rect(img.cols / 2, img.rows / 2, img.cols - img.cols / 2, img.rows - img.rows / 2));\r
     detail::ImageFeatures roi_features;\r
     (*finder)(img, roi_features, rois);\r
-    \r
+\r
     int tl_rect_count = 0, br_rect_count = 0, bad_count = 0;\r
     for (size_t i = 0; i < roi_features.keypoints.size(); ++i)\r
     {\r
index b6640a9..19fcfef 100644 (file)
@@ -53,7 +53,7 @@
 #include "opencv2/videostab/motion_core.hpp"
 #include "opencv2/videostab/outlier_rejection.hpp"
 
-#if HAVE_OPENCV_GPU
+#ifdef HAVE_OPENCV_GPU
   #include "opencv2/gpu/gpu.hpp"
 #endif
 
@@ -73,7 +73,7 @@ CV_EXPORTS Mat estimateGlobalMotionRobust(
 
 class CV_EXPORTS MotionEstimatorBase
 {
-public:    
+public:
     virtual ~MotionEstimatorBase() {}
 
     virtual void setMotionModel(MotionModel val) { motionModel_ = val; }
@@ -200,7 +200,7 @@ private:
     std::vector<Point2f> pointsPrevGood_, pointsGood_;
 };
 
-#if HAVE_OPENCV_GPU
+#ifdef HAVE_OPENCV_GPU
 class CV_EXPORTS KeypointBasedMotionEstimatorGpu : public ImageMotionEstimatorBase
 {
 public:
index 13f9ff0..e11b081 100644 (file)
@@ -46,7 +46,7 @@
 #include "opencv2/core/core.hpp"
 #include "opencv2/opencv_modules.hpp"
 
-#if HAVE_OPENCV_GPU
+#ifdef HAVE_OPENCV_GPU
   #include "opencv2/gpu/gpu.hpp"
 #endif
 
@@ -99,7 +99,7 @@ public:
             OutputArray status, OutputArray errors);
 };
 
-#if HAVE_OPENCV_GPU
+#ifdef HAVE_OPENCV_GPU
 class CV_EXPORTS SparsePyrLkOptFlowEstimatorGpu
         : public PyrLkOptFlowEstimatorBase, public ISparseOptFlowEstimator
 {
index 8f5bb11..48fa4de 100644 (file)
@@ -48,7 +48,7 @@
 #include "opencv2/videostab/global_motion.hpp"
 #include "opencv2/videostab/log.hpp"
 
-#if HAVE_OPENCV_GPU
+#ifdef HAVE_OPENCV_GPU
   #include "opencv2/gpu/gpu.hpp"
 #endif
 
@@ -119,7 +119,7 @@ private:
     Mat_<float> mapx_, mapy_;
 };
 
-#if HAVE_OPENCV_GPU
+#ifdef HAVE_OPENCV_GPU
 class CV_EXPORTS MoreAccurateMotionWobbleSuppressorGpu : public MoreAccurateMotionWobbleSuppressorBase
 {
 public:
index c9998ab..e464a03 100644 (file)
@@ -621,7 +621,7 @@ Mat ToFileMotionWriter::estimate(const Mat &frame0, const Mat &frame1, bool *ok)
 
 KeypointBasedMotionEstimator::KeypointBasedMotionEstimator(Ptr<MotionEstimatorBase> estimator)
     : ImageMotionEstimatorBase(estimator->motionModel()), motionEstimator_(estimator)
-{    
+{
     setDetector(new GoodFeaturesToTrackDetector());
     setOpticalFlowEstimator(new SparsePyrLkOptFlowEstimator());
     setOutlierRejector(new NullOutlierRejector());
@@ -686,11 +686,11 @@ Mat KeypointBasedMotionEstimator::estimate(const Mat &frame0, const Mat &frame1,
 }
 
 
-#if HAVE_OPENCV_GPU
+#ifdef HAVE_OPENCV_GPU
 KeypointBasedMotionEstimatorGpu::KeypointBasedMotionEstimatorGpu(Ptr<MotionEstimatorBase> estimator)
     : ImageMotionEstimatorBase(estimator->motionModel()), motionEstimator_(estimator)
 {
-    CV_Assert(gpu::getCudaEnabledDeviceCount() > 0);    
+    CV_Assert(gpu::getCudaEnabledDeviceCount() > 0);
     setOutlierRejector(new NullOutlierRejector());
 }
 
@@ -720,7 +720,7 @@ Mat KeypointBasedMotionEstimatorGpu::estimate(const gpu::GpuMat &frame0, const g
     detector_(grayFrame0, pointsPrev_);
 
     // find correspondences
-    optFlowEstimator_.run(frame0, frame1, pointsPrev_, points_, status_);    
+    optFlowEstimator_.run(frame0, frame1, pointsPrev_, points_, status_);
 
     // leave good correspondences only
     gpu::compactPoints(pointsPrev_, points_, status_);
index 4b35f32..b97cd0f 100644 (file)
@@ -241,7 +241,7 @@ public:
             for (int dx = -rad; dx <= rad; ++dx)
             {
                 int qx0 = x + dx;
-                int qy0 = y + dy;               
+                int qy0 = y + dy;
 
                 if (qy0 >= 0 && qy0 < mask0.rows && qx0 >= 0 && qx0 < mask0.cols && mask0(qy0,qx0))
                 {
@@ -325,7 +325,7 @@ public:
 
 MotionInpainter::MotionInpainter()
 {
-#if HAVE_OPENCV_GPU
+#ifdef HAVE_OPENCV_GPU
     setOptFlowEstimator(new DensePyrLkOptFlowEstimatorGpu());
 #else
     CV_Error(CV_StsNotImplemented, "Current implementation of MotionInpainter requires GPU");
@@ -374,7 +374,7 @@ void MotionInpainter::inpaint(int idx, Mat &frame, Mat &mask)
 
         // warp frame
 
-        frame1_ = at(neighbor, *frames_);        
+        frame1_ = at(neighbor, *frames_);
 
         if (motionModel_ != MM_HOMOGRAPHY)
             warpAffine(
@@ -532,7 +532,7 @@ void completeFrameAccordingToFlow(
 
                 if (x1 >= 0 && x1 < frame1.cols && y1 >= 0 && y1 < frame1.rows && mask1_(y1,x1)
                     && sqr(flowX_(y0,x0)) + sqr(flowY_(y0,x0)) < sqr(distThresh))
-                {                    
+                {
                     frame0.at<Point3_<uchar> >(y0,x0) = frame1.at<Point3_<uchar> >(y1,x1);
                     mask0_(y0,x0) = 255;
                 }
index f3e5fb1..44ea613 100644 (file)
@@ -60,7 +60,7 @@ void SparsePyrLkOptFlowEstimator::run(
 }
 
 
-#if HAVE_OPENCV_GPU
+#ifdef HAVE_OPENCV_GPU
 SparsePyrLkOptFlowEstimatorGpu::SparsePyrLkOptFlowEstimatorGpu()
 {
     CV_Assert(gpu::getCudaEnabledDeviceCount() > 0);
@@ -135,7 +135,7 @@ void DensePyrLkOptFlowEstimatorGpu::run(
     flowX_.download(flowX.getMatRef());
     flowY_.download(flowY.getMatRef());
 }
-#endif // #if HAVE_OPENCV_GPU
+#endif // HAVE_OPENCV_GPU
 
 } // namespace videostab
 } // namespace cv
index 2b60cfb..d5a6b3a 100644 (file)
@@ -115,7 +115,7 @@ void MoreAccurateMotionWobbleSuppressor::suppress(int idx, const Mat &frame, Mat
 }
 
 
-#if HAVE_OPENCV_GPU
+#ifdef HAVE_OPENCV_GPU
 void MoreAccurateMotionWobbleSuppressorGpu::suppress(int idx, const gpu::GpuMat &frame, gpu::GpuMat &result)
 {
     CV_Assert(motions_ && stabilizationMotions_);
index afb0d22..bf96bdf 100644 (file)
@@ -4,6 +4,8 @@
 # ----------------------------------------------------------------------------
 add_custom_target(opencv_android_examples)
 
+ocv_warnings_disable(CMAKE_CXX_FLAGS -Wmissing-declarations)
+
 add_subdirectory(15-puzzle)
 add_subdirectory(face-detection)
 add_subdirectory(image-manipulations)
index 2e9f1db..986a754 100644 (file)
@@ -215,7 +215,7 @@ public:
             outlierRejector = tblor;
         }
 
-#if HAVE_OPENCV_GPU
+#ifdef HAVE_OPENCV_GPU
         if (gpu)
         {
             KeypointBasedMotionEstimatorGpu *kbest = new KeypointBasedMotionEstimatorGpu(est);
@@ -256,7 +256,7 @@ public:
             outlierRejector = tblor;
         }
 
-#if HAVE_OPENCV_GPU
+#ifdef HAVE_OPENCV_GPU
         if (gpu)
         {
             KeypointBasedMotionEstimatorGpu *kbest = new KeypointBasedMotionEstimatorGpu(est);
@@ -341,7 +341,7 @@ int main(int argc, const char **argv)
             return 0;
         }
 
-#if HAVE_OPENCV_GPU
+#ifdef HAVE_OPENCV_GPU
         if (arg("gpu") == "yes")
         {
             cout << "initializing GPU..."; cout.flush();
@@ -419,7 +419,7 @@ int main(int argc, const char **argv)
             {
                 MoreAccurateMotionWobbleSuppressorBase *ws = new MoreAccurateMotionWobbleSuppressor();
                 if (arg("gpu") == "yes")
-#if HAVE_OPENCV_GPU
+#ifdef HAVE_OPENCV_GPU
                     ws = new MoreAccurateMotionWobbleSuppressorGpu();
 #else
                     throw runtime_error("OpenCV is built without GPU support");