You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2021/06/15 06:55:52 UTC

[GitHub] [nifi-minifi-cpp] lordgamez opened a new pull request #1110: MINIFICPP-994 Move out OpenCV build from cmake configuration

lordgamez opened a new pull request #1110:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1110


   Jira ticket: https://issues.apache.org/jira/browse/MINIFICPP-994
   
   ----------------------------------------------------------------------------------------------
   Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.
   
   In order to streamline the review of the contribution we ask you
   to ensure the following steps have been taken:
   
   ### For all changes:
   - [ ] Is there a JIRA ticket associated with this PR? Is it referenced
        in the commit message?
   
   - [ ] Does your PR title start with MINIFICPP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
   
   - [ ] Has your PR been rebased against the latest commit within the target branch (typically main)?
   
   - [ ] Is your initial contribution a single, squashed commit?
   
   ### For code changes:
   - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
   - [ ] If applicable, have you updated the LICENSE file?
   - [ ] If applicable, have you updated the NOTICE file?
   
   ### For documentation related changes:
   - [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
   
   ### Note:
   Please ensure that once the PR is submitted, you check GitHub Actions CI results for build issues and submit an update to your PR as soon as possible.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] szaszm closed pull request #1110: MINIFICPP-994 Move out OpenCV build from cmake configuration

Posted by GitBox <gi...@apache.org>.
szaszm closed pull request #1110:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1110


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] lordgamez commented on a change in pull request #1110: MINIFICPP-994 Move out OpenCV build from cmake configuration

Posted by GitBox <gi...@apache.org>.
lordgamez commented on a change in pull request #1110:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1110#discussion_r672231836



##########
File path: CMakeLists.txt
##########
@@ -503,6 +517,8 @@ endif()
 ## OpenCV Extensions
 option(ENABLE_OPENCV "Disables the OpenCV extensions." OFF)
 if (ENABLE_OPENCV)
+	include(BundledOpenCV)
+	use_bundled_opencv(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
 	createExtension(OPENCV-EXTENSIONS "OPENCV EXTENSIONS" "This enabled OpenCV support" "extensions/opencv" "extensions/opencv/tests")

Review comment:
       Updated in db9827c54077e213ac5c4f1c4ce871d155c0c40d




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] lordgamez commented on a change in pull request #1110: MINIFICPP-994 Move out OpenCV build from cmake configuration

Posted by GitBox <gi...@apache.org>.
lordgamez commented on a change in pull request #1110:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1110#discussion_r672231758



##########
File path: CMakeLists.txt
##########
@@ -503,6 +517,8 @@ endif()
 ## OpenCV Extensions
 option(ENABLE_OPENCV "Disables the OpenCV extensions." OFF)

Review comment:
       Updated in db9827c54077e213ac5c4f1c4ce871d155c0c40d

##########
File path: CMakeLists.txt
##########
@@ -503,6 +517,8 @@ endif()
 ## OpenCV Extensions
 option(ENABLE_OPENCV "Disables the OpenCV extensions." OFF)
 if (ENABLE_OPENCV)
+	include(BundledOpenCV)
+	use_bundled_opencv(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
 	createExtension(OPENCV-EXTENSIONS "OPENCV EXTENSIONS" "This enabled OpenCV support" "extensions/opencv" "extensions/opencv/tests")

Review comment:
       Updated in db9827c54077e213ac5c4f1c4ce871d155c0c40d




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] lordgamez commented on a change in pull request #1110: MINIFICPP-994 Move out OpenCV build from cmake configuration

Posted by GitBox <gi...@apache.org>.
lordgamez commented on a change in pull request #1110:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1110#discussion_r672231758



##########
File path: CMakeLists.txt
##########
@@ -503,6 +517,8 @@ endif()
 ## OpenCV Extensions
 option(ENABLE_OPENCV "Disables the OpenCV extensions." OFF)

Review comment:
       Updated in db9827c54077e213ac5c4f1c4ce871d155c0c40d

##########
File path: CMakeLists.txt
##########
@@ -503,6 +517,8 @@ endif()
 ## OpenCV Extensions
 option(ENABLE_OPENCV "Disables the OpenCV extensions." OFF)
 if (ENABLE_OPENCV)
