<h5 dir="auto">System information (version)</h5>

<ul dir="auto">
<li>OpenCV =&gt; 4.1.1</li>
<li>Operating System / Platform =&gt; Windows 64 Bit</li>
<li>Compiler =&gt; MinGW-w64 10.1.0</li>
</ul>
<h5 dir="auto">Detailed description</h5>

<p dir="auto">Building fails</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="...
[482/1644] Building CXX object modules/core/CMakeFiles/opencv_core_pch_dephelp.dir/opencv_core_pch_dephelp.cxx.obj
FAILED: modules/core/CMakeFiles/opencv_core_pch_dephelp.dir/opencv_core_pch_dephelp.cxx.obj 
C:\msys64\mingw64\bin\c++.exe -D_USE_MATH_DEFINES -D__OPENCV_BUILD=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -IC:/dev/repos/opencv/modules/core/src -IC:/dev/repos/opencv/modules/core/include -Imodules/core -IC:/dev/repos/opencv/3rdparty/zlib -I3rdparty/zlib -IC:/dev/repos/opencv/3rdparty/include/opencl/1.2 -isystem . -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG -std=c++11 -MD -MT modules/core/CMakeFiles/opencv_core_pch_dephelp.dir/opencv_core_pch_dephelp.cxx.obj -MF modules\core\CMakeFiles\opencv_core_pch_dephelp.dir\opencv_core_pch_dephelp.cxx.obj.d -o modules/core/CMakeFiles/opencv_core_pch_dephelp.dir/opencv_core_pch_dephelp.cxx.obj -c modules/core/opencv_core_pch_dephelp.cxx
cc1plus.exe: warning: command-line option '-Wmissing-prototypes' is valid for C/ObjC but not for C++
cc1plus.exe: warning: command-line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
In file included from C:/dev/repos/opencv/modules/core/src/precomp.hpp:55,
                 from modules/core/opencv_core_pch_dephelp.cxx:1:
C:/dev/repos/opencv/modules/core/include/opencv2/core/private.hpp:66:12: fatal error: Eigen/Core: No such file or directory
   66 | #  include &lt;Eigen/Core&gt;
      |            ^~~~~~~~~~~~
compilation terminated.
[483/1644] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1d/sources/ade/source/memory_descriptor_view.cpp.obj
cc1plus.exe: warning: command-line option '-Wmissing-prototypes' is valid for C/ObjC but not for C++
cc1plus.exe: warning: command-line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
[484/1644] Building CXX object modules/core/CMakeFiles/opencv_test_core_pch_dephelp.dir/opencv_test_core_pch_dephelp.cxx.obj
FAILED: modules/core/CMakeFiles/opencv_test_core_pch_dephelp.dir/opencv_test_core_pch_dephelp.cxx.obj 
C:\msys64\mingw64\bin\c++.exe -D_USE_MATH_DEFINES -D__OPENCV_BUILD=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -IC:/dev/repos/opencv/modules/ts/include -IC:/dev/repos/opencv/modules/core/include -IC:/dev/repos/opencv/modules/imgcodecs/include -IC:/dev/repos/opencv/modules/videoio/include -IC:/dev/repos/opencv/modules/imgproc/include -IC:/dev/repos/opencv/modules/highgui/include -Imodules/core/test -isystem . -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG -std=c++11 -MD -MT modules/core/CMakeFiles/opencv_test_core_pch_dephelp.dir/opencv_test_core_pch_dephelp.cxx.obj -MF modules\core\CMakeFiles\opencv_test_core_pch_dephelp.dir\opencv_test_core_pch_dephelp.cxx.obj.d -o modules/core/CMakeFiles/opencv_test_core_pch_dephelp.dir/opencv_test_core_pch_dephelp.cxx.obj -c modules/core/opencv_test_core_pch_dephelp.cxx
cc1plus.exe: warning: command-line option '-Wmissing-prototypes' is valid for C/ObjC but not for C++
cc1plus.exe: warning: command-line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
In file included from C:/dev/repos/opencv/modules/core/test/test_precomp.hpp:12,
                 from modules/core/opencv_test_core_pch_dephelp.cxx:1:
C:/dev/repos/opencv/modules/core/include/opencv2/core/private.hpp:66:12: fatal error: Eigen/Core: No such file or directory
   66 | #  include &lt;Eigen/Core&gt;
      |            ^~~~~~~~~~~~
