Bug 1070428

Summary: OpenCVConfig.cmake gives incorrect OpenCV_INSTALL_PATH & OpenCV_INCLUDE_DIRS
Product: [Fedora] Fedora Reporter: Rok Mandeljc <rok.mandeljc>
Component: opencvAssignee: Rex Dieter <rdieter>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 20CC: hhorak, i, jmlich, karlthered, kwizart, logans, markku.kolkka, nomis80, rdieter
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: opencv-2.4.7-6.fc20 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-05-06 03:34:26 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Rok Mandeljc 2014-02-26 20:00:44 UTC
Description of problem:
-----------------------

The OpenCVConfig.cmake shipped by RPM appears to incorrectly determine OpenCV_INSTALL_PATH, and consequently OpenCV_INCLUDE_DIRS. This results in compilation error of code that uses old-style headers, i.e. #include <cv.h>.

The issue appears to be caused by opencv-pkgcmake2.patch that was introduced to fix #838125, which is exactly the opposite of the problem I am seeing (maybe something changed with recent OpenCV versions?).

Stock OpenCV's OpenCVConfig.cmake sets OpenCV_INSTALL_PATH to "${OpenCV_CONFIG_PATH}/../..", whereas the said patch causes it to be set to 
"${OpenCV_CONFIG_PATH}/../../..". Since OpenCV_CONFIG_PATH is determined by location of the OpenCVConfig.cmake, which is in /usr/lib64/OpenCV/, going three levels up lands us in /, and incorrectly sets include dir to //include and //include/opencv.


Version-Release number of selected component (if applicable):
-------------------------------------------------------------
opencv-2.4.7-2.fc20

How reproducible:
-----------------

Try building any code that uses old-style OpenCV includes, for example, bgslibrary.

Steps to Reproduce:
-------------------
1. use the following minimal example:

--- main.cpp ---
#include <cv.h>

int main (int argc, char **argv)
{
    return 0;
}
---------------
--- CMakeLists.txt ---
cmake_minimum_required(VERSION 2.8)
project(bgs)
find_package(OpenCV REQUIRED)

add_executable(test main.cpp)
target_link_libraries(test ${OpenCV_LIBS})
----------------------

2. mkdir build && cd build
3. cmake ..
4. make VERBOSE=1

Actual results:
---------------