+	include(BundledOpenCV)
+	use_bundled_opencv(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
 	createExtension(OPENCV-EXTENSIONS "OPENCV EXTENSIONS" "This enabled OpenCV support" "extensions/opencv" "extensions/opencv/tests")

Review comment:
       Updated in db9827c54077e213ac5c4f1c4ce871d155c0c40d




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] lordgamez commented on pull request #1110: MINIFICPP-994 Move out OpenCV build from cmake configuration

Posted by GitBox <gi...@apache.org>.
lordgamez commented on pull request #1110:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1110#issuecomment-882657304


   > This PR causes a build issue:
   > 
   > ```
   > + nice -n 19 ninja -v -j64
   > ninja: error: 'thirdparty/opencv-install/lib64/libopencv_flann.a', needed by 'main/minifi', missing and no known rule to make it
   > ```
   > 
   > May or may not happen with GNU Make, I only tried building with Ninja on Linux (with both GCC and Clang) after my merge attempt. Will postpone merging until this is fixed.
   > 
   > My cmake flags:
   > 
   > ```
   > cmake -G Ninja -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DFORCE_COLORED_OUTPUT=ON -DAWS_ENABLE_UNITY_BUILD=OFF -DASAN_BUILD=OFF -DCMAKE_BUILD_TYPE=Debug -DFAIL_ON_WARNINGS=ON -DENABLE_PYTHON=ON -DENABLE_OPS=ON -DENABLE_JNI=OFF -DENABLE_OPC=ON -DENABLE_COAP=ON -DENABLE_GPS=ON -DENABLE_MQTT=ON -DENABLE_LIBRDKAFKA=ON -DENABLE_SENSORS=ON -DENABLE_USB_CAMERA=ON -DENABLE_AWS=OFF -DENABLE_SFTP=ON -DENABLE_OPENWSMAN=ON -DENABLE_BUSTACHE=ON -DENABLE_OPENCV=ON -DENABLE_TENSORFLOW=OFF -DENABLE_SQL=OFF -DENABLE_PCAP=OFF -DENABLE_NANOFI=ON -DENABLE_SYSTEMD=ON ..
   > ```
   > 
   > Same for clang, except substitute gcc with clang and g++ with clang++.
   > 
   > These are the exact scripts I use to test builds: https://github.com/szaszm/verify-nifi-release/tree/master/bin
   
   Thanks for all the info! There was an error in the cmake file, the wrong variable was passed to the build byproduct parameter. It worked fine with Make, but ninja fails without defining the byproducts beforehand. I fixed the issue in f0ab4c23ec482140065bd51a13b71eaa98900f71


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] szaszm commented on a change in pull request #1110: MINIFICPP-994 Move out OpenCV build from cmake configuration

Posted by GitBox <gi...@apache.org>.
szaszm commented on a change in pull request #1110:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1110#discussion_r670490280



