Skip to content

[OpenCV] patches for v3.4.0, use vcpkg external libraries, many static triplet fixes, opt-out from ninja parallel configure#2764

Closed
cenit wants to merge 27 commits intomicrosoft:masterfrom
cenit:master
Closed

[OpenCV] patches for v3.4.0, use vcpkg external libraries, many static triplet fixes, opt-out from ninja parallel configure#2764
cenit wants to merge 27 commits intomicrosoft:masterfrom
cenit:master

Conversation

@cenit
Copy link
Copy Markdown
Contributor

@cenit cenit commented Feb 9, 2018

Trying to use OpenCV from vcpkg, I encountered few problems, which have been fixed with this PR (I also cleaned up the commmit history before editing this message, removing unnecessary tests):

  • patchset not updated for OpenCV 3.4.0 (everything from 3.3.0 should be correctly ported over)
  • random failures in opencv_contrib vgg files downloaded on the fly (ninja parallel configuring was messing with downloading files on the fly, OpenCV now opts-out of this new mechanism)
  • static triplets not working
  • move "contrib" to features package
  • do not use integrated ffmpeg and use vcpkg's one, in order to be able to build static libs and to better integrate with the system
  • do not use integrated jpeg library (required a small patch also in libjpeg-turbo)
  • do not use integrated jasper library (required a small patch also in jasper)
  • do not use integrated webp library
  • do not use integrated openexr library (required a patch also in openexr/ilmbase)
  • do not use integrated tiff library also for static builds

As a byproduct, now OpenCV build is much, much faster (counted in minutes instead of hours on my machine) and also the downloads on the fly are reduced to a very minimum (hope they go to zero)

There was also the request to move "pcl" to features package, but I need more info on this @patrikhuber

@cenit cenit changed the title [WIP] OpenCV patch rework, static triplet fixes [OpenCV] patches for v3.4.0, static triplet fixes, opt-out from ninja parallel configure Feb 11, 2018
@lijgame
Copy link
Copy Markdown
Contributor

lijgame commented Feb 13, 2018

Thanks.
I tried this patch, it works for OpenCV[core].
OpenCV[cuda] is still broken.

But this works for me, appreciate it!

--update:
I can install OpenCV successfully, but it got some errors when include OpenCV in CMake projects.
There are some path error in openCVConfig.cmake/OpenCVModules-debug/OpenCVModules-release.cmake files.
Not sure if they are related to this patch though.

@cenit
Copy link
Copy Markdown
Contributor Author

cenit commented Feb 13, 2018

could you please tell me more? I have a sample build project which worked ok....
I will try to work on this patch more to be sure that also OpenCV[ffmpeg] work...

@patrikhuber
Copy link
Copy Markdown
Contributor

I'm also getting multiple Applying patch failed. errors when installing the latest OpenCV (3.4.0) from vcpkg.

@patrikhuber
Copy link
Copy Markdown
Contributor

patrikhuber commented Feb 14, 2018

Maybe @jasjuang can help as well, he updated from 3.3 to 3.4 which broke the patches.

@cenit
Copy link
Copy Markdown
Contributor Author

cenit commented Feb 14, 2018

This PR fixes that problem. I am collecting problems if you have any. I will work on opencv[ffmpeg] also soon, because I need it.

@cenit
Copy link
Copy Markdown
Contributor Author

cenit commented Feb 14, 2018

I also discussed about that patch (accepted too quickly imho) here #2762
The curated collection should avoid these problems, but it already happened more than once here with opencv, breaking suddenly the port. The idea is to test ports and not point to head of master because of that...

@patrikhuber
Copy link
Copy Markdown
Contributor

patrikhuber commented Feb 14, 2018

I will work on opencv[ffmpeg] also soon, because I need it.