[rok@alpha build]$ make VERBOSE=1
/usr/bin/cmake -H/home/rok/test -B/home/rok/test/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/rok/test/build/CMakeFiles /home/rok/test/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/home/rok/test/build'
make -f CMakeFiles/test.dir/build.make CMakeFiles/test.dir/depend
make[2]: Entering directory `/home/rok/test/build'
cd /home/rok/test/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/rok/test /home/rok/test /home/rok/test/build /home/rok/test/build /home/rok/test/build/CMakeFiles/test.dir/DependInfo.cmake --color=
Dependee "/home/rok/test/build/CMakeFiles/test.dir/DependInfo.cmake" is newer than depender "/home/rok/test/build/CMakeFiles/test.dir/depend.internal".
Dependee "/home/rok/test/build/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "/home/rok/test/build/CMakeFiles/test.dir/depend.internal".
Scanning dependencies of target test
make[2]: Leaving directory `/home/rok/test/build'
make -f CMakeFiles/test.dir/build.make CMakeFiles/test.dir/build
make[2]: Entering directory `/home/rok/test/build'
/usr/bin/cmake -E cmake_progress_report /home/rok/test/build/CMakeFiles 1
[100%] Building CXX object CMakeFiles/test.dir/main.cpp.o
/usr/lib64/ccache/c++    -I//include/opencv -I//include    -o CMakeFiles/test.dir/main.cpp.o -c /home/rok/test/main.cpp
/home/rok/test/main.cpp:1:16: fatal error: cv.h: No such file or directory
 #include <cv.h>
                ^
compilation terminated.
make[2]: *** [CMakeFiles/test.dir/main.cpp.o] Error 1
make[2]: Leaving directory `/home/rok/test/build'
make[1]: *** [CMakeFiles/test.dir/all] Error 2
make[1]: Leaving directory `/home/rok/test/build'
make: *** [all] Error 2



Expected results (obtained by reverting opencv-pkgcmake2.patch):
----------------------------------------------------------------

[rok@alpha build]$ make VERBOSE=1
/usr/bin/cmake -H/home/rok/test -B/home/rok/test/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/rok/test/build/CMakeFiles /home/rok/test/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/home/rok/test/build'
make -f CMakeFiles/test.dir/build.make CMakeFiles/test.dir/depend
make[2]: Entering directory `/home/rok/test/build'
cd /home/rok/test/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/rok/test /home/rok/test /home/rok/test/build /home/rok/test/build /home/rok/test/build/CMakeFiles/test.dir/DependInfo.cmake --color=
Dependee "/home/rok/test/build/CMakeFiles/test.dir/DependInfo.cmake" is newer than depender "/home/rok/test/build/CMakeFiles/test.dir/depend.internal".
Dependee "/home/rok/test/build/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "/home/rok/test/build/CMakeFiles/test.dir/depend.internal".
Scanning dependencies of target test
make[2]: Leaving directory `/home/rok/test/build'
make -f CMakeFiles/test.dir/build.make CMakeFiles/test.dir/build
make[2]: Entering directory `/home/rok/test/build'
/usr/bin/cmake -E cmake_progress_report /home/rok/test/build/CMakeFiles 1
[100%] Building CXX object CMakeFiles/test.dir/main.cpp.o
/usr/lib64/ccache/c++    -I/usr/include/opencv    -o CMakeFiles/test.dir/main.cpp.o -c /home/rok/test/main.cpp
Linking CXX executable test
/usr/bin/cmake -E cmake_link_script CMakeFiles/test.dir/link.txt --verbose=1
/usr/lib64/ccache/c++       CMakeFiles/test.dir/main.cpp.o  -o test -rdynamic /usr/lib64/libopencv_videostab.so.2.4.7 /usr/lib64/libopencv_video.so.2.4.7 /usr/lib64/libopencv_ts.so.2.4.7 /usr/lib64/libopencv_superres.so.2.4.7 /usr/lib64/libopencv_stitching.so.2.4.7 /usr/lib64/libopencv_photo.so.2.4.7 /usr/lib64/libopencv_objdetect.so.2.4.7 /usr/lib64/libopencv_ml.so.2.4.7 /usr/lib64/libopencv_legacy.so.2.4.7 /usr/lib64/libopencv_imgproc.so.2.4.7 /usr/lib64/libopencv_highgui.so.2.4.7 /usr/lib64/libopencv_flann.so.2.4.7 /usr/lib64/libopencv_features2d.so.2.4.7 /usr/lib64/libopencv_core.so.2.4.7 /usr/lib64/libopencv_contrib.so.2.4.7 /usr/lib64/libopencv_calib3d.so.2.4.7 /usr/lib64/libopencv_video.so.2.4.7 /usr/lib64/libopencv_objdetect.so.2.4.7 /usr/lib64/libopencv_ml.so.2.4.7 /usr/lib64/libopencv_features2d.so.2.4.7 /usr/lib64/libopencv_highgui.so.2.4.7 /usr/lib64/libopencv_imgproc.so.2.4.7 /usr/lib64/libopencv_flann.so.2.4.7 /usr/lib64/libopencv_core.so.2.4.7 
make[2]: Leaving directory `/home/rok/test/build'
/usr/bin/cmake -E cmake_progress_report /home/rok/test/build/CMakeFiles  1
[100%] Built target test
make[1]: Leaving directory `/home/rok/test/build'
/usr/bin/cmake -E cmake_progress_start /home/rok/test/build/CMakeFiles 0

Comment 1 Nicolas Chauvet (kwizart) 2014-02-26 20:05:36 UTC
-I//include/opencv should have been -I/usr/include/opencv.
But patch welcomed, I don't plan to work on this issue that do not affects the case I know. (I'm using opencv.pc).

Comment 2 Rok Mandeljc 2014-02-26 20:11:54 UTC
The problem is caused by opencv-pkgcmake2.patch used by fedora's RPM - can you please check if it is still necessary?

Comment 3 Nicolas Chauvet (kwizart) 2014-02-27 22:15:57 UTC
You can make a test build and verify that all the dependent packages rebuilt fine. (You should use mock)

Comment 4 Rok Mandeljc 2014-03-09 20:56:36 UTC
Ok, I did the test re-build with opencv-2.4.7-6.fc20.src.rpm, which is same as opencv-2.4.7-5.fc21.src.rpm from Koji, except that it does not enable opencv-pkgcmake2.patch.

The list of packages to rebuild was obtained by 'repoquery --whatrequires opencv ', and then I got the corresponding SRPMs from Koji and rebuilt them using the following:

