[CMake] autoheader

Bill Hoffman bill.hoffman at kitware.com
Tue Mar 31 12:26:04 EDT 2009


BRM wrote:
> How about:
> 
> 
> # Each variable can have a registered filter name - packages/programs/libraries would use their name
> cmake_autoheader_add_variable(has_some_other_package, filter_name)
> # user controls what the output file is
> #     User can generate a C #define method (default method if no language is specified)
> cmake_autoheader(C, path/to/cmake/autoheader_output.h [filter_name_list])
> #    User can generate a C++ const methods
> cmake_autoheader(CXX, path/to/cmake/autoheader_output.hpp [filter_name_list])
> 
> - if filter name list is not provided, all entries are entered into the header file
> - if filter is list is provided:
>      - if name listed and is preceeded by an exclamation (!) then that name is not entered
>      - if name is listed then it is entered
>      - if name is not listed, then it is not entered
> 
> Likely it would be good to have a parameter that would specify the default behavior of the filter list - enter or not enter - for names not listed.
> I think a default of 'not enter' would be good if the list is being provided, and this could be overridden and then the list becomes a 'not enter' list.
> 
> So:
> 
> # package defines its own automatically
> find_package(some package)
>    if (some_package_found)
>        -> cmake_autoheader_add_variable(has_some_package, some_package)
> ...
> # user can add it too
> cmake_autoheader_add_variable(has_some_other_package, some_other_package)
> 
> # user controls what the output file is
> #     User can generate a C #define method (default method if no language is specified)
> cmake_autoheader(C, path/to/cmake/autoheader_output.h some_other_package)
> #    User can generate a C++ const methods
> cmake_autoheader(CXX, path/to/cmake/autoheader_output.hpp some_package)
> 
> 
> just another 2 cents...
> 
I am not sure where things would be stored in this API?  Seems to global

Maybe the autoheader should be some sort of target...

cmake_add_autoheader(C /path/to/cmake/autoheader_output.h)
cmake_add_autoheader_variable(/path/to/cmake/autoheader_output.h VAR)


-Bill



More information about the CMake mailing list