compilation terminated.
"><pre class="notranslate"><code class="notranslate">...
[482/1644] Building CXX object modules/core/CMakeFiles/opencv_core_pch_dephelp.dir/opencv_core_pch_dephelp.cxx.obj
FAILED: modules/core/CMakeFiles/opencv_core_pch_dephelp.dir/opencv_core_pch_dephelp.cxx.obj 
C:\msys64\mingw64\bin\c++.exe -D_USE_MATH_DEFINES -D__OPENCV_BUILD=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -IC:/dev/repos/opencv/modules/core/src -IC:/dev/repos/opencv/modules/core/include -Imodules/core -IC:/dev/repos/opencv/3rdparty/zlib -I3rdparty/zlib -IC:/dev/repos/opencv/3rdparty/include/opencl/1.2 -isystem . -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG -std=c++11 -MD -MT modules/core/CMakeFiles/opencv_core_pch_dephelp.dir/opencv_core_pch_dephelp.cxx.obj -MF modules\core\CMakeFiles\opencv_core_pch_dephelp.dir\opencv_core_pch_dephelp.cxx.obj.d -o modules/core/CMakeFiles/opencv_core_pch_dephelp.dir/opencv_core_pch_dephelp.cxx.obj -c modules/core/opencv_core_pch_dephelp.cxx
cc1plus.exe: warning: command-line option '-Wmissing-prototypes' is valid for C/ObjC but not for C++
cc1plus.exe: warning: command-line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
In file included from C:/dev/repos/opencv/modules/core/src/precomp.hpp:55,
                 from modules/core/opencv_core_pch_dephelp.cxx:1:
C:/dev/repos/opencv/modules/core/include/opencv2/core/private.hpp:66:12: fatal error: Eigen/Core: No such file or directory
   66 | #  include &lt;Eigen/Core&gt;
      |            ^~~~~~~~~~~~
compilation terminated.
[483/1644] Building CXX object modules/CMakeFiles/ade.dir/__/3rdparty/ade/ade-0.1.1d/sources/ade/source/memory_descriptor_view.cpp.obj
cc1plus.exe: warning: command-line option '-Wmissing-prototypes' is valid for C/ObjC but not for C++
cc1plus.exe: warning: command-line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
[484/1644] Building CXX object modules/core/CMakeFiles/opencv_test_core_pch_dephelp.dir/opencv_test_core_pch_dephelp.cxx.obj
FAILED: modules/core/CMakeFiles/opencv_test_core_pch_dephelp.dir/opencv_test_core_pch_dephelp.cxx.obj 
C:\msys64\mingw64\bin\c++.exe -D_USE_MATH_DEFINES -D__OPENCV_BUILD=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -IC:/dev/repos/opencv/modules/ts/include -IC:/dev/repos/opencv/modules/core/include -IC:/dev/repos/opencv/modules/imgcodecs/include -IC:/dev/repos/opencv/modules/videoio/include -IC:/dev/repos/opencv/modules/imgproc/include -IC:/dev/repos/opencv/modules/highgui/include -Imodules/core/test -isystem . -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG -std=c++11 -MD -MT modules/core/CMakeFiles/opencv_test_core_pch_dephelp.dir/opencv_test_core_pch_dephelp.cxx.obj -MF modules\core\CMakeFiles\opencv_test_core_pch_dephelp.dir\opencv_test_core_pch_dephelp.cxx.obj.d -o modules/core/CMakeFiles/opencv_test_core_pch_dephelp.dir/opencv_test_core_pch_dephelp.cxx.obj -c modules/core/opencv_test_core_pch_dephelp.cxx
cc1plus.exe: warning: command-line option '-Wmissing-prototypes' is valid for C/ObjC but not for C++
cc1plus.exe: warning: command-line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
In file included from C:/dev/repos/opencv/modules/core/test/test_precomp.hpp:12,
                 from modules/core/opencv_test_core_pch_dephelp.cxx:1:
C:/dev/repos/opencv/modules/core/include/opencv2/core/private.hpp:66:12: fatal error: Eigen/Core: No such file or directory
   66 | #  include &lt;Eigen/Core&gt;
      |            ^~~~~~~~~~~~
compilation terminated.