What do you mean with that - does it not work for you? I had problems with it (see #2613) but since @ras0219-msft can't reproduce them, I am just trying again now to see whether it's a local problem or one with the vcpkg port.

What do you think about #2794?

Thank you very much for your work @cenit.
OpenCV is a particularly difficult package (almost like boost ;-) ) but used quite widely, and it would be nice to have timely updates in vcpkg, which is one of the main points of a package manager like this. Otherwise I'll have to build it myself again which defeats the purpose of vcpkg. And since vcpkg requires to set the CMAKE TOOLCHAIN file, it also makes it hard to use vcpkg for some packages, but use a local install for other packages.
The difficulty of the OpenCV package probably means it needs someone quite familiar with vcpkg (e.g. from upstream) to help maintaining it, to also make sure it doesn't break again, which I agree with you sucks :\

@cenit
Copy link
Copy Markdown
Contributor Author

cenit commented Feb 14, 2018

It just means that I have not tested OpenCV[ffmpeg] for now, so I don't want to say that it's working without having tried it!

@cenit
Copy link
Copy Markdown
Contributor Author

cenit commented Feb 14, 2018

I can try to exploit feature packages and extract OpenCV-contrib and protobuf, #2794 is a good idea. Unfortunately my time is really constrained now, but since I need this package working (my time spent fixing it would be much more reasonable than any time spent manually installing on many system the library) I will find some time to fix it. If you want access to my repo to contribute to it (automatically only maintainers, so MSFT's Robert and Alex, have it), please let me know so that I can add you manually

@patrikhuber
Copy link
Copy Markdown
Contributor

Ok, cool! Looking forward to the changes. :-) In my opinion, OpenCV-contrib should never have been part of the "default" OpenCV package in vcpkg in the first place.

Regarding ffmpeg, we solved #2613, and isolated the problem, for which I've created a new issue: #2799.

@jasjuang
Copy link
Copy Markdown
Contributor

One thing to point out first, in the usage include_directories(${OpenCV_INCLUDE_DIRS}) is redundant, as ${OpenCV_LIBS} are targets not plain library names.

It seems that you remove the patches I did earlier, which might be the cause of the path issues that @lijgame is seeing. I will test out this PR later.

@ras0219-msft
Copy link
Copy Markdown
Contributor

random failures in opencv_contrib vgg files downloaded on the fly (ninja parallel configuring was messing with downloading files on the fly, OpenCV now opts-out of this new mechanism)

If OpenCV needs more files, we should do the download ourselves and place it into the right place. In order to ensure things like proxy support / authentication / determinism, we need to have all the downloads occur as directly in the portfile as possible.

libjpeg-turbo was found only as a debug library, creating issues when linking with CRT/CRTd (the latter always required by libjpeg, wrongly)

I'll look into this!

the lzma dependency of libtiff was missed out, making impossible to proper linking to OpenCV.

We should have fixed this in our toolchain file [1]. Could you go into a bit more detail here about what specifically isn't working?

[1] https://github.com/Microsoft/vcpkg/blob/0d29d2fe869863640253c1486e2a83c6941d2b8a/scripts/buildsystems/vcpkg.cmake#L209-L217

@jasjuang
Copy link
Copy Markdown
Contributor

vcpkg install opencv works, but as I suspected it breaks OpenCVConfig for downstream projects because you removed my patch, I am not sure how it works for you. Below is the minimal CMakeLists to demonstrate the problem.

cmake_minimum_required(VERSION 3.9)

project(Example LANGUAGES CXX)

set(PROJECT_SRCS ${PROJECT_SOURCE_DIR}/mycpp.cpp) 

find_package(OpenCV REQUIRED)

add_executable(${PROJECT_NAME} ${PROJECT_SRCS})

target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})

mycpp.cpp can be as simple as

int main(){
return 0;
}

After running cmake configuration for the downstream, the below error shows up

CMake Error at C:/dev/vcpkg/installed/x64-windows/share/opencv/OpenCVModules.cmake:367 (message):
  The imported target "opencv_core" references the file

     "C:/dev/vcpkg/installed/x64-windows/x64/vc15/lib/opencv_core340d.lib"

  but this file does not exist.  Possible reasons include:

  * The file was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and contained

     "C:/dev/vcpkg/installed/x64-windows/share/opencv/OpenCVModules.cmake"

  but not all the files it references.

