<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 12 (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: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;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;}
@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"><span style="font-family:"Courier New"">I wonder if anyone else has come into this kind of situation.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">We are restructuring how some of our libraries are structured on disk to be more modular.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">Previously, we had all of the project names defined in a CMakeList.txt that then would call to add the subdirectories that are needed. This works fine, but with the new structure, we would like to
eliminate the need for this master file and just have the subdirectories define the name itself.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">The thing I was thinking of doing was just adding them to the cache file, but order may be important here.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">Here is a very simple example:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">Master CMakeList:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">cmake_minimum_required(VERSION 2.8)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">project(test)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">add_subdirectory(lib2)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">add_subdirectory(lib)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">add_subdirectory(exe)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">lib2 CMakeList:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">cmake_minimum_required(VERSION 2.8)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">SET(PROJECT_LIB2 lib2 CACHE INTERNAL "lib2 project name")<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">add_library(${PROJECT_LIB2} SHARED file.cpp)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">target_link_libraries(${PROJECT_LIB2} ${PROJECT_LIB})<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">lib CMakeList:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">cmake_minimum_required(VERSION 2.8)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">SET(PROJECT_LIB lib CACHE INTERNAL "lib project name")<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">add_library(${PROJECT_LIB} STATIC file.cpp)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">exe CMakeList:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">cmake_minimum_required(VERSION 2.8)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">SET(PROJECT_EXE exe CACHE INTERNAL "exe project name")<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">add_executable(${PROJECT_EXE} file.cpp)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">target_link_libraries(${PROJECT_EXE} ${PROJECT_LIB2})<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">In this simple example, lib is never seen by lib2 and added as a dependant because the cache entry has not yet been evaluated.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">I thought that there was first a configuration step to acquire all variables of and stuff them into the cache file and then the generation step would use these values to generate the file output,
but that is not happening as can be seen in the example above. I am using CMake 2.8.11.1 when conducting this test and generating a VS2010 project.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">During our restructuring efforts, we are making a full attempt at trying to not have these kind of situations come up, but we live in the real world and not an ideal world. Outside of using the –C
option or restructuring again, is there anything I can do to accomplish what I am trying to do? Is there a mechanism to delay reading from the cache until the configuration step has finished?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">Thanks.<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-family:"Courier New"">Ryan H. Kawicki</span><span style="font-size:8.0pt;font-family:"Courier New""><o:p></o:p></span></p>
</div>
</body>
</html>