<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le sam. 9 mars 2019 à 08:44, <a href="mailto:Workbench@gmx.at">Workbench@gmx.at</a> <<a href="mailto:workbench@gmx.at">workbench@gmx.at</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi everyone,<br>
<br>
i've a project setup that looks like this:<br>
<br>
<br>
abc.h<br>
<br>
def.h<br>
<br>
and all my other .cpp and .h files are in the folder intern. Now my <br>
CMakeLists.txt looks like this:<br>
<br>
cmake_minimum_required(VERSION 3.7)<br>
project(BS_Application)<br>
set(SRC<br>
     BS_AppTypes.hpp<br>
     BS_IEvent.hpp<br>
     BS_ISystem.hpp<br>
     BS_IWindow.hpp<br>
     BS_ITimerTask.hpp<br>
     BS_IEventConsumer.hpp<br>
     BS_Application.cpp<br>
     BS_Button.cpp<br>
     BS_ContextSDL.cpp<br>
     BS_ISystem.cpp<br>
     BS_System.cpp<br>
     BS_SystemSDL.cpp<br>
     BS_WindowSDL.cpp<br>
     BS_ContextSDL.cpp<br>
     BS_DisplayManagerSDL.cpp<br>
     BS_Button.cpp<br>
     BS_EventManager.cpp<br>
     BS_EventPrinter.cpp<br>
     BS_ModifierKeys.cpp<br>
     BS_DisplayManager.cpp<br>
)<br>
set(INC<br>
     intern<br>
)<br>
include_directories(${INC})<br>
add_library(BS_Application STATIC ${SRC})<br>
<br>
Where all files above BS_Application.cpp are in the folder intern but he <br>
is not able to find BS_Application.cpp but i added it to the <br>
include_direcotires, what am i doing wrong here ?<br></blockquote><div><br></div><div>First of all usage of include_directories is a discouraged old-style variable oriented CMake.</div><div>You should prefer target oriented rule.</div><div>Namelly target_include_directories().</div><div>You can have a look at: <a href="https://steveire.wordpress.com/2017/11/05/embracing-modern-cmake/">https://steveire.wordpress.com/2017/11/05/embracing-modern-cmake/</a> and/or</div><div>refered presentation from Daniel Pfeifer or Mathieu Ropert there in.</div><div>It'll get you a broad view of the "Modern CMake way to go".</div><div><br></div><div>Now both commands (target_include_directories or include_directories) influence where *header* file are found.</div><div>So that if you say</div><div><br></div><div>include_directories(${INC})<br></div><div><div>add_library(BS_Application STATIC BS_Application.cpp)</div><div><br></div></div><div>CMake won't go looking for "BS_Application.cpp" inside ${INC}.</div><div>You should refer to your source files with the proper path:</div><div>i.e.</div><div><div>add_library(BS_Application STATIC ${INC}/BS_Application.cpp)</div></div><div><br></div><div>You may consider having a look at how to use target_source as well.</div><div>Craig Scott published a nice blog entry about that:</div><div><a href="https://crascit.com/2016/01/31/enhanced-source-file-handling-with-target_sources/">https://crascit.com/2016/01/31/enhanced-source-file-handling-with-target_sources/</a><br></div><div><br></div><div>Regards,</div><div>Eric</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
best regards!<br>
<br>
-- <br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="https://cmake.org/mailman/listinfo/cmake" rel="noreferrer" target="_blank">https://cmake.org/mailman/listinfo/cmake</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Eric<br></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>