I have a function that I define in my top-most CMakeLists.txt file (on Windows using CMake version 2.8.6) called define_project() that calls add_executable, sets up compile defintions, etc etc.<div><br></div><div>For each time define_project() is called *anywhere* in the directory hierarchy, I need to increment a global "project_count" variable to keep track of how many projects were created and print that at the very end of the root CMakeLists.txt file.</div>
<div><br></div><div>So far my attempts at this have been unsuccessful. I tried creating a cache variable in the root script:</div><div><br></div><div>set( project_count 0 CACHE INTERNAL "" )</div><div><br></div>
<div>Then inside of my function, I do this:</div><div><br></div><div>function( define_project ... )</div><div> math( EXPR count "${project_count}+1" )</div><div> set( project_count ${count} )</div><div>endfunction()</div>
<div><br></div><div>However, 'project_count' is always 0 each time that the function is executed.</div><div><br></div><div>How can I make this work?<br clear="all"><div><br></div><div>---------</div>Robert Dailey<br>
</div>