[CMake] How to assign version numbers from a source header to CMake variables?

David Cole david.cole at kitware.com
Mon Jan 17 11:37:32 EST 2011


Markus,

Please discuss things on the CMake mailing list and wait (sometimes a few
days are necessary for a discussion to evolve and resolve itself into a
conclusion) until there is a consensus about a course of action among the
people discussing it on the mailing list before you bring things up in the
CMake bug tracker.

The bug tracker is meant to help us track what bugs are going to be fixed in
the upcoming releases of CMake. It is not good as a general discussion
mechanism because only a handful of CMake developers actually peruse the new
issues in there. Whereas hundreds (and even thousands) of people read the
CMake mailing list regularly.

If there is a specific problem with CMake's actual functionality, then it
belongs in the bug tracker as an issue.


Thanks for your help to make CMake better,

David Cole
Kitware, Inc.



On Mon, Jan 17, 2011 at 11:30 AM, SF Markus Elfring <
elfring at users.sourceforge.net> wrote:

> Here is the code:
>>
>
> I have found and implemented a solution that can extract data from a header
> file with the "help" from evaluation of regular expressions.
>
> file(STRINGS "${CPPCHECK_SOURCE_DIR}/lib/library_version.h"
>     CPPCHECK_BUILD_SPECIFICATION REGEX "^[ \t]*#define[
> \t]+CPPCHECK_LIBRARY_VERSION_[A-Z]+[ \t]+[0-9]+.*$")
>
> if(CPPCHECK_BUILD_SPECIFICATION)
>   message(STATUS "${CPPCHECK_BUILD_SPECIFICATION}")
>   foreach(item IN ITEMS MAJOR MINOR PATCH)
>      string(REGEX REPLACE ".*#define[ \t]+CPPCHECK_LIBRARY_VERSION_${item}[
> \t]+([0-9]+).*"
>             "\\1" XYZ ${CPPCHECK_BUILD_SPECIFICATION})
>      set("CPPCHECK_BUILD_VERSION_${item}" ${XYZ} CACHE STRING "Version
> number for the build of the Cppcheck software")
>   endforeach()
> else()
>   message(FATAL_ERROR "Data were not found for the required build
> specification.")
> endif()
>
>
> How do you think about any optimisation opportunities like it is mentioned
> in the feature request "Directly reading data from a file into variables"?
> http://public.kitware.com/Bug/view.php?id=11714
>
> Regards,
> Markus
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110117/5be4d1aa/attachment.htm>


More information about the CMake mailing list