<html xmlns:v="urn:schemas-microsoft-com:vml" 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=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:"Courier New";}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">Hi,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I’m trying to set up a project pulls in information from another CMake project (include dirs, libraries, etc.). As I understand it the right thing to do is create a <Project>config.cmake.in in the source project and then use find_package
in config mode to pull in the information to the dependent project.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">So far things seem to be working properly but I’d like to pull the content of include_directories from the master project into the dependent project because it has to reference a few headers. I haven’t found any built in CMake variable
that collects all the include_directory commands but I can do something like this:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-left:.5in;background:white"><span style="font-size:12.0pt;font-family:Consolas;color:black">get_property (dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in;background:white"><span style="font-size:12.0pt;font-family:Consolas;color:black">foreach (dir ${dirs})<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in;background:white"><span style="font-size:12.0pt;font-family:Consolas;color:black"> message (STATUS "MyProject INCLUDE DIRECTORY: '${dir}'")<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in;background:white"><span style="font-size:12.0pt;font-family:Consolas;color:black"> list (APPEND MyProject_INCLUDE_DIRS ${dir})<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in;background:white"><span style="font-size:12.0pt;font-family:Consolas;color:black">endforeach ()<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in;background:white"><span style="font-size:12.0pt;font-family:Consolas;color:black">message( STATUS "MyProject_INCLUDE_DIRS: " ${MyProject_INCLUDE_DIRS} )<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">this seems to do the right thing and lists all the directories in include_directory() statements, but when I go to the MyProjectConfig.cmake.in file and have something like this:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<pre style="margin-left:.5in;background:white"><span style="font-size:12.0pt;font-family:Consolas;color:black">set (MYPROJECT_INCLUDE_DIRS ${MyProject_INCLUDE_DIRS})<o:p></o:p></span></pre>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">it doesn’t get anything. I have other statements in the MyProjectConfig.cmake.in file that have a similar pattern and are expanded but for this one I get something like this:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<pre style="margin-left:.5in;background:white"><span style="font-size:12.0pt;font-family:Consolas;color:black">set (MYPROJECT_INCLUDE_DIRS )<o:p></o:p></span></pre>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I’ve used CMake for a while, generated a couple simple project scripts in the past but this is my first time developing a project using find_package in config mode. Any suggestions would be helpful :)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks!<o:p></o:p></p>
<p class="MsoNormal"> -William<o:p></o:p></p>
</div>
</body>
</html>