[CMake] cmake config.h

Michael Jackson mike.jackson at bluequartz.net
Sun Nov 28 10:21:45 EST 2010


Those variables are specific for the project you are trying to
convert. For example if this was the LibTiff project then you might
have something like:

#define PACKAGE    "libTif"
#define PACKAGE_BUGREPORT   "bugs at libtiff.com"
#define PACKAGE_VERSION   "8.9.10"

You can set these as CMake varables in your CMakeLists.txt file as the
following:

set (MY_PACKAGE "MyProject")

Then in the config.h.in you would have

#cmakedefine PACKAGE @MY_PACKAGE@

And do that for the remaining variables in the list you provided.

 Again, if this is an existing project that is well known then you
probably can not mess with the preprocessor #defines BUT if this is a
new project or if you have control over the project then I HIGHLY
recommend you use something like this:

#cmakedefine MYPROJECT_PACKAGE   "MyProject"

or somehow prefix or suffix those variables. I have had instances
where I have used several different packages where each one defined
PACKAGE which created some interesting side effects.

Hope that helps.

_________________________________________________________
Mike Jackson                  mike.jackson at bluequartz.net
BlueQuartz Software                    www.bluequartz.net
Principal Software Engineer                  Dayton, Ohio



On Sun, Nov 28, 2010 at 11:03 AM, luxInteg <lux-integ at btconnect.com> wrote:
> On Sunday 28 November 2010 14:04:50 luxInteg wrote:
>
>> headers, datatypes, functions  seem straight forward,  I currently have  a
>> config.h.in    refering to 'package' (I assume something to do with
>> pkgconfig )  for which  I  have not a clue how  to translate using the
>> tools above:- The said  problematic  config.h.in file  has lines like
>> these:-
>>
>> -----------------------------
>> /* Name of package */
>> #undef PACKAGE
>>
>> /* Define to the address where bug reports for this package should be sent.
>> */ #undef PACKAGE_BUGREPORT
>>
>> /* Define to the full name of this package. */
>> #undef PACKAGE_NAME
>>
>> /* Define to the full name and version of this package. */
>> #undef PACKAGE_STRING
>>
>> /* Define to the one symbol short name of this package. */
>> #undef PACKAGE_TARNAME
>>
>> /* Define to the version of this package. */
>> #undef PACKAGE_VERSION
>>
>> /* Version number of package */
>> #undef VERSION
>>
>> /* Define to empty if `const' does not conform to ANSI C. */
>> #undef const
>>
>> /* Define to rpl_malloc if the replacement function should be used. */
>> #undef malloc
>>
>> /* Define to rpl_realloc if the replacement function should be used. */
>> #undef realloc
>> -----------------------
>
> I came across the useful wiki
> http://www.cmake.org/Wiki/CMake:How_To_Write_Platform_Checks
>
> And I have also done some searching on the net to learn to  use
> CheckVariableExists.cmake to   set   arguments for  'PACKAGE' (if so required)
>  in config.h.  I have not been successful.  So I would be grateful if someone
> on list could   give an example of how CheckVariableExists.cmake  is used.
>


More information about the CMake mailing list