Call Stack (most recent call first):
  C:/dev/vcpkg/installed/x64-windows/share/opencv/OpenCVConfig.cmake:112 (include)
  C:/dev/vcpkg/scripts/buildsystems/vcpkg.cmake:239 (_find_package)
  CMakeLists.txt:7 (find_package)


-- Configuring incomplete, errors occurred!
See also "C:/Users/jasju/Desktop/test/build/CMakeFiles/CMakeOutput.log".

Additionally when I tested out vcpkg install opencv[ffmpeg] here is the build error I am seeing.

-- Performing post-build validation
Detected outdated dynamic CRT in the following files:

    C:/dev/vcpkg/packages/opencv_x64-windows/debug/bin/opencv_ffmpeg340_64.dll: msvcrt.dll
    C:/dev/vcpkg/packages/opencv_x64-windows/bin/opencv_ffmpeg340_64.dll: msvcrt.dll

To inspect the dll files, use:
    dumpbin.exe /dependents mydllfile.dll
Found 1 error(s). Please correct the portfile:
    C:\dev\vcpkg\ports\opencv\portfile.cmake

@cenit
Copy link
Copy Markdown
Contributor Author

cenit commented Feb 15, 2018

@jasjuang which patch are you talking about? I ported patches, not removed any...
also, this PR is tested (and working) with non trivial builds in both x86-windows and x64-windows-static, and they both work. Not sure about your references to x64/vc15/ in C:/dev/vcpkg/installed/x64-windows/x64/vc15/lib/opencv_core340d.lib, since the proper port of CMakeLists.txt.patch to 3.4 was specific to re-enable the ocv_update(OpenCV_INSTALL_BINARIES_PREFIX ""), in order to avoid any messy manual rename...

@cenit
Copy link
Copy Markdown
Contributor Author

cenit commented Feb 15, 2018

@ras0219-msft

If OpenCV needs more files, we should do the download ourselves and place it into the right place. In order to ensure things like proxy support / authentication / determinism, we need to have all the downloads occur as directly in the portfile as possible.

While I fully understand your point, the fact is that dynamic downloading of files is embedded in OpenCV CMake toolchain through the OpenCVDownload.cmake functions (available in the cmake/ folder inside the .tar.gz). We can maybe prepare all the possible files inside the opencv-cache which is used by the script, but the port would be much bigger (and unstable, release-to-release) than expected, only for this point, which for now can be really alleviated by opting out of parallel configure (the dbg and rel configuration just mess up things downloading and removing things in parallel inside the opencv-cache). I would like to see, first of all, a working and proper OpenCV port without dealing with proxy et al, then maybe we can concentrate on this problem.

We should have fixed this in our toolchain file [1]. Could you go into a bit more detail here about what specifically isn't working?

There are some unresolved lzma symbols when using static builds of OpenCV.

As you can see from the patch attached to the first message, the default OpenCVModules-debug.cmake, OpenCVModules-release.cmake and OpenCVModules.cmake installed by the port miss out any reference to lzma. I can patch those things automatically, but not the final lines of OpenCVModules.cmake, so I found out that using embedded libraries just worked fine and for now I just accepted them, hoping for some help

@jasjuang
Copy link
Copy Markdown
Contributor

If you made changes to OpenCV_INSTALL_BINARIES_PREFIX then I am not sure why it's not working. I will try to test it again

@cenit
Copy link
Copy Markdown
Contributor Author

cenit commented Feb 15, 2018

There are no traces of those kind of paths prefixes in the machines on which I am testing (and already using) this PR, so please double check it. I could miss problems because all of the machines ultimately are made from the same setup, but still that problem should not be present here (maybe you referenced the wrong vcpkg toolchain, if you have many vcpkg installations?).

@cenit
Copy link
Copy Markdown
Contributor Author

cenit commented Feb 19, 2018

@ras0219-msft @alexkaratarakis I am having some problems: when a library has the same name in both debug and release, FindXXX will have a hard time distinguishing them. In particular, the great select_library_configurations() snippet is broken if Release and Debug have the same name.
To circumvent this problem, I had to "fix" also jasper and libjpeg-turbo in the meantime...

