Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: update install paths (Linux) #12401

Merged
merged 1 commit into from Sep 19, 2018

Conversation

alalek
Copy link
Member

@alalek alalek commented Sep 3, 2018

Improve support for side-by-side installations (multiple major versions).
Improve conformance with Linux/GNU installation layout.

Details:

  • includes have one extra level: /usr/include/opencv4/ (no changes in applications are required if CMake is used).
  • CMake config is moved into "lib". It is incorrect to place it in "share" directory due direct paths to binaries.
  • changed paths for "doc", "licenses", "java"
  • use "opencv4" by default (except "lib" - no "opencv" in path)
  • pkg-config file is renamed to opencv4.pc
  • use lower-case "opencv" in paths

All paths are still configurable.

**WIP**
force_builders=linux,docs
test_modules=core
build_contrib:iOS=ON

@mshabunin
Copy link
Contributor

Maybe we should break #include compatibility. It does not look good: <ROOT>/include/opencv4/opencv2/core.hpp

@alalek
Copy link
Member Author

alalek commented Sep 10, 2018

"opencv4" will not be used in source codes. Users still using "opencv2/core.hpp" (no any changes are required if using CMake)

opencv4/opencv2/core.hpp

Right.
Currently I'm working on "proxy" headers in "opencv" directory (include/opencv4/opencv/core.hpp): #12481
Currently they would just include "../opencv2/core.hpp" (relative path is required, just "opencv2/core.hpp" doesn't work due installations of OpenCV with other versions 2.4/3.x into system paths).

This will allow smooth transition from "opencv2". Both lines would have the same effect:

#include <opencv2/core.hpp>
#include <opencv/core.hpp>

@opencv-pushbot opencv-pushbot merged commit a956732 into opencv:master Sep 19, 2018
@Unarmed1000
Copy link

Is the impact of this change documented anywhere for code not using cmake?
How can it be disabled so the headers install to their normal old location?

Is the recommended solution to do a "ln -s /usr/local/include/opencv4/opencv2/ /usr/local/include/opencv2"?

We normally create docker images for building inside so being able to have side-by-side installations is not something that we want to take advantage of and it appears to break all existing software that doesnt use cmake for building as the include path changed and there is no desire for us to update all our build files with a new include path for no good reason.

I tried looking at the documentation but did not find the 'breaking' change mentioned anywhere but maybe I missed it. I found multiple people that resorted to the "ln" solution which is why I wanted to ask if its the recommended way to deal with this.

@alalek
Copy link
Member Author

alalek commented Jan 12, 2019

Recommended way is using of CMake's find_package(OpenCV ...).

@Unarmed1000
Copy link

I asked what is the recommended way for people not using cmake.

@sergiomb2
Copy link
Contributor

this commit a956732
for me is a disaster , why opencv.pc change to opencv4.pc ?

@mshabunin
Copy link
Contributor

@sergiomb2 , set the OPENCV_PC_FILE_NAME option to whatever you need.

@sergiomb2
Copy link
Contributor

thank you for reply mshabunin

after move opencv4.pc to opencv.pc if not packages aren't found .
gmic don't compile (with opencv-4.1) [1] with :
CImg.h:424:10: fatal error: opencv2/opencv.hpp: No such file or directory

nomacs don't complie [3] with error: 'CV_DIST_C' was not declared in this scope , was C API deleted ?
https://docs.opencv.org/4.1.0/df/d4e/group__imgproc__c.html is a clean page

Thanks I have to go now

[1]
https://copr-be.cloud.fedoraproject.org/results/sergiomb/opencv/fedora-28-x86_64/00912676-gmic/build.log.gz
https://copr-be.cloud.fedoraproject.org/results/sergiomb/opencv/fedora-28-x86_64/00912676-gmic/

[3]
https://copr-be.cloud.fedoraproject.org/results/sergiomb/opencv/fedora-rawhide-x86_64/00912674-nomacs/build.log.gz
https://copr-be.cloud.fedoraproject.org/results/sergiomb/opencv/fedora-28-x86_64/00912676-gmic/

@mshabunin
Copy link
Contributor

mshabunin commented May 21, 2019

C-API was not deleted yet, but all inclusions have been removed from default headers, so now one needs to directly include "opencv2/imgproc/types_c.h" and other *_c.h headers:

CV_DIST_C =3, /**< distance = max(|x1-x2|,|y1-y2|) */

Not sure why opencv.pc was not found by gmic, I can see /usr/lib64/pkgconfig/opencv.pc file in the opencv-devel.rpm and I don't know why it can not be found by pkg-config.

I've found gmic/src/Makefile contains block:

# Enable native support of webcams and video streaming, using the OpenCV library.
# (https://opencv.org/)
OPENCV_CFLAGS = -Dcimg_use_opencv $(shell pkg-config opencv --cflags || echo -I/usr/include/opencv) -I/usr/include/opencv
OPENCV_LIBS = $(shell pkg-config opencv --libs || echo -lopencv_core -lopencv_highgui)

which adds wrong compiler options: -Dcimg_use_opencv -I/usr/include/opencv -I/usr/include/opencv

While gmic/CMakeLists.txt has better block:

if(ENABLE_OPENCV)
  pkg_check_modules(OPENCV opencv)
endif()
if(OPENCV_FOUND)
  set(CLI_COMPILE_FLAGS "${CLI_COMPILE_FLAGS} -Dcimg_use_opencv")
  include_directories(${OPENCV_INCLUDE_DIRS})
  link_directories(${OPENCV_LIBRARY_DIRS})
endif()

which should work correctly if OpenCV can not be found.

Is it possible to build gmic using cmake? Where should all .pc files be located on Fedora?

@alalek
Copy link
Member Author

alalek commented May 21, 2019

C API (from OpenCV 1.0) has been deprecated since OpenCV 2.4. It is not tested for years with C compiler.

Mentioned headers keep legacy C API constants only (for apps which are not migrated on C++ enums for some reasons).

Some part of legacy C API functions are gone (left functions/structures will be removed without notice during future OpenCV 4.x releases).

More info/links about C API is here: #11000


opencv2/opencv.hpp

This all-in-one header is deprecated.
Consider using headers of OpenCV modules directly:

#include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants