This is a template helping you to create an issue which can be processes as quickly as possible. Feel free to add additional information or remove not relevant points if you do not need them.
If you have a question rather than reporting a bug please go to http://answers.opencv.org where you get much faster responses.
Compiler & CMake: MSVC 120 & CMake 3.5
CMakeLists.txt
Build succeeds
LINK : fatal error LNK1104: cannot open file 'Files\NVIDIA.obj'
This line breaks the build with Ninja under Windows. I think the line should be:
# this
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CMAKE_LIBRARY_PATH_FLAG}$<SHELL_PATH:${p}>)
# instead of that
# set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} -L${p})
But even with this change the build fails because of the spaces in the path which Ninja does not like. Maybe $<SHELL_PATH:...>
should return a short path but that's a CMake issue.
As a workaround one can use:
if(NOT CMAKE_GENERATOR MATCHES "Ninja" AND NOT MSVC)
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} -L${p})
endif()
This problem also affects consuming projects as the link flags end up in the OpenCVModules*.cmake
files.
I find Ninja much faster than msbuild on Windows especially when building with CUDA so it would be nice if OpenCV supported this generator too.
Posted a related issue to CMake bug tracker: https://cmake.org/Bug/view.php?id=16053
You can use /maxcpucount
option with msbuild to speed up the build process. The example for 4-core CPU:
.cmd
cmake --build . --config release -- /maxcpucount:5
@mshabunin with respect, but the maxcpucount
nothing to do really w.r.t. parallel compilation of translation units.