<div dir="ltr">Dear users,<div><br></div><div>It has been a while since I used CMake and it's the first time I'm using it on Windows/MSVC2013, so hopefully I'm not missing something obvious. I tried to create the most basic example that shows the problem.</div><div><br></div><div>I'm trying to compile a subfolder of my Qt5 project into a shared library. The CMakeLists.txt file in the main folder looks like:</div><div><br></div><div><div>  CMAKE_MINIMUM_REQUIRED(VERSION 3.0.0)</div><div>  PROJECT(qtapp)</div><div><br></div><div>  set(CMAKE_PREFIX_PATH "C:/Qt/Qt5.4.0/5.4/msvc2013_64_opengl/lib/cmake") </div><div>  FIND_PACKAGE(Qt5Widgets REQUIRED)</div><div>  FIND_PACKAGE(Qt5Core REQUIRED)</div><div>  SET(CMAKE_AUTOMOC ON)</div><div>  SET(CMAKE_INCLUDE_CURRENT_DIR ON)</div><div><br></div><div>  add_subdirectory(mylib)<br></div><div><br></div><div>  add_executable(mymain WIN32 mymain.cpp)<br></div><div>  target_link_libraries(mymain mylib)</div><div><br></div></div><div><div>The CMakeLists.txt file in the subfolder looks like this:</div><div><br></div><div><div>  CMAKE_MINIMUM_REQUIRED(VERSION 3.0.0)</div><div>  FILE(GLOB lib_sources *.cpp *.h)</div><div>  ADD_LIBRARY(mylib SHARED ${lib_sources})</div><div>  TARGET_LINK_LIBRARIES(mylib Qt5::Widgets)</div><div><br></div><div>  include(GenerateExportHeader)</div><div>  generate_export_header(mylib)</div></div></div><div><br></div><div>Inside the subfolder I have one header file mylib.h:</div><div><br></div><div><div>  #pragma once</div><div>  #include "mylib_export.h"</div><div><br></div><div>  class MYLIB_EXPORT MyClass</div><div>  {</div><div>  public:</div><div>      MyClass();</div><div><br></div><div>  };</div></div><div><br></div><div>And there is one source file mylib.cpp:</div><div><div><br></div><div>  #include "myclass.h"</div><div><br></div><div>  MyClass::MyClass()</div><div>  {}</div></div><div><br></div><div>In the main file mymain.cpp in the main folder I try to instantiate an object:</div><div><br></div><div><div>  #include "mylib/myclass.h"</div><div>  int main()<br></div><div>  {</div><div>      MyClass klass();</div><div>  }</div></div><div><br></div><div>I create a 'build' folder, where I execute 'cmake -G "Visual Studio 12 2013 Win64" ..'; subsequently I open the resulting solution file, which I try to build.</div><div><br></div><div>The problem: for some reason when compiling mymain.cpp I get:</div><div>  fatal error C1083: Cannot open include file: 'mylib_export.h': No such file or directory<br></div><div><br></div><div>I already checked that the build-folder is added as an include directory, both to the main-project and to the library-project. I already noticed that compilation will succeed if I #include explicitly from the build directory inside mylib.h (#include "../build/mylib/mylib_export.h") but that obviously is not my intention.</div><div><br></div><div>What am I doing wrong or what did I miss? Any ideas?</div><div><br></div><div>Sincerely,</div><div>Jakob van Bethlehem</div></div>