##########
File path: cmake/BundledOpenCV.cmake
##########
@@ -0,0 +1,214 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+function(use_bundled_opencv SOURCE_DIR BINARY_DIR)
+    set(PATCH_FILE "${SOURCE_DIR}/thirdparty/opencv/opencv.patch")
+    set(PC "${Patch_EXECUTABLE}" -R -p1 -s -f --dry-run -i "${PATCH_FILE}" || "${Patch_EXECUTABLE}" -p1 -i "${PATCH_FILE}")
+
+    if (WIN32)
+        set(CMAKE_INSTALL_LIBDIR "lib")
+    else()
+        include(GNUInstallDirs)
+    endif()
+
+    # Define byproducts
+    if (WIN32)
+        set(SUFFIX "410.lib")
+        set(THIRDPARTY_SUFFIX ".lib")
+        set(PREFIX "")
+        set(THIRDPARTY_DIR "")
+    else()
+        set(SUFFIX ".a")
+        set(THIRDPARTY_SUFFIX ".a")
+        set(PREFIX "lib")
+        set(THIRDPARTY_DIR "opencv4/3rdparty/")
+    endif()
+
+    set(OPENCV_BYPRODUCT_DIR "${CMAKE_CURRENT_BINARY_DIR}/thirdparty/opencv-install")
+    set(BYPRODUCTS
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_flann${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_dnn${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_objdetect${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_core${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_gapi${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_imgcodecs${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_calib3d${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_imgproc${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_photo${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_videoio${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_video${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_stitching${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_features2d${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${THIRDPARTY_DIR}${PREFIX}libjpeg-turbo${THIRDPARTY_SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${THIRDPARTY_DIR}${PREFIX}libpng${THIRDPARTY_SUFFIX}")
+
+    # Set build options
+    set(OPENCV_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS}
+            "-DCMAKE_INSTALL_PREFIX=${OPENCV_BYPRODUCT_DIR}"
+            "-DBUILD_SHARED_LIBS=OFF"
+            "-DBUILD_WITH_STATIC_CRT=OFF"
+            "-DBUILD_EXAMPLES=OFF"
+            "-DBUILD_DOCS=OFF"
+            "-DBUILD_PACKAGE=OFF"
+            "-DBUILD_opencv_apps=OFF"
+            "-DBUILD_PERF_TESTS=OFF"
+            "-DBUILD_TESTS=OFF"
+            "-DBUILD_opencv_calib3d=ON"
+            "-DBUILD_opencv_core=ON"
+            "-DBUILD_opencv_dnn=ON"
+            "-DBUILD_opencv_features2d=ON"
+            "-DBUILD_opencv_flann=ON"
+            "-DBUILD_opencv_gapi=ON"
+            "-DBUILD_opencv_highgui=OFF"
+            "-DBUILD_opencv_imgcodecs=ON"
+            "-DBUILD_opencv_imgproc=ON"
+            "-DBUILD_opencv_ml=OFF"
+            "-DBUILD_opencv_objdetect=ON"
+            "-DBUILD_opencv_photo=ON"
+            "-DBUILD_opencv_stitching=ON"
+            "-DBUILD_opencv_video=ON"
+            "-DBUILD_opencv_videoio=ON"
+            "-DBUILD_JAVA=OFF"
+            "-DBUILD_FAT_JAVA_LIB=OFF"
+            "-DBUILD_PNG=ON"
+            "-DBUILD_JPEG=ON"
+            "-DWITH_1394=OFF"
+            "-DWITH_FFMPEG=OFF"
+            "-DWITH_GSTREAMER=OFF"
+            "-DWITH_GTK=OFF"
+            "-DWITH_IPP=OFF"
+            "-DWITH_JASPER=OFF"
+            "-DWITH_OPENEXR=OFF"
+            "-DWITH_ITT=OFF"
+            "-DWITH_OPENEXR=OFF"
+            "-DWITH_WEBP=OFF"
+            "-DWITH_TIFF=OFF")
+
+    append_third_party_passthrough_args(OPENCV_CMAKE_ARGS "${OPENCV_CMAKE_ARGS}")
+
+    # Build project
+    ExternalProject_Add(
+            opencv-external
+            GIT_REPOSITORY "https://github.com/opencv/opencv.git"
+            GIT_TAG "4.1.0"
+            SOURCE_DIR "${BINARY_DIR}/thirdparty/opencv-src"
+            PATCH_COMMAND ${PC}
+            CMAKE_ARGS ${OPENCV_CMAKE_ARGS}
+            BUILD_BYPRODUCTS "${OPENCV_LIBS}"
+            EXCLUDE_FROM_ALL TRUE
+            LIST_SEPARATOR % # This is needed for passing semicolon-separated lists
+    )
+
+    # Set variables
+    set(OPENCV_FOUND "YES" CACHE STRING "" FORCE)
+    if (WIN32)
+        set(OPENCV_INCLUDE_DIR "${OPENCV_BYPRODUCT_DIR}/include" CACHE STRING "" FORCE)
+    else()
+        set(OPENCV_INCLUDE_DIR "${OPENCV_BYPRODUCT_DIR}/include/opencv4" CACHE STRING "" FORCE)
+    endif()
+    set(OPENCV_LIBRARIES "${OPENCV_LIBS}" CACHE STRING "" FORCE)
+
+    # Set exported variables for FindPackage.cmake
+    set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_OPENCV_INCLUDE_DIR=${OPENCV_INCLUDE_DIR}" CACHE STRING "" FORCE)
+    string(REPLACE ";" "%" OPENCV_LIBRARIES_EXPORT "${OPENCV_LIBRARIES}")
+    set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_OPENCV_LIBRARIES=${OPENCV_LIBRARIES_EXPORT}" CACHE STRING "" FORCE)
+    message(${PASSTHROUGH_VARIABLES})

Review comment:
       Please make this message `DEBUG` or remove it. I don't think it helps the user who compiles the project.

##########
File path: cmake/BundledOpenCV.cmake
##########
@@ -0,0 +1,214 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+function(use_bundled_opencv SOURCE_DIR BINARY_DIR)
+    set(PATCH_FILE "${SOURCE_DIR}/thirdparty/opencv/opencv.patch")
+    set(PC "${Patch_EXECUTABLE}" -R -p1 -s -f --dry-run -i "${PATCH_FILE}" || "${Patch_EXECUTABLE}" -p1 -i "${PATCH_FILE}")
+
+    if (WIN32)
+        set(CMAKE_INSTALL_LIBDIR "lib")
+    else()
+        include(GNUInstallDirs)
+    endif()
+
+    # Define byproducts
+    if (WIN32)
+        set(SUFFIX "410.lib")
+        set(THIRDPARTY_SUFFIX ".lib")
+        set(PREFIX "")
+        set(THIRDPARTY_DIR "")
+    else()
+        set(SUFFIX ".a")
+        set(THIRDPARTY_SUFFIX ".a")
+        set(PREFIX "lib")
+        set(THIRDPARTY_DIR "opencv4/3rdparty/")
+    endif()
+
+    set(OPENCV_BYPRODUCT_DIR "${CMAKE_CURRENT_BINARY_DIR}/thirdparty/opencv-install")
+    set(BYPRODUCTS
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_flann${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_dnn${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_objdetect${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_core${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_gapi${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_imgcodecs${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_calib3d${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_imgproc${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_photo${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_videoio${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_video${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_stitching${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_features2d${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${THIRDPARTY_DIR}${PREFIX}libjpeg-turbo${THIRDPARTY_SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${THIRDPARTY_DIR}${PREFIX}libpng${THIRDPARTY_SUFFIX}")
+
+    # Set build options
+    set(OPENCV_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS}

Review comment:
       Could you modify the passthrough arguments to include `-Wno-error -w` (disable warnings as errors and disable warnings altogether, only `-w` might be enough) and the msvc equivalent in CMAKE_C_FLAGS and CMAKE_CXX_FLAGS? I don't think any of us cares about warnings in opencv, or in any third party lib, yet we spam the build output with them.
   
   Not strictly related to this changeset, so it's fine to not do it here if you prefer that way.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] lordgamez commented on a change in pull request #1110: MINIFICPP-994 Move out OpenCV build from cmake configuration

Posted by GitBox <gi...@apache.org>.
lordgamez commented on a change in pull request #1110:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1110#discussion_r671059259



##########
File path: cmake/BundledOpenCV.cmake
##########
@@ -0,0 +1,214 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+function(use_bundled_opencv SOURCE_DIR BINARY_DIR)
+    set(PATCH_FILE "${SOURCE_DIR}/thirdparty/opencv/opencv.patch")
+    set(PC "${Patch_EXECUTABLE}" -R -p1 -s -f --dry-run -i "${PATCH_FILE}" || "${Patch_EXECUTABLE}" -p1 -i "${PATCH_FILE}")
+
+    if (WIN32)
+        set(CMAKE_INSTALL_LIBDIR "lib")
+    else()
+        include(GNUInstallDirs)
+    endif()
+
+    # Define byproducts
+    if (WIN32)
+        set(SUFFIX "410.lib")
+        set(THIRDPARTY_SUFFIX ".lib")
+        set(PREFIX "")
+        set(THIRDPARTY_DIR "")
+    else()
+        set(SUFFIX ".a")
+        set(THIRDPARTY_SUFFIX ".a")
+        set(PREFIX "lib")
+        set(THIRDPARTY_DIR "opencv4/3rdparty/")
+    endif()
+
+    set(OPENCV_BYPRODUCT_DIR "${CMAKE_CURRENT_BINARY_DIR}/thirdparty/opencv-install")
+    set(BYPRODUCTS
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_flann${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_dnn${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_objdetect${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_core${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_gapi${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_imgcodecs${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_calib3d${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_imgproc${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_photo${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_videoio${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_video${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_stitching${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_features2d${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${THIRDPARTY_DIR}${PREFIX}libjpeg-turbo${THIRDPARTY_SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${THIRDPARTY_DIR}${PREFIX}libpng${THIRDPARTY_SUFFIX}")
+
+    # Set build options
+    set(OPENCV_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS}
+            "-DCMAKE_INSTALL_PREFIX=${OPENCV_BYPRODUCT_DIR}"
+            "-DBUILD_SHARED_LIBS=OFF"
+            "-DBUILD_WITH_STATIC_CRT=OFF"
+            "-DBUILD_EXAMPLES=OFF"
+            "-DBUILD_DOCS=OFF"
+            "-DBUILD_PACKAGE=OFF"
+            "-DBUILD_opencv_apps=OFF"
+            "-DBUILD_PERF_TESTS=OFF"
+            "-DBUILD_TESTS=OFF"
+            "-DBUILD_opencv_calib3d=ON"
+            "-DBUILD_opencv_core=ON"
+            "-DBUILD_opencv_dnn=ON"
+            "-DBUILD_opencv_features2d=ON"
+            "-DBUILD_opencv_flann=ON"
+            "-DBUILD_opencv_gapi=ON"
+            "-DBUILD_opencv_highgui=OFF"
+            "-DBUILD_opencv_imgcodecs=ON"
+            "-DBUILD_opencv_imgproc=ON"
+            "-DBUILD_opencv_ml=OFF"
+            "-DBUILD_opencv_objdetect=ON"
+            "-DBUILD_opencv_photo=ON"
+            "-DBUILD_opencv_stitching=ON"
+            "-DBUILD_opencv_video=ON"
+            "-DBUILD_opencv_videoio=ON"
+            "-DBUILD_JAVA=OFF"
+            "-DBUILD_FAT_JAVA_LIB=OFF"
+            "-DBUILD_PNG=ON"
+            "-DBUILD_JPEG=ON"
+            "-DWITH_1394=OFF"
+            "-DWITH_FFMPEG=OFF"
+            "-DWITH_GSTREAMER=OFF"
+            "-DWITH_GTK=OFF"
+            "-DWITH_IPP=OFF"
+            "-DWITH_JASPER=OFF"
+            "-DWITH_OPENEXR=OFF"
+            "-DWITH_ITT=OFF"
+            "-DWITH_OPENEXR=OFF"
+            "-DWITH_WEBP=OFF"
+            "-DWITH_TIFF=OFF")
+
+    append_third_party_passthrough_args(OPENCV_CMAKE_ARGS "${OPENCV_CMAKE_ARGS}")
+
+    # Build project
+    ExternalProject_Add(
+            opencv-external
+            GIT_REPOSITORY "https://github.com/opencv/opencv.git"
+            GIT_TAG "4.1.0"
+            SOURCE_DIR "${BINARY_DIR}/thirdparty/opencv-src"
+            PATCH_COMMAND ${PC}
+            CMAKE_ARGS ${OPENCV_CMAKE_ARGS}
+            BUILD_BYPRODUCTS "${OPENCV_LIBS}"
+            EXCLUDE_FROM_ALL TRUE
+            LIST_SEPARATOR % # This is needed for passing semicolon-separated lists
+    )
+
+    # Set variables
+    set(OPENCV_FOUND "YES" CACHE STRING "" FORCE)
+    if (WIN32)
+        set(OPENCV_INCLUDE_DIR "${OPENCV_BYPRODUCT_DIR}/include" CACHE STRING "" FORCE)
+    else()
+        set(OPENCV_INCLUDE_DIR "${OPENCV_BYPRODUCT_DIR}/include/opencv4" CACHE STRING "" FORCE)
+    endif()
+    set(OPENCV_LIBRARIES "${OPENCV_LIBS}" CACHE STRING "" FORCE)
+
+    # Set exported variables for FindPackage.cmake
+    set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_OPENCV_INCLUDE_DIR=${OPENCV_INCLUDE_DIR}" CACHE STRING "" FORCE)
+    string(REPLACE ";" "%" OPENCV_LIBRARIES_EXPORT "${OPENCV_LIBRARIES}")
+    set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_OPENCV_LIBRARIES=${OPENCV_LIBRARIES_EXPORT}" CACHE STRING "" FORCE)
+    message(${PASSTHROUGH_VARIABLES})

Review comment:
       Thanks, I left i there by accident when debugging, removed in 18fb02160b50f0c461b512e799d835d55b81a6e5

##########
File path: cmake/BundledOpenCV.cmake
##########
@@ -0,0 +1,214 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+function(use_bundled_opencv SOURCE_DIR BINARY_DIR)
+    set(PATCH_FILE "${SOURCE_DIR}/thirdparty/opencv/opencv.patch")
+    set(PC "${Patch_EXECUTABLE}" -R -p1 -s -f --dry-run -i "${PATCH_FILE}" || "${Patch_EXECUTABLE}" -p1 -i "${PATCH_FILE}")
+
+    if (WIN32)
+        set(CMAKE_INSTALL_LIBDIR "lib")
+    else()
+        include(GNUInstallDirs)
+    endif()
+
+    # Define byproducts
+    if (WIN32)
+        set(SUFFIX "410.lib")
+        set(THIRDPARTY_SUFFIX ".lib")
+        set(PREFIX "")
+        set(THIRDPARTY_DIR "")
+    else()
+        set(SUFFIX ".a")
+        set(THIRDPARTY_SUFFIX ".a")
+        set(PREFIX "lib")
+        set(THIRDPARTY_DIR "opencv4/3rdparty/")
+    endif()
+
+    set(OPENCV_BYPRODUCT_DIR "${CMAKE_CURRENT_BINARY_DIR}/thirdparty/opencv-install")
+    set(BYPRODUCTS
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_flann${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_dnn${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_objdetect${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_core${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_gapi${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_imgcodecs${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_calib3d${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_imgproc${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_photo${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_videoio${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_video${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_stitching${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${PREFIX}opencv_features2d${SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${THIRDPARTY_DIR}${PREFIX}libjpeg-turbo${THIRDPARTY_SUFFIX}"
+        "${OPENCV_BYPRODUCT_DIR}/${CMAKE_INSTALL_LIBDIR}/${THIRDPARTY_DIR}${PREFIX}libpng${THIRDPARTY_SUFFIX}")
+
+    # Set build options
+    set(OPENCV_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS}

Review comment:
       Added in 18fb02160b50f0c461b512e799d835d55b81a6e5




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] lordgamez commented on a change in pull request #1110: MINIFICPP-994 Move out OpenCV build from cmake configuration

Posted by GitBox <gi...@apache.org>.
lordgamez commented on a change in pull request #1110:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1110#discussion_r672231758



##########
File path: CMakeLists.txt
##########
@@ -503,6 +517,8 @@ endif()
 ## OpenCV Extensions
 option(ENABLE_OPENCV "Disables the OpenCV extensions." OFF)

Review comment:
       Updated in db9827c54077e213ac5c4f1c4ce871d155c0c40d




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] lordgamez commented on pull request #1110: MINIFICPP-994 Move out OpenCV build from cmake configuration

Posted by GitBox <gi...@apache.org>.
lordgamez commented on pull request #1110:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1110#issuecomment-882657304


   > This PR causes a build issue:
   > 
   > ```
   > + nice -n 19 ninja -v -j64
   > ninja: error: 'thirdparty/opencv-install/lib64/libopencv_flann.a', needed by 'main/minifi', missing and no known rule to make it
   > ```
   > 
   > May or may not happen with GNU Make, I only tried building with Ninja on Linux (with both GCC and Clang) after my merge attempt. Will postpone merging until this is fixed.
   > 
   > My cmake flags:
   > 
   > ```
   > cmake -G Ninja -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DFORCE_COLORED_OUTPUT=ON -DAWS_ENABLE_UNITY_BUILD=OFF -DASAN_BUILD=OFF -DCMAKE_BUILD_TYPE=Debug -DFAIL_ON_WARNINGS=ON -DENABLE_PYTHON=ON -DENABLE_OPS=ON -DENABLE_JNI=OFF -DENABLE_OPC=ON -DENABLE_COAP=ON -DENABLE_GPS=ON -DENABLE_MQTT=ON -DENABLE_LIBRDKAFKA=ON -DENABLE_SENSORS=ON -DENABLE_USB_CAMERA=ON -DENABLE_AWS=OFF -DENABLE_SFTP=ON -DENABLE_OPENWSMAN=ON -DENABLE_BUSTACHE=ON -DENABLE_OPENCV=ON -DENABLE_TENSORFLOW=OFF -DENABLE_SQL=OFF -DENABLE_PCAP=OFF -DENABLE_NANOFI=ON -DENABLE_SYSTEMD=ON ..
   > ```
   > 
   > Same for clang, except substitute gcc with clang and g++ with clang++.
   > 
   > These are the exact scripts I use to test builds: https://github.com/szaszm/verify-nifi-release/tree/master/bin
   
   Thanks for all the info! There was an error in the cmake file, the wrong variable was passed to the build byproduct parameter. It worked fine with Make, but ninja fails without defining the byproducts beforehand. I fixed the issue in f0ab4c23ec482140065bd51a13b71eaa98900f71


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] szaszm closed pull request #1110: MINIFICPP-994 Move out OpenCV build from cmake configuration

Posted by GitBox <gi...@apache.org>.
szaszm closed pull request #1110:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1110


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] fgerlits commented on a change in pull request #1110: MINIFICPP-994 Move out OpenCV build from cmake configuration

Posted by GitBox <gi...@apache.org>.
fgerlits commented on a change in pull request #1110:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1110#discussion_r671306945



##########
File path: CMakeLists.txt
##########
@@ -503,6 +517,8 @@ endif()
 ## OpenCV Extensions
 option(ENABLE_OPENCV "Disables the OpenCV extensions." OFF)
 if (ENABLE_OPENCV)
+	include(BundledOpenCV)
+	use_bundled_opencv(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
 	createExtension(OPENCV-EXTENSIONS "OPENCV EXTENSIONS" "This enabled OpenCV support" "extensions/opencv" "extensions/opencv/tests")

Review comment:
       ```suggestion
   	createExtension(OPENCV-EXTENSIONS "OPENCV EXTENSIONS" "This enables OpenCV support" "extensions/opencv" "extensions/opencv/tests")
   ```

##########
File path: CMakeLists.txt
##########
@@ -503,6 +517,8 @@ endif()
 ## OpenCV Extensions
 option(ENABLE_OPENCV "Disables the OpenCV extensions." OFF)

Review comment:
       Old stuff and not important, but this should be "Enables ..."




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] szaszm closed pull request #1110: MINIFICPP-994 Move out OpenCV build from cmake configuration

Posted by GitBox <gi...@apache.org>.
szaszm closed pull request #1110:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1110


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] lordgamez commented on pull request #1110: MINIFICPP-994 Move out OpenCV build from cmake configuration

Posted by GitBox <gi...@apache.org>.
lordgamez commented on pull request #1110:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1110#issuecomment-882657304


   > This PR causes a build issue:
   > 
   > ```
   > + nice -n 19 ninja -v -j64
   > ninja: error: 'thirdparty/opencv-install/lib64/libopencv_flann.a', needed by 'main/minifi', missing and no known rule to make it
   > ```
   > 
   > May or may not happen with GNU Make, I only tried building with Ninja on Linux (with both GCC and Clang) after my merge attempt. Will postpone merging until this is fixed.
   > 
   > My cmake flags:
   > 
   > ```
   > cmake -G Ninja -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DFORCE_COLORED_OUTPUT=ON -DAWS_ENABLE_UNITY_BUILD=OFF -DASAN_BUILD=OFF -DCMAKE_BUILD_TYPE=Debug -DFAIL_ON_WARNINGS=ON -DENABLE_PYTHON=ON -DENABLE_OPS=ON -DENABLE_JNI=OFF -DENABLE_OPC=ON -DENABLE_COAP=ON -DENABLE_GPS=ON -DENABLE_MQTT=ON -DENABLE_LIBRDKAFKA=ON -DENABLE_SENSORS=ON -DENABLE_USB_CAMERA=ON -DENABLE_AWS=OFF -DENABLE_SFTP=ON -DENABLE_OPENWSMAN=ON -DENABLE_BUSTACHE=ON -DENABLE_OPENCV=ON -DENABLE_TENSORFLOW=OFF -DENABLE_SQL=OFF -DENABLE_PCAP=OFF -DENABLE_NANOFI=ON -DENABLE_SYSTEMD=ON ..
   > ```
   > 
   > Same for clang, except substitute gcc with clang and g++ with clang++.
   > 
   > These are the exact scripts I use to test builds: https://github.com/szaszm/verify-nifi-release/tree/master/bin
   
   Thanks for all the info! There was an error in the cmake file, the wrong variable was passed to the build byproduct parameter. It worked fine with Make, but ninja fails without defining the byproducts beforehand. I fixed the issue in f0ab4c23ec482140065bd51a13b71eaa98900f71


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org