Open Source Computer Vision Library
Go to file
Gabriel B. Nunes 88e54ca1c0 Work around CMake bug that mangles install dir
CMake has a long-standing bug/feature (see [here](https://cmake.org/pipermail/cmake/2015-March/060204.html) and reply [here](https://cmake.org/pipermail/cmake/2015-March/060209.html)) which can mangle certain path variables by attempting to make them into relative paths if you try to set them with CACHE PATH.

Say you have your OpenCV download at `/path/on/my/computer/to/opencv/`. What actually happens is that if you try to set this variable by invoking CMAKE with `-DCMAKE_INSTALL_PREFIX=/my/desired/install/path`, what you end up is *not* `/usr/local/` and *not* `my/desired/install/path`, but instead, this monstrosity: `/path/on/my/computer/to/opencv/src/OpenCV-build//my/desired/install/path`.

That is, CMake attempts, for some reason, to turn the path that you passed into a path relative to `${CMAKE_BINARY_DIR}`. See the links I posted above: this is a known (and apparently unfixable) issue with CMake.

In OpenCV's case, among other potential issues, this leads to broken paths in `opencv_tests_config.hpp`, which can break the build or cause bizarre behaviour.

The fix for this issue, as stated in my links above, is to test that the variable hasn't been set yet with an `if(NOT DEFINED ...)` before attempting to set it. This is what I've implemented here. I admit I don't know enough about OpenCV's internals to know whether you *really* need to force the install to be in `/usr/local`, but as it stands right now you get *neither* a clean `/usr/local` path *nor* a customized `/my/desired/install/path`, but a broken mess. This change at least allows the user to customize their install directory.

In the meantime, there's a workaround for this, by explicitly defining the variable as a path with `-DCMAKE_INSTALL_PREFIX:PATH=my/desired/install/path`. But if this change can save anyone else the hours of headaches that I had today, I'll be happy.
2017-02-11 20:40:37 -05:00
.github migration: github.com/opencv/opencv 2016-07-12 12:51:12 +03:00
3rdparty Fixed addressing structure population for integral image output 2017-02-03 13:54:22 +03:00
apps fix some issues with skipping files and old redundant code 2017-01-06 12:35:56 +01:00
cmake Merge pull request #8084 from mshabunin:libstdcplusplus-debug 2017-02-03 08:47:37 +00:00
data add new frontal face detection model, VISAPP2017 contribution 2016-12-21 10:49:03 +01:00
doc Merge pull request #8150 from cclauss/patch-1 2017-02-10 15:12:11 +03:00
include Merge pull request #7370 from souch55:Fixxn 2016-10-01 10:44:56 +00:00
modules Merge pull request #8165 from AdeelH:master 2017-02-11 11:02:10 +00:00
platforms Fixed build_framework.py script for osx 2017-01-24 19:14:50 +01:00
samples KMeans improvement 2017-01-31 12:05:08 +03:00
.gitattributes Made changes to OpenCVFindMatlab suggested by SpecLad 2013-09-14 13:32:15 +10:00
.gitignore Improved thrust interop tutorial. 2015-09-24 09:32:38 -04:00
.tgitconfig Add tgit.icon project config 2014-02-26 17:46:52 +08:00
CMakeLists.txt Work around CMake bug that mangles install dir 2017-02-11 20:40:37 -05:00
CONTRIBUTING.md migration: github.com/opencv/opencv 2016-07-12 12:51:12 +03:00
LICENSE Update license year range to 2016 2016-01-18 10:11:01 +05:30
README.md migration: github.com/opencv/opencv 2016-07-12 12:51:12 +03:00

OpenCV: Open Source Computer Vision Library

Resources

Contributing

Please read before starting work on a pull request: https://github.com/opencv/opencv/wiki/How_to_contribute

Summary of guidelines:

  • One pull request per issue;
  • Choose the right base branch;
  • Include tests and documentation;
  • Clean up "oops" commits before submitting;
  • Follow the coding style guide.