[CMake] How to properly handle build version number in CMake script for project

Robert Dailey rcdailey.lists at gmail.com
Mon Apr 10 14:15:12 EDT 2017


Sorry you're right, this isn't working because -D creates a cache
entry for the variable, which breaks it.

So maybe more ideas on the configure_file() solution would be ideal...
unsetting the cache variable might work as well, I have to toy around
with this.

On Mon, Apr 10, 2017 at 12:48 PM, Bruce Stephens
<bruce.r.stephens at gmail.com> wrote:
> On Mon, Apr 10, 2017 at 5:04 PM, Robert Dailey <rcdailey.lists at gmail.com> wrote:
>> Actually I think your idea does work. Why do you think it won't? I'm
>> using it right now and so far it seems OK.
>
> I assumed (without testing, admittedly) is that it would fail if
> someone used -D to set the value,
> then changed some CMakeLists.txt file, then executed the build command
> again. I'd expect that
> to rerun cmake to update the build files and I'd fear that you'd then
> get BUILD_VERSION from
> the CMakeLists.txt file rather than the value explicitly set.
>
> However, I haven't tried it, and maybe it works fine (with the
> generators you care about) even without
> caching?


More information about the CMake mailing list