<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>Hello,<br>
</p>
<p>Have you try to add the header files in the add_library command to explicitely add a dependency over it ?</p>
<p>add_library(MyLib SHARED my_source.cpp ../MyHeaders/header.hpp etc.)</p>
<div class="moz-cite-prefix">On 10/21/19 4:16 PM, David Aldrich wrote:<br>
</div>
<blockquote type="cite" cite="mid:CAJK_ieiVP+ntvaZ5S8mjWSX6hJd+26xuN+brU-kCMD_mu94A7w@mail.gmail.com">
<div style="”font-family:Calibri;font-size:14.5px;font-weight:bold;color:Firebrick;line-height:0pt”">
WARNING: External email, please be mindful before clicking or replying.</div>
<br>
<div>
<div dir="ltr">Hi again,<br>
<br>
My CMakeLists.txt file for my shared library contains:<br>
<br>
add_library(MyLib SHARED my_source.cpp etc.)<br>
target_include_directories( MyLib PRIVATE ../MyHeaders)<br>
<br>
The library builds ok, but there is no dependency on directory ../MyHeaders - touching a header file does not result in a re-compile of dependent source files.<br>
<br>
There's a discussion here:<br>
<br>
<a href="https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Furldefense.com%2Fv3%2F__https%3A%2F%2Fstackoverflow.com%2Fquestions%2F13703647%2Fhow-to-properly-add-include-directories-with-cmake__%3B!NS9wnPUNuDs!whDhrk7RGTn3RadMaGwNJ7gyGUJg_fOCmaUVKr9T3ock9JmdX37y1aDQW7XthkCVdA%24&data=01%7C01%7Cwilliam.bon%40caldera.com%7C2e78ae5316384a4a4aa908d756315037%7C3d2d2b6f061a48b6b4b39312d687e3a1%7C1&sdata=zpBAH%2BeG3WhFkfgnzt9iTMsiK0NBupnbI2fTjvoK3TM%3D&reserved=0" originalsrc="https://urldefense.com/v3/__https://stackoverflow.com/questions/13703647/how-to-properly-add-include-directories-with-cmake__;!NS9wnPUNuDs!whDhrk7RGTn3RadMaGwNJ7gyGUJg_fOCmaUVKr9T3ock9JmdX37y1aDQW7XthkCVdA$" shash="NfhvEmHKiPJi7Z7DrIL9B30MXwulQImwdgtCAeVCuxuq6OmeiI0zPZ3EXS4HasIU/s95ara/KL1pKEXT6FVFtdbR6f8vLQjcF1EeZ5UFyFIOYoWgvS+6fXqV1tWyVwBXaS18CHOYrFeowNfIziXFam94tRWpI0cw0GhIFiohCck=" moz-do-not-send="true">https://stackoverflow.com/questions/13703647/how-to-properly-add-include-directories-with-cmake</a>
  <br>
Opinion seems divided over whether or not it is necessary to add the header files to the list of source files for the target, e.g.:<br>
<br>
set(SOURCES file.cpp file2.cpp ${YOUR_DIRECTORY}/file1.h ${YOUR_DIRECTORY}/file2.h)<br>
add_library(test ${SOURCES})<br>
<div><br>
</div>
<div>Please will you tell me what is the best practice?</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset> </blockquote>
</body>
</html>