@cenit
Copy link
Copy Markdown
Contributor Author

cenit commented Feb 19, 2018

by the way, I fear that from the license point of view, a static linked software containing both GPL code (ffmpeg) and BSD code (OpenCV) is not redistributable. Am I right?

@cenit cenit changed the title [OpenCV] patches for v3.4.0, static triplet fixes, opt-out from ninja parallel configure [OpenCV] patches for v3.4.0, use vcpkg external libraries, many static triplet fixes, opt-out from ninja parallel configure Feb 20, 2018
@cenit
Copy link
Copy Markdown
Contributor Author

cenit commented Feb 20, 2018

also OpenEXR is now used from vcpkg (the library did not build, I had to add some patches to it too).
Next step (already found how to fix it, hope to have time soon) is to use external Tiff library.
OpenCV now also does NOT download anything (in the [core] package) on the fly uncontrolled by vcpkg.

+ IexMathFloatExc.cpp
IexMathFpu.cpp
)
-TARGET_LINK_LIBRARIES(IexMath Iex)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed? I am able to build locally without this patch for both x86-windows and x64-windows-static, even when including the changes below to the portfile.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you use the ilmlibrary, usually you have to link to Iex and IexMath and others (as also examples do). If you link Iex library symbols into IexMath you have symbols multiply defined. Also, linking a library to another one is not a best practice.
The library of course builds perfectly also without the patch, but you cannot use it. In the original conditions any symbol of Iex not included into IexMath requires linking also to Iex, but you cannot do it because of the problem just described.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok after more investigation, I think I should drop this patch too

"${CMAKE_CURRENT_LIST_DIR}/fix-parallel-build.patch"
"${CMAKE_CURRENT_LIST_DIR}/IexMath__CMakeLists.txt.patch"
"${CMAKE_CURRENT_LIST_DIR}/IlmThread__CMakeLists.txt.patch"
"${CMAKE_CURRENT_LIST_DIR}/Imath__CMakeLists.txt.patch"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am able to build without these three patches -- what are they used for?

Copy link
Copy Markdown
Contributor Author

@cenit cenit Feb 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To remove the interlinking between libraries, which make them not working if you try to use them (downstream)

set(BUILD_SHARED_LIBS OFF)
else()
set(BUILD_SHARED_LIBS ON)
endif()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not needed -- we automatically set BUILD_SHARED_LIBS inside vcpkg_configure_cmake based on the VCPKG_LIBRARY_LINKAGE setting

https://github.com/Microsoft/vcpkg/blob/77b07838bfaa997c7e133762755a9918f286d010/scripts/cmake/vcpkg_configure_cmake.cmake#L127-L133

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok good, I will remove it :)

@@ -0,0 +1,105 @@
# Distributed under the OSI-approved BSD 3-Clause License.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking in source code under a different license than Vcpkg is a problem. Instead, can we download these from their original locations using vcpkg_download_distfile()?

Or, we can author shorter alternatives that are more specialized for Vcpkg.

Finally, it makes more sense to me to move these to the respective publishing port (in this particular case FFMPEG) and putting it somewhere like /share/ffmpeg/FindFFMPEG.cmake. This won't be picked up by default from CMake, but then this port could explicitly pass

vcpkg_configure_cmake(
    
    OPTIONS
        "-DCMAKE_MODULE_PATH=${CURRENT_INSTALLED_DIR}/share/X;..."
)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote all of them. I can move them wherever you need them and also relicense as you like

@@ -0,0 +1,61 @@
# Distributed under the OSI-approved BSD 3-Clause License.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments about FindFFMPEG

Copy link
Copy Markdown
Contributor Author

@cenit cenit Feb 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall you give me the proper license tag to put on the header? Also, this port is becoming huge. I think I will submit all these FindXXX.cmake modules to official cmake repository, but it will take time (FindFLTK is there since so many months, accepted but CMake 3.11 is not coming out!! these ones should be easier, as you can see, the includes are almost ready for official inclusion, but even if they are considered for CMake 3.12, it means 6 months at least), so having them here in the meantime can speed up things a lot

