<div class="gmail_quote">On Tue, Mar 31, 2009 at 3:27 PM, BRM <span dir="ltr">&lt;<a href="mailto:bm_witness@yahoo.com">bm_witness@yahoo.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Notice my original API suggestion - the project controls its own header - just not the list of available items.<br>
<br>
So essentially:<br>
<br>
1) Cmake runs, finds packages, builds list<br>
2) user add extra items to list<br>
3) header generated<br>
<br>
Noting from my original API example:<br>
<br>
cmake_autoheader(C, path/to/cmake/autoheader_output1.h some_other_package )<br>
cmake_autoheader(C, path/to/cmake/autoheader_output2.h some_other_package )<br>
cmake_autoheader(C, path/to/cmake/autoheader_output3.h some_other_package )<br>
<br>
Adding in the filtering as I suggested:<br>
<br>
cmake_autoheader(C, path/to/cmake/autoheader_output1.h some_other_package [filter 1])<br>
cmake_autoheader(C, path/to/cmake/autoheader_output2.h some_other_package [filter 2])<br>
cmake_autoheader(C, path/to/cmake/autoheader_output3.h some_other_package [filter 3])<br>
<br>
Each project could easily define its own header (or headers) - there would be no limit. And it should probably generate the header immediately based on when the cmake_autoheader() is called, based on the state of the list at that point. (I think it would be too complex to push it until the end of the file; but that might be possible too.)<br>

<br>
As to resolving between sub-projects, it would likely be good to internally register a scope for the variables - the scope being the path from the root CMakeLists.txt to the present one. If a parent, sibling, or child node wanted to access a different node&#39;s variables, it would have to do so using the filters and explicitly name the path. This would be easy to do in the filters as the project designer would know the paths between the projects. The output in the header would be no different - just the #define HAS_VARIABLE no matter what node it was in.<br>

<br>
So take the following:<br>
<br>
src/CMakeLists.txt<br>
src/subdir1/CMakeLists.txt<br>
src/subdir1/subdir1a/CMakeLists.txt<br>
src/subdir2/CMakeLists.txt<br>
<br>
src/subdir1/CMakeLists.txt would be able to access its variables with no scoping whatsoever. But to access a variable in src/CMakeLists.txt, it would have to provide explicit scoping to it via a filter when generating the autoheader via cmake_autoheader(). It would need to do the same to access variables in either src/subdir1/subdir1a/CMakeLists.txt and src/subdir2/CMakeLists.txt.<br>

<br>
However, I would only guarantee that the cmake_autoheader() would be able to get what is in the global list at the time it is run. So src/subdir1/CMakeLists.txt would likely not be able to see src/subdir2/CMakeLists.txt&#39;s variables, or all of the variables in src/CMakeLists.txt (as some may be defined after src/subdir1/CMakeLists.txt is run). It could control what it or its child nodes know though - based on when it makes the call, but that can be left to the project designer.</blockquote>
<div><br>Why not simply make cmake_autoheader() reentrant (and I assume a command) and have it process last?  This would solve one of your critiques of not having to pass lists around.  You could also eliminate the need to specify the filename everywhere and a logical name could be used.  It would presumably call the functionality provided by configure_file() internally per logical name.<br>
<br>cmake_autoheader(INIT myconfig ${CMAKE_CURRENT_BINARY_DIR}/config.h)<br>cmake_autoheader(CONFIG myconfig<br>      ... stuff like we already have ...)<br><br>add_subdirectory(foo)<br>     foo/ =&gt;  cmake_autoheader(CONFIG myconfig<br>
                ... add additional stuff)<br><br>I hear you on trying to automatically add #cmakedefine variables to a list.  Ultimately I think Bill and co. are right that trying to retrofit find_package() and any other place where you may (or may not) want to add a #cmakedefine like check_function_exists, etc. is simply going to be too complex.  Also as for find_package() someone out there will certainly want HAVE_OPENSCENEGRAPH to work instead of HAVE_OSG or HAVE_OSG2 or whatever.  You seem to like HAS_FOO, others probably prefer USE_FOO or HAVE_FOO_H.  Clearly we&#39;re never all going to agree.<br>
<br>Even if it was easy to do this there is another risk.  Users won&#39;t care to really define which variables they want #cmakedefined or not so they&#39;ll simply define everything.  Then you&#39;ll end up with what GNU autotools seems to do now which is to create a ginormous <a href="http://config.h.in">config.h.in</a> file for pretty much anything you type in <a href="http://configure.ac">configure.ac</a>.  Trying to wade through which of these #defines are actually necessary or not is an annoying exercise in the use of grep.  Also many of these #defines are superfluous on modern compilers/platforms.<br>
<br></div></div>-- <br>Philip Lowman<br>