mock -r fedora-20-x86_64 --init
mock -r fedora-20-x86_64 --no-clean --verbose --rebuild ./opencv-2.4.7-6.fc20.src.rpm
mock -r fedora-20-x86_64 --no-clean --install /var/lib/mock/fedora-20-x86_64/result/opencv-python-2.4.7-6.fc20.x86_64.rpm /var/lib/mock/fedora-20-x86_64/result/opencv-devel-2.4.7-6.fc20.x86_64.rpm /var/lib/mock/fedora-20-x86_64/result/opencv-core-2.4.7-6.fc20.x86_64.rpm /var/lib/mock/fedora-20-x86_64/result/opencv-2.4.7-6.fc20.x86_64.rpm
mock -r fedora-20-x86_64 --no-clean --verbose --rebuild ./${SRPM}

Is this the procedure you had in mind, or is there a way to rebuild all dependent packages automatically?


Using the above procedure, all the packages rebuilt without errors when pkgcmake2.patch was removed (whereas, in fact, simon fails to build WITH it):

digikam-0:3.5.0-1.fc20.x86_64
digikam-0:3.5.0-4.fc20.x86_64
digikam-libs-0:3.5.0-1.fc20.i686
digikam-libs-0:3.5.0-1.fc20.x86_64
digikam-libs-0:3.5.0-4.fc20.i686
digikam-libs-0:3.5.0-4.fc20.x86_64
kipi-plugins-0:3.5.0-1.fc20.x86_64
kipi-plugins-0:3.5.0-4.fc20.x86_64
libkface-0:3.5.0-1.fc20.i686
libkface-0:3.5.0-1.fc20.x86_64
libkface-0:3.5.0-4.fc20.i686
libkface-0:3.5.0-4.fc20.x86_64
=> SRPM: digikam-3.5.0-4.fc20.src.rpm
=> comment: uses #include <opencv/cv.h>

fawkes-firevision-0:0.5.0-13.fc20.i686
fawkes-firevision-0:0.5.0-13.fc20.x86_64
=> SRPM: fawkes-0.5.0-13.fc20.src.rpm
=> comment: uses #include <opencv/cv.h>

freemedforms-emr-0:0.9.0-0.1.beta1.fc20.x86_64
=> SRPM: freemedforms-0.9.0-0.1.beta1.fc20.src.rpm 
=> comment: uses #include <opencv2/core/core.hpp>, etc.

frei0r-plugins-opencv-0:1.3-11.fc20.x86_64
frei0r-plugins-opencv-0:1.4-1.fc20.x86_64
=> SRPM: frei0r-plugins-1.4-1.fc20.src.rpm
=> comment: uses #include <opencv/cv.h>

libfreenect-opencv-0:0.1.2-6.fc20.i686
libfreenect-opencv-0:0.1.2-6.fc20.x86_64
=> SRPM: libfreenect-0.1.2-6.fc20.src.rpm
=> comment: uses #include <opencv/cv.h>

mrpt-apps-0:1.0.2-1.fc20.x86_64
mrpt-base-0:1.0.2-1.fc20.i686
mrpt-base-0:1.0.2-1.fc20.x86_64
mrpt-detectors-0:1.0.2-1.fc20.i686
mrpt-detectors-0:1.0.2-1.fc20.x86_64
mrpt-gui-0:1.0.2-1.fc20.i686
mrpt-gui-0:1.0.2-1.fc20.x86_64
mrpt-hmtslam-0:1.0.2-1.fc20.i686
mrpt-hmtslam-0:1.0.2-1.fc20.x86_64
mrpt-hwdrivers-0:1.0.2-1.fc20.i686
mrpt-hwdrivers-0:1.0.2-1.fc20.x86_64
mrpt-kinematics-0:1.0.2-1.fc20.i686
mrpt-kinematics-0:1.0.2-1.fc20.x86_64
mrpt-maps-0:1.0.2-1.fc20.i686
mrpt-maps-0:1.0.2-1.fc20.x86_64
mrpt-obs-0:1.0.2-1.fc20.i686
mrpt-obs-0:1.0.2-1.fc20.x86_64
mrpt-opengl-0:1.0.2-1.fc20.i686
mrpt-opengl-0:1.0.2-1.fc20.x86_64
mrpt-pbmap-0:1.0.2-1.fc20.i686
mrpt-pbmap-0:1.0.2-1.fc20.x86_64
mrpt-reactivenav-0:1.0.2-1.fc20.i686
mrpt-reactivenav-0:1.0.2-1.fc20.x86_64
mrpt-scanmatching-0:1.0.2-1.fc20.i686
mrpt-scanmatching-0:1.0.2-1.fc20.x86_64
mrpt-slam-0:1.0.2-1.fc20.i686
mrpt-slam-0:1.0.2-1.fc20.x86_64
mrpt-topography-0:1.0.2-1.fc20.i686
mrpt-topography-0:1.0.2-1.fc20.x86_64
mrpt-vision-0:1.0.2-1.fc20.i686
mrpt-vision-0:1.0.2-1.fc20.x86_64
=> SRPM: mrpt-1.0.2-1.fc20.src.rpm
=> comment: uses #include <cv.h>, but seems to bring its own FindOpenCV

