Why were cmake options invalid? How can I disable OpenCL, IPP and enable CV_SIMD?
I was working on Canny Edge Detector. After reading the source code, I felt like the edge detector could work in one way among IPP/OPENCL/OPENVX/CV_SIMD(which uses, TBB, I think)/the most traditional and slowest way(to work on pixels one by one). However, I only wanted it parallelCanny with CV_SIMD defined to work.
I tried to call canny function and use "std::cout << cv::getBuildInformation() << std::endl;" to see the libraries being used in the process. Then, I wrote a short CMakeLists.txt file in this way:
# project name
PROJECT(opencv_test)
# requirement of cmake version
cmake_minimum_required(VERSION 3.9)
add_compile_options(-std=c++17)
# find required opencv
find_package(OpenCV REQUIRED)
# name of executable file and path of source file
add_executable(opencv_test main.cpp)
# opencv libraries
target_link_libraries(opencv_test ${OpenCV_LIBS})
After that, I ran the program with the following command in order:
cmake -D WITH_OPENCL=OFF -D WITH_IPP=OFF -D WITH_TBB=OFF -D WITH_OPENMP=ON .
make
opencv_test
Only to be told that:
CMake Warning:
Manually-specified variables were not used by the project:
WITH_IPP
WITH_OPENCL
WITH_OPENMP
WITH_TBB
Then, after my program ran, the line of code
std::cout << cv::getBuildInformation() << std::endl;
printed out exactly the same things as I ran cmake command without any options as follows (I also wrote another function to check if CV_SIMD is enabled):
================== macro dump ===================
CV_SIMD is NOT defined
SIMD intrinsics are not available. Check compilation target and passed build options.
===================== done ======================
General configuration for OpenCV 4.1.1 =====================================
Version control: unknown
Extra modules:
Location (extra): /tmp/opencv-20190826-34514-r5q5gz/opencv-4.1.1/opencv_contrib/modules
Version control (extra): unknown
Platform:
Timestamp: 2019-08-26T13:40:01Z
Host: Darwin 18.6.0 x86_64
CMake: 3.15.2
CMake generator: Unix Makefiles
CMake build tool: /usr/local/Homebrew/Library/Homebrew/shims/mac/super/gmake
Configuration: Release
CPU/HW features:
Baseline: SSE SSE2 SSE3 SSSE3 SSE4_1 POPCNT SSE4_2
requested: DETECT
disabled: AVX AVX2
Dispatched code generation: FP16 AVX AVX2 AVX512_SKX
requested: SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
FP16 (0 files): + FP16 AVX
AVX (4 files): + AVX
AVX2 (27 files): + FP16 FMA3 AVX AVX2
AVX512_SKX (2 files): + FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX
C/C++:
Built as dynamic libs?: YES
C++ Compiler: /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang++ (ver 10.0.1.10010046)
C++ flags (Release): -I/Library/Java/JavaVirtualMachines/adoptopenjdk-12.0.1.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/adoptopenjdk-12.0.1.jdk/Contents/Home/include/darwin -fsigned-char -W -Wall
Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -DNDEBUG -DNDEBUG
C++ flags (Debug): -I/Library/Java/JavaVirtualMachines/adoptopenjdk-12.0.1.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/adoptopenjdk-12.0.1.jdk/Contents/Home/include/darwin -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body ...