<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
        {mso-style-priority:99;
        mso-style-link:"Plain Text Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.PlainTextChar
        {mso-style-name:"Plain Text Char";
        mso-style-priority:99;
        mso-style-link:"Plain Text";
        font-family:"Calibri",sans-serif;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="EN-AU" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoPlainText">J Decker wrote:<o:p></o:p></p>
<p class="MsoPlainText" style="margin-left:36.0pt">You can define a variable to define the base of the sources....<o:p></o:p></p>
<p class="MsoPlainText" style="margin-left:36.0pt">set( SOURCE_ROOT /some/path )<o:p></o:p></p>
<p class="MsoPlainText" style="margin-left:36.0pt"><o:p> </o:p></p>
<p class="MsoPlainText" style="margin-left:36.0pt">could be set relative to the current cmake path per cmake that uses those<o:p></o:p></p>
<p class="MsoPlainText" style="margin-left:36.0pt">souces... and then just prefix it<o:p></o:p></p>
<p class="MsoPlainText" style="margin-left:36.0pt"><o:p> </o:p></p>
<p class="MsoPlainText" style="margin-left:36.0pt">add_library(my_lib<o:p></o:p></p>
<p class="MsoPlainText" style="margin-left:36.0pt">        ${SOURCE_ROOT}/src/a.c<o:p></o:p></p>
<p class="MsoPlainText" style="margin-left:36.0pt">        ${SOURCE_ROOT}/include/a.h<o:p></o:p></p>
<p class="MsoPlainText" style="margin-left:36.0pt">)<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">Thanks, but that’s approximately exactly what I’m trying to avoid doing.  I cheat a little, in that I have a macro that will prepend a prefix to every element of a list.  My motivation is avoiding situations where I add the prefix to
 the files but forget to add the prefix when I call target_include_directories or suchlike.<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">I’m not sure anything trickier is workable in the CMake model, however.  For example, hacking CMAKE_CURRENT_SOURCE_DIR might make sense for file paths, but if I then call add_subdirectory should it be rooted at the CMakeList directory
 or the source root directory.<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">--<o:p></o:p></p>
<p class="MsoPlainText">Andrew<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
</div>
</body>
</html>