From 18e7afdfd91e20b938ba885045b5537bcce1f915 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Thu, 4 Aug 2016 19:23:49 +0300 Subject: [PATCH] cmake: add OPENCV_ENABLE_NONFREE option and macro --- CMakeLists.txt | 7 +++++++ cmake/templates/opencv_modules.hpp.in | 4 ++++ modules/core/include/opencv2/core/base.hpp | 2 ++ 3 files changed, 13 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 317edbb..5e575bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -164,6 +164,8 @@ endif() # OpenCV cmake options # ---------------------------------------------------------------------------- +OCV_OPTION(OPENCV_ENABLE_NONFREE "Enable non-free algorithms" OFF) + # Optional 3rd party components # =================================================== OCV_OPTION(WITH_1394 "Include IEEE1394 support" ON IF (NOT ANDROID AND NOT IOS AND NOT WINRT) ) @@ -914,6 +916,11 @@ status(" Disabled:" OPENCV_MODULES_DISABLED_USER THEN ${OPENCV status(" Disabled by dependency:" OPENCV_MODULES_DISABLED_AUTO THEN ${OPENCV_MODULES_DISABLED_AUTO_ST} ELSE "-") status(" Unavailable:" OPENCV_MODULES_DISABLED_FORCE THEN ${OPENCV_MODULES_DISABLED_FORCE_ST} ELSE "-") +if(OPENCV_ENABLE_NONFREE) + status("") + status(" Non-free algorithms are enabled") +endif() + # ========================== Android details ========================== if(ANDROID) status("") diff --git a/cmake/templates/opencv_modules.hpp.in b/cmake/templates/opencv_modules.hpp.in index 1498715..6696bb4 100644 --- a/cmake/templates/opencv_modules.hpp.in +++ b/cmake/templates/opencv_modules.hpp.in @@ -6,4 +6,8 @@ * */ +// This definition means that OpenCV is built with enabled non-free code. +// For example, patented algorithms for non-profit/non-commercial use only. +#cmakedefine OPENCV_ENABLE_NONFREE + @OPENCV_MODULE_DEFINITIONS_CONFIGMAKE@ diff --git a/modules/core/include/opencv2/core/base.hpp b/modules/core/include/opencv2/core/base.hpp index ed633f5..0432ccb 100644 --- a/modules/core/include/opencv2/core/base.hpp +++ b/modules/core/include/opencv2/core/base.hpp @@ -49,6 +49,8 @@ # error base.hpp header must be compiled as C++ #endif +#include "opencv2/opencv_modules.hpp" + #include #include -- 2.7.4