@@ -0,0 +1,19 @@
diff --git a/IlmImfUtilTest/CMakeLists.txt b/IlmImfUtilTest/CMakeLists.txt
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this patch needed given that you've removed the add_subdirectory(IlmImfUtilTest) above?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as before, will remove in the next commit

set(BUILD_SHARED_LIBS OFF)
else()
set(BUILD_SHARED_LIBS ON)
endif()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not needed, see previous comments.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok :)

@@ -74,6 +74,10 @@ function(vcpkg_configure_cmake)
set(NINJA_CAN_BE_USED OFF)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make these changes in a separate PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

endif()

if (_csc_DISABLE_PARALLEL_CONFIGURE)
message(STATUS "Disabling parallel configure - package has opted-out")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe being noisy here is beneficial

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. It was necessary for me during the debug, to be sure that the correct path was chosen. Will remove!

message(STATUS "Configuring ${TARGET_TRIPLET}-dbg done")
endif()

if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make this swap (Debug first) in a separate PR!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure!

@ras0219-msft
Copy link
Copy Markdown
Contributor

I'm going to prepare a rebased branch with some of these changes I've requested

@cenit
Copy link
Copy Markdown
Contributor Author

cenit commented Feb 21, 2018

on my train to a conference, I implemented the external TIFF library detection fixing the LZMA dependency (it required the deployment of another couple of FindXXX.cmake modules, both for TIFF and for LibLZMA...), but now it works.
I also did some requested changes, other will come soon, unfortunately my free time is almost finished so any help is really welcome (I would like to enable also python, but I will leave it for later and another PR, this one is already too big).

I will also rewrite git history with a force push before merging, so we can have only the necessary number of commits and any trace of wrong licenses.

@ras0219-msft
Copy link
Copy Markdown
Contributor

Ok, I've rebased, squashed, cherry-picked, and minimized my way to a (small) victory:
https://github.com/Microsoft/vcpkg/tree/dev/roschuma/opencv-rework
https://github.com/Microsoft/vcpkg/tree/dev/roschuma/opencv-use-external-ffmpeg

I've prepared two branches: one without the ffmpeg change and one with. I think we should deliberate a bit more on what the right answer is w.r.t. the ffmpeg change (licenses as well as the upstream choices make me hesitant), however the branch without external ffmpeg LGTM.

I've also split out the various -DCMAKE_DEBUG_SUFFIX=d and removal of namespace changes that you had made -- I think these changes are orthogonal so they should be broken into separate PRs to minimize the number of simultaneous moving parts.

Barring bugs, I plan to merge opencv-rework soon. We can then keep working on the external ffmpeg and switching the dependencies to use debug suffixes.

@cenit
Copy link
Copy Markdown
Contributor Author

cenit commented Feb 22, 2018

First of all, thank you for revising the patchset and for all the small enhancements along the road.

we should deliberate a bit more on what the right answer is w.r.t. the ffmpeg change (licenses as well as the upstream choices make me hesitant)

(licenses)

For the license problem, I would not give it too much weight. vcpkg is just a tool to give you working libraries built from sources, we should not discuss how the user wants to play with them. This is also not the only mixture that would be not redistributable. Also, why should we block custom experiments?

(upstream choices)

On all the other systems, OpenCV links to the already available ffmpeg and does not download custom prebuilt binaries, all without complaining. On Windows for now they redistribute dlls that are made inside a docker container which runs ubuntu cross-compiling to Windows [1]. May I suppose that they never found a clean way to build ffmpeg as they require it on Windows and this is the reason they download it on the fly (while all the other libraries are built from sources if missing?)
Besides bumps and obstacles along the road, vcpkg is really playing a huge role in restoring Windows usability for C and C++ cross-platform developers and the fact that it can build ffmpeg with a simple command is a big testament to that. Maybe not the ffmpeg collaboration, but the OpenCV one could be interested in the toolchain that will come out of this rework :)