</code></pre></div>
<p dir="auto"><a href="https://github.com/opencv/opencv/files/5134333/opencv_log.txt">full log</a></p>
<h5 dir="auto">Steps to reproduce</h5>
<p dir="auto">Generate and build project with cmake (MSYS2 MINGW64 shell launcher)</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="cmake -G Ninja $opencv_source
cmake --build .."><pre class="notranslate"><code class="notranslate">cmake -G Ninja $opencv_source
cmake --build ..
</code></pre></div>
<p dir="auto"><code class="notranslate">$opencv_source</code> - path to opencv source</p>
<h5 dir="auto">System information (version)</h5>

<ul dir="auto">
<li>OpenCV =&gt; 3.4.7 / 4.1.1</li>
<li>Operating System / Platform =&gt; Ubuntu 18.04 x86_64</li>
<li>Compiler =&gt; gcc 8.3 / gcc 9.1</li>
</ul>
<h5 dir="auto">Detailed description</h5>

<p dir="auto">OpenCV fails to build when Eigen is imported as a CMake target and precompiled header are ON.</p>
<p dir="auto">When Eigen is imported as a CMake target (here <a href="https://github.com/opencv/opencv/blob/3.4.7/cmake/OpenCVFindLibsPerf.cmake#L47-L50">https://github.com/opencv/opencv/blob/3.4.7/cmake/OpenCVFindLibsPerf.cmake#L47-L50</a>) I got the following error when compiling :</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[321/1436] Building CXX object modules/core/CMakeFiles/opencv_core_pch_dephelp.dir/opencv_core_pch_dephelp.cxx.o
FAILED: modules/core/CMakeFiles/opencv_core_pch_dephelp.dir/opencv_core_pch_dephelp.cxx.o 
/usr/bin/c++  -DOPENCV_WITH_ITT=1 -D_USE_MATH_DEFINES -D__OPENCV_BUILD=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I. -I../modules/core/src -I../modules/core/include -Imodules/core -I../3rdparty/include/opencl/1.2 -I../3rdparty/ittnotify/include -fsigned-char -ffast-math -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG -fPIC   -std=c++11 -MD -MT modules/core/CMakeFiles/opencv_core_pch_dephelp.dir/opencv_core_pch_dephelp.cxx.o -MF modules/core/CMakeFiles/opencv_core_pch_dephelp.dir/opencv_core_pch_dephelp.cxx.o.d -o modules/core/CMakeFiles/opencv_core_pch_dephelp.dir/opencv_core_pch_dephelp.cxx.o -c modules/core/opencv_core_pch_dephelp.cxx
In file included from /tmp/Genie/External/source/opencv/modules/core/src/precomp.hpp:55,
                 from modules/core/opencv_core_pch_dephelp.cxx:1:
../modules/core/include/opencv2/core/private.hpp:66:12: fatal error: Eigen/Core: No such file or directory
 #  include &lt;Eigen/Core&gt;
            ^~~~~~~~~~~~"><pre class="notranslate"><code class="notranslate">[321/1436] Building CXX object modules/core/CMakeFiles/opencv_core_pch_dephelp.dir/opencv_core_pch_dephelp.cxx.o
FAILED: modules/core/CMakeFiles/opencv_core_pch_dephelp.dir/opencv_core_pch_dephelp.cxx.o 
/usr/bin/c++  -DOPENCV_WITH_ITT=1 -D_USE_MATH_DEFINES -D__OPENCV_BUILD=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I. -I../modules/core/src -I../modules/core/include -Imodules/core -I../3rdparty/include/opencl/1.2 -I../3rdparty/ittnotify/include -fsigned-char -ffast-math -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG -fPIC   -std=c++11 -MD -MT modules/core/CMakeFiles/opencv_core_pch_dephelp.dir/opencv_core_pch_dephelp.cxx.o -MF modules/core/CMakeFiles/opencv_core_pch_dephelp.dir/opencv_core_pch_dephelp.cxx.o.d -o modules/core/CMakeFiles/opencv_core_pch_dephelp.dir/opencv_core_pch_dephelp.cxx.o -c modules/core/opencv_core_pch_dephelp.cxx
In file included from /tmp/Genie/External/source/opencv/modules/core/src/precomp.hpp:55,
                 from modules/core/opencv_core_pch_dephelp.cxx:1:
../modules/core/include/opencv2/core/private.hpp:66:12: fatal error: Eigen/Core: No such file or directory
 #  include &lt;Eigen/Core&gt;
            ^~~~~~~~~~~~
</code></pre></div>
<p dir="auto">Disabling precompiled header with <code class="notranslate">ENABLE_PRECOMPILED_HEADER=OFF</code> when configuring is workaround.</p>