From 9bbcebd6b01f5e946d9e1651925e10feb9937118 Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Sat, 12 May 2012 13:54:26 +0000 Subject: [PATCH] added opencv_world module that combines all the other [selected by user] OpenCV modules, except for opencv_python and opencv_gpu. --- CMakeLists.txt | 11 +- cmake/OpenCVModule.cmake | 12 ++- modules/highgui/CMakeLists.txt | 2 + modules/ml/include/opencv2/ml/ml.hpp | 2 + .../nonfree/include/opencv2/nonfree/nonfree.hpp | 2 +- modules/video/include/opencv2/video/video.hpp | 9 ++ modules/world/CMakeLists.txt | 117 +++++++++++++++++++++ modules/world/include/opencv2/world/world.hpp | 58 ++++++++++ modules/world/src/precomp.cpp | 0 modules/world/src/precomp.hpp | 66 ++++++++++++ modules/world/src/world_init.cpp | 61 +++++++++++ 11 files changed, 335 insertions(+), 5 deletions(-) create mode 100644 modules/world/CMakeLists.txt create mode 100644 modules/world/include/opencv2/world/world.hpp create mode 100644 modules/world/src/precomp.cpp create mode 100644 modules/world/src/precomp.hpp create mode 100644 modules/world/src/world_init.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index f00f2ce..688e0e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -155,10 +155,19 @@ OCV_OPTION(INSTALL_PYTHON_EXAMPLES "Install Python examples" OFF ) OCV_OPTION(INSTALL_ANDROID_EXAMPLES "Install Android examples" OFF IF ANDROID ) OCV_OPTION(INSTALL_TO_MANGLED_PATHS "Enables mangled install paths, that help with side by side installs." OFF IF (UNIX AND NOT ANDROID AND NOT IOS AND BUILD_SHARED_LIBS) ) + +if(CMAKE_GENERATOR MATCHES Xcode) + set(ENABLE_SOLUTION_FOLDERS0 ON) +elseif(MSVC_IDE) + set(ENABLE_SOLUTION_FOLDERS0 ON) +else() + set(ENABLE_SOLUTION_FOLDERS0 OFF) +endif() + # OpenCV build options # =================================================== OCV_OPTION(ENABLE_PRECOMPILED_HEADERS "Use precompiled headers" ON IF (NOT IOS) ) -OCV_OPTION(ENABLE_SOLUTION_FOLDERS "Solution folder in Visual Studio or in other IDEs" MSVC_IDE IF (CMAKE_VERSION VERSION_GREATER "2.8.0") ) +OCV_OPTION(ENABLE_SOLUTION_FOLDERS "Solution folder in Visual Studio or in other IDEs" ${ENABLE_SOLUTION_FOLDERS0} IF (CMAKE_VERSION VERSION_GREATER "2.8.0") ) OCV_OPTION(ENABLE_PROFILING "Enable profiling in the GCC compiler (Add flags: -g -pg)" OFF IF CMAKE_COMPILER_IS_GNUCXX ) OCV_OPTION(ENABLE_OMIT_FRAME_POINTER "Enable -fomit-frame-pointer for GCC" ON IF CMAKE_COMPILER_IS_GNUCXX ) OCV_OPTION(ENABLE_POWERPC "Enable PowerPC for GCC" ON IF (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_SYSTEM_PROCESSOR MATCHES powerpc.*) ) diff --git a/cmake/OpenCVModule.cmake b/cmake/OpenCVModule.cmake index 9c21c73..1809459 100644 --- a/cmake/OpenCVModule.cmake +++ b/cmake/OpenCVModule.cmake @@ -58,8 +58,8 @@ set(OPENCV_MODULES_DISABLED_FORCE "" CACHE INTERNAL "List of OpenCV modules whic # * - can include full names of modules or full pathes to shared/static libraries or cmake targets macro(ocv_add_dependencies full_modname) #we don't clean the dependencies here to allow this macro several times for every module - foreach(d "REQIRED" ${ARGN}) - if(d STREQUAL "REQIRED") + foreach(d "REQUIRED" ${ARGN}) + if(d STREQUAL "REQUIRED") set(__depsvar OPENCV_MODULE_${full_modname}_REQ_DEPS) elseif(d STREQUAL "OPTIONAL") set(__depsvar OPENCV_MODULE_${full_modname}_OPT_DEPS) @@ -110,7 +110,13 @@ macro(ocv_add_module _name) unset(OPENCV_MODULE_${the_module}_OPT_DEPS CACHE) #create option to enable/disable this module - option(BUILD_${the_module} "Include ${the_module} module into the OpenCV build" ON) + if(the_module STREQUAL "opencv_world") + set(build_the_module OFF) + else() + set(build_the_module ON) + endif() + option(BUILD_${the_module} "Include ${the_module} module into the OpenCV build" ${build_the_module}) + unset(build_the_module) if("${ARGV1}" STREQUAL "INTERNAL" OR "${ARGV1}" STREQUAL "BINDINGS") set(__ocv_argn__ ${ARGN}) diff --git a/modules/highgui/CMakeLists.txt b/modules/highgui/CMakeLists.txt index a5ef22c..414b85f 100644 --- a/modules/highgui/CMakeLists.txt +++ b/modules/highgui/CMakeLists.txt @@ -301,3 +301,5 @@ endif() ocv_add_accuracy_tests() ocv_add_perf_tests() + +set(HIGHGUI_LIBRARIES ${HIGHGUI_LIBRARIES} PARENT_SCOPE) diff --git a/modules/ml/include/opencv2/ml/ml.hpp b/modules/ml/include/opencv2/ml/ml.hpp index 0cc1b5f..6358fa7 100644 --- a/modules/ml/include/opencv2/ml/ml.hpp +++ b/modules/ml/include/opencv2/ml/ml.hpp @@ -2136,6 +2136,8 @@ typedef CvGBTreesParams GradientBoostingTreeParams; typedef CvGBTrees GradientBoostingTrees; template<> CV_EXPORTS void Ptr::delete_obj(); + +CV_EXPORTS bool initModule_ml(void); } diff --git a/modules/nonfree/include/opencv2/nonfree/nonfree.hpp b/modules/nonfree/include/opencv2/nonfree/nonfree.hpp index dd084cd..3510f02 100644 --- a/modules/nonfree/include/opencv2/nonfree/nonfree.hpp +++ b/modules/nonfree/include/opencv2/nonfree/nonfree.hpp @@ -48,7 +48,7 @@ namespace cv { -CV_EXPORTS_W bool initModule_nonfree(); +CV_EXPORTS bool initModule_nonfree(); } diff --git a/modules/video/include/opencv2/video/video.hpp b/modules/video/include/opencv2/video/video.hpp index 21a2fce..ebac290 100644 --- a/modules/video/include/opencv2/video/video.hpp +++ b/modules/video/include/opencv2/video/video.hpp @@ -46,4 +46,13 @@ #include "opencv2/video/tracking.hpp" #include "opencv2/video/background_segm.hpp" +#ifdef __cplusplus +namespace cv +{ + +CV_EXPORTS bool initModule_video(void); + +} +#endif + #endif //__OPENCV_VIDEO_HPP__ diff --git a/modules/world/CMakeLists.txt b/modules/world/CMakeLists.txt new file mode 100644 index 0000000..7d3a8e2 --- /dev/null +++ b/modules/world/CMakeLists.txt @@ -0,0 +1,117 @@ +set(the_description "All the selected OpenCV modules in a single binary") + +set(module_list ) + +ocv_add_module(world opencv_core OPTIONAL opencv_flann opencv_imgproc opencv_video opencv_ml opencv_features2d opencv_highgui opencv_calib3d opencv_photo opencv_objdetect opencv_legacy opencv_nonfree) + +set(the_module opencv_world) + +ocv_glob_module_sources() +ocv_module_include_directories() + +add_library(${the_module} ${OPENCV_MODULE_TYPE} ${OPENCV_MODULE_${the_module}_HEADERS} ${OPENCV_MODULE_${the_module}_SOURCES}) + +if(ENABLE_SOLUTION_FOLDERS) + set_target_properties(${the_module} PROPERTIES FOLDER "modules") +endif() + +set_target_properties(${the_module} PROPERTIES + OUTPUT_NAME "${the_module}${OPENCV_DLLVERSION}" + DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}" + ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH} + RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} + INSTALL_NAME_DIR lib +) + +# For dynamic link numbering convenions +if(NOT ANDROID) + # Android SDK build scripts can include only .so files into final .apk + # As result we should not set version properties for Android + set_target_properties(${the_module} PROPERTIES + VERSION ${OPENCV_VERSION} + SOVERSION ${OPENCV_SOVERSION} + ) +endif() + +if(BUILD_SHARED_LIBS) + if(MSVC) + set_target_properties(${the_module} PROPERTIES DEFINE_SYMBOL CVAPI_EXPORTS) + else() + add_definitions(-DCVAPI_EXPORTS) + endif() +endif() + +if(MSVC) + if(CMAKE_CROSSCOMPILING) + set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:secchk") + endif() + set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:libc /DEBUG") +endif() + +set(objpath0 "${OpenCV_BINARY_DIR}/modules/") + +if(CMAKE_GENERATOR MATCHES "^Visual.*$") + set(have_cfg 1) + set(objpath0 "${objpath0}/CMakeFiles/opencv_.dir/src/.obj") +elseif (CMAKE_GENERATOR MATCHES Xcode) + set(have_cfg 1) + set(objpath0 "${objpath0}/OpenCV.build/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/opencv_.build/Objects-normal/$(CURRENT_ARCH)/.o") +else() + set(have_cfg 0) + set(objpath0 "${objpath0}/CMakeFiles/opencv_.dir/src/.o") +endif() + +#message("CMAKE_CFG_INTDIR: ${CMAKE_CFG_INTDIR}") +set(objlist) + +foreach(m ${OPENCV_MODULES_BUILD}) + if(m STREQUAL ${the_module}) + else() + add_dependencies(${the_module} ${m}) + string(REGEX REPLACE "^opencv_" "" bare_m "${m}") + string(REGEX REPLACE "" "${bare_m}" objpath1 "${objpath0}") + if(m STREQUAL "opencv_highgui") + target_link_libraries(${the_module} ${HIGHGUI_LIBRARIES} zlib libtiff libjpeg libpng libjasper) + endif() + set(modobjlist) + foreach(src ${OPENCV_MODULE_${m}_SOURCES}) + get_filename_component(srcname ${src} NAME) + if(srcname STREQUAL "precomp.cpp") + elseif(srcname MATCHES ".*\\.[cm].*") + get_filename_component(srcname_we ${srcname} NAME_WE) + string(REGEX REPLACE "${srcname_we}" objpath2 "${objpath1}") + string(REGEX REPLACE "${srcname}" objpath3 "${objpath2}") + set(modobjlist "${modobjlist} ${objpath3}") + endif() + endforeach() + set(objlist "${objlist} ${modobjlist}") + endif() +endforeach() + + +if(have_cfg) + set_target_properties(${the_module} PROPERTIES + LINK_FLAGS_DEBUG ${objlist} + LINK_FLAGS_RELEASE ${objlist}) +else() + set_target_properties(${the_module} PROPERTIES + LINK_FLAGS ${objlist}) +endif() + +install(TARGETS ${the_module} + RUNTIME DESTINATION bin COMPONENT main + LIBRARY DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT main + ARCHIVE DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT main +) + +# only "public" headers need to be installed +if(OPENCV_MODULE_${the_module}_HEADERS AND OPENCV_MODULES_PUBLIC MATCHES "(^|;)${the_module}(;|$)") + foreach(hdr ${OPENCV_MODULE_${the_module}_HEADERS}) + string(REGEX REPLACE "^.*opencv2/" "opencv2/" hdr2 "${hdr}") + if(hdr2 MATCHES "^(opencv2/.*)/[^/]+.h(..)?$") + install(FILES ${hdr} DESTINATION "${OPENCV_INCLUDE_PREFIX}/${CMAKE_MATCH_1}" COMPONENT main) + endif() + endforeach() +endif() + +ocv_add_precompiled_headers(${the_module}) diff --git a/modules/world/include/opencv2/world/world.hpp b/modules/world/include/opencv2/world/world.hpp new file mode 100644 index 0000000..b4bff33 --- /dev/null +++ b/modules/world/include/opencv2/world/world.hpp @@ -0,0 +1,58 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009-2010, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + +#ifndef __OPENCV_WORLD_HPP__ +#define __OPENCV_WORLD_HPP__ + +#include "opencv2/core/core.hpp" + +#ifdef __cplusplus +namespace cv +{ + +CV_EXPORTS_W bool initAll(); + +} + +#endif + +#endif diff --git a/modules/world/src/precomp.cpp b/modules/world/src/precomp.cpp new file mode 100644 index 0000000..e69de29 diff --git a/modules/world/src/precomp.hpp b/modules/world/src/precomp.hpp new file mode 100644 index 0000000..667d2ff --- /dev/null +++ b/modules/world/src/precomp.hpp @@ -0,0 +1,66 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + +#ifndef __OPENCV_PRECOMP_H__ +#define __OPENCV_PRECOMP_H__ + +#ifdef HAVE_CVCONFIG_H +#include "cvconfig.h" +#endif + +#include "opencv2/opencv_modules.hpp" +#ifdef HAVE_OPENCV_VIDEO +#include "opencv2/video/video.hpp" +#endif +#ifdef HAVE_OPENCV_FEATURES2D +#include "opencv2/features2d/features2d.hpp" +#endif +#ifdef HAVE_OPENCV_NONFREE +#include "opencv2/nonfree/nonfree.hpp" +#endif +#ifdef HAVE_OPENCV_ML +#include "opencv2/ml/ml.hpp" +#endif + +#include "opencv2/world/world.hpp" + +#endif diff --git a/modules/world/src/world_init.cpp b/modules/world/src/world_init.cpp new file mode 100644 index 0000000..3fd13f3 --- /dev/null +++ b/modules/world/src/world_init.cpp @@ -0,0 +1,61 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + +#include "precomp.hpp" + +bool cv::initAll() +{ + return true +#ifdef HAVE_OPENCV_VIDEO + && initModule_video() +#endif +#ifdef HAVE_OPENCV_FEATURES2D + && initModule_features2d() +#endif +#ifdef HAVE_OPENCV_NONFREE + && initModule_nonfree() +#endif +#ifdef HAVE_OPENCV_ML + && initModule_ml() +#endif + ; +} -- 2.7.4