I've also split out the various -DCMAKE_DEBUG_SUFFIX=d and removal of namespace changes that you had made -- I think these changes are orthogonal so they should be broken into separate PRs to minimize the number of simultaneous moving parts.
Barring bugs, I plan to merge opencv-rework soon. We can then keep working on the external ffmpeg and switching the dependencies to use debug suffixes.

Ok let me know how to proceed in the best coordinated way. I don't want to do anything that you have already done and I am sure also the vice-versa is valid.
Let me know if I should open some small PR with the -d options. I will not open any PR with the removal of inter-library linking because I realized they were also triggered by a residual file in the installed folder by previous OpenCV installation, which left a ilmimf.lib dangerous file. Everything looks legit also without but I will keep testing.
Should I rework this PR in any way for merging or do you prefer to abandon it 😢 ?

In the meantime I will also open some PR in the CMake repository to trigger some updates of some FindXXXX.cmake modules. In the long time, it should ease this and other ports.

[1] https://github.com/opencv/opencv_3rdparty/tree/ffmpeg/master/ffmpeg

@ras0219-msft
Copy link
Copy Markdown
Contributor

I've merged the OpenCV-rework branch to master!

Also, why should we block custom experiments?

I am simply concerned about blocking users from using the dynamic ffmpeg (which is currently the out-of-the-box experience with OpenCV on Windows/MSVC, even when building statically). However, this should still be possible with our triplets system, so I think that while changing the default is always something worth contemplating, it doesn't block us here.

On all the other systems, OpenCV links to the already available ffmpeg and does not download custom prebuilt binaries, all without complaining. [additional solid reasoning]

That's a good argument. I'm mostly convinced, but I'll wait a bit longer for other users to potentially chime in (@jasjuang @lp55 @Mixaill @UnaNancyOwen @amincheloh @zabulus @tobiaskohlbau -- you've all contributed in the past so please chime in if you feel one way or another!).

Ok let me know how to proceed in the best coordinated way.

I see a few things:

  1. Could you test the dev/roschuma/opencv-use-external-ffmpeg and confirm it works for your scenarios? If it doesn't, either let me know or perhaps update this PR to be based off that branch plus some fixes.
  2. Could you submit independent PRs for the libraries you'd like to see changed w.r.t. debug suffixes and namespaces? I want to be cautious about changing the names because I want to (as much as reasonable) support existing FindXYZ.cmake scripts in the wild, such as for OpenEXR[1]. Looking at the first result from that query, it[2] actually looks like good evidence that we should remove the namespaces but not add a debug suffix! OTOH, Ogre3d[3] appears to support a debug suffix without namespaces.

Should I rework this PR in any way for merging or do you prefer to abandon it 😢 ?

Sorry for doing the separate rebase, but I didn't want to force-push-rebase over your master branch 😢. I still really appreciate what you've provided here -- it really makes up the majority of the branch I did merge! Unless you have some changes you'd like to apply on top of dev/roschuma/opencv-use-external-ffmpeg, I think it'd be best to close this PR and open new ones for any future work (also, please use separate branches when possible so I can contribute directly to them if I want simple formatting changes 😄)!

[1] https://github.com/search?utf8=%E2%9C%93&q=filename%3Afindopenexr.cmake&type=Code
[2] https://github.com/ItayGal2/nvidia-texture-tools/blob/32904e479f3d3da4d431b3023d847e0e239c6bf7/cmake/FindOpenEXR.cmake
[3] https://github.com/OGRECave/ogre/blob/06307e1963a97dbfc5871d23e613108ace9d0b93/CMake/Packages/FindOpenEXR.cmake

@jasjuang
Copy link
Copy Markdown
Contributor

Thanks for the work guys. I tested the builds and it works with my downstream project with both release and debug.

@cenit
Copy link
Copy Markdown
Contributor Author

cenit commented Feb 24, 2018

Could you test the dev/roschuma/opencv-use-external-ffmpeg and confirm it works for your scenarios?