nomacs-0:1.6.0.2-1.fc20.x86_64
nomacs-0:1.6.4-1.fc20.x86_64
=> SRPM: nomacs-1.6.4-1.fc20.src.rpm
=> comment: uses either #include "opencv/cv.h" or #include "opencv2/core/core.hpp", etc.

opencfu-0:3.8.11-1.fc20.x86_64
=> SRPM: opencfu-3.8.11-1.fc20.src.rpm
=> comment: uses #include "opencv2/core/core.hpp"

opencv-devel-0:2.4.6.1-1.fc20.i686
opencv-devel-0:2.4.6.1-1.fc20.x86_64
opencv-devel-0:2.4.7-2.fc20.i686
opencv-devel-0:2.4.7-2.fc20.x86_64
opencv-python-0:2.4.6.1-1.fc20.x86_64
opencv-python-0:2.4.7-2.fc20.x86_64
=> SRPM: opencv-2.4.7-6.fc20.src.rpm
=> comment: the modified package

php-facedetect-0:1.0.1-10.fc20.x86_64
=> SRPM: php-facedetect-1.0.1-10.fc20.src.rpm
=> comment: uses #include <opencv/cv.h>

player-0:3.0.2-34.fc20.i686
player-0:3.0.2-34.fc20.x86_64
=> SRPM: player-3.0.2-34.fc20.src.rpm
=> comment: uses #include <cv.h>; but uses pkg-config

simarrange-0:0.0-1.20131019gitd52382f.fc20.x86_64
=> SRPM: simarrange-0.0-1.20131019gitd52382f.fc20.src.rpm
=> comment: uses #include <opencv/cv.h>

simon-0:0.4.1-1.fc20.x86_64
simon-libs-0:0.4.1-1.fc20.i686
simon-libs-0:0.4.1-1.fc20.x86_64
=> SRPM: simon-0.4.1-1.fc20.src.rpm
=> comment: uses #include <cv.h>; works without pkgcmake2.patch, whereas with it, it fails with the same symptoms as described in initial report.

vlc-extras-0:2.1.2-1.fc20.i686
vlc-extras-0:2.1.2-1.fc20.x86_64
vlc-extras-0:2.1.4-1.fc20.x86_64
=> SRPM: vlc-2.1.4-1.fc20.src.rpm (rpmfusion)
=> uses #include <cv.h>; but uses pkg-config


Basically, most of the packages are not affected one way or the other, because:
- either they use "#include <opencv/*.h>" or "#include <opencv2/*/*.h>", and therefore -I/usr/include is automatically sufficient
- or they use "#include <cv.h>", but obtain the include path via pkg-config, which is not affected by pkgcmake2.patch

Comment 5 Scott K Logan 2014-04-27 00:00:47 UTC
This is a regression caused by http://pkgs.fedoraproject.org/cgit/opencv.git/commit/?id=85dcc3a0ce55e5781fc670381996af2b43b38e8d (cc Rex)

I just took a look at the patch, and I think completely removing pkgcmake2.patch will solve the problem entirely.

The current cmake reports two invalid directories, and no valid ones. After the patch is removed, both directories are valid, so I can't see any possibility for regression.

Please remove the patch and push a release ASAP. This is a simple bug with a straightforward solution.

Comment 6 Rex Dieter 2014-04-27 02:03:04 UTC
OK, let's give that plan a whirl,
http://koji.fedoraproject.org/koji/taskinfo?taskID=6785205

Comment 7 Fedora Update System 2014-05-01 14:33:29 UTC
opencv-2.4.7-6.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/opencv-2.4.7-6.fc20

Comment 8 Fedora Update System 2014-05-01 22:22:18 UTC
Package opencv-2.4.7-6.fc20:
* should fix your issue,
* was pushed to the Fedora 20 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing opencv-2.4.7-6.fc20'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2014-5882/opencv-2.4.7-6.fc20
then log in and leave karma (feedback).

Comment 9 Fedora Update System 2014-05-06 03:34:26 UTC
opencv-2.4.7-6.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.