I am testing it and it seems good. I understand your point on waiting for others before merging also the external ffmpeg, I just hope it will be accepted soon!

I want to (as much as reasonable) support existing FindXYZ.cmake scripts in the wild

As I said, I will push these script upstream to CMake. I hope they can be accepted, even if the timing there is very slow. We can postpone the work on the debug suffixes when those scripts will be accepted, if ever, so that your concerns should not be a problem anymore.

I just didn't check the OpenCV CMake configuration logs, is it correctly linked to debug-libraries in debug config and optimised libraries in release config? Should be, I think (on a MBP now :/ )

Sorry for doing the separate rebase, but I didn't want to force-push-rebase over your master branch 😢. I still really appreciate what you've provided here -- it really makes up the majority of the branch I did merge!

Thank you.
I always intended that fork to be totally up to you and any other contributor, also in the master branch, but I also understand your concern to force pushing to others' repository. I am used to it anyway 🤣

In any case, the really important thing is that OpenCV now is in a much better state here on vcpkg. I was also contacted by people that used my fork to develop the OpenCV[cuda] feature up to a working state, I think that it will be my next step (together with the python libraries, I see that python is cited here sometimes and so maybe we can extend the OpenCV library to build also the python interfaces if requested)

@patrikhuber
Copy link
Copy Markdown
Contributor

With the latest master branch of vcpkg, .\vcpkg.exe install opencv[core]:x64-windows now requires to install opengl[core]:x64-windows. This wasn't required before. Any reason for that?

@patrikhuber
Copy link
Copy Markdown
Contributor

With regards to ffmpeg, I don't have a particular opinion. If OpenCV on all other platforms is using system ffmpeg too and not the OpenCV-bundled one, then that sounds like a good reason to use vcpkg-ffmpeg on Windows too.
If you're using vcpkg libpng, tiff and jpeg also from vcpkg (it looks like that to me) and not the OpenCV-bundled one, then why not do it for ffmpeg too, this would be another argument for it.

@cenit
Copy link
Copy Markdown
Contributor Author

cenit commented Feb 24, 2018

Any reason for that?

OpenCV building triggers a FindOpenGL along the way, which was correctly solved because the SDK path is always checked by cmake. Having it explicitly as a dependency I think is better, so that we can keep track of what is really necessary. Installing OpenGL also is very quick, since it is just a copy of the binary libraries inside vcpkg folder.

If you're using vcpkg libpng, tiff and jpeg also from vcpkg (it looks like that to me) and not the OpenCV-bundled one, then why not do it for ffmpeg too, this would be another argument for it.

Exactly. But I can understand that we should just let the dust settle a bit. The rework is just big enough to deserve some days to see if there's a surge of issues related to it (I am almost sure not, on the other hands many problems are now solved)

@cenit cenit closed this Feb 24, 2018
@patrikhuber
Copy link
Copy Markdown
Contributor

OpenCV building triggers a FindOpenGL along the way, which was correctly solved because the SDK path is always checked by cmake. Having it explicitly as a dependency I think is better, so that we can keep track of what is really necessary.

Just came across this again by coincidence. Strictly speaking OpenCV build does not trigger a FindOpenGL. It only triggers it when WITH_OPENGL (don't remember the exact option, but something like that) is set to ON.

Also another thing, I'm not sure which module it is but some apps that I build with OpenCV, now show some output on the command-line about OpenCL initialisation - without me ever printing something. This must be one of OpenCV's modules - and I am definitely not using OpenCL. So I am not sure but I think this output message is a bit intrusive and it's on with vcpkg's default configuration of OpenCV. I don't really want any spurious output in my apps on the command line, particularly if I'm not even using OpenCL. I'd set building OpenCV with OpenCL off by default - I am surprised that it isn't.

@cenit
Copy link
Copy Markdown
Contributor Author

cenit commented Apr 18, 2018

in the latest patchset, I explicitly treated OpenGL as a feature (a default one, by the way), but still you can force to disable it during install.
I will look into this OpenCL issue you are seeing. Can you provide a repro?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants