perlmakefilemakemaker

Is it possible to setup the cross module version in VERSION_FROM option (of Makefile.PL)?


I want to setup the same version for few projects in one place. I've tried:

use ExtUtils::MakeMaker;

WriteMakefile(
    VERSION_FROM => 'lib/project/version.pm',
    ...

In 'lib/project/version.pm':

package project::version;
use AnotherProject;
our $VERSION = AnotherProject->VERSION();
1;

Note: AnotherProject is located in separate directory, but could be loaded by 'use AnotherProject'. And contain 'our $VERSION="1.00"'.

$ perl Makefile.PL
WARNING: Setting VERSION via file 'lib/project/version.pm' failed
 at /usr/lib64/perl5/5.18.2/ExtUtils/MakeMaker.pm line 599.
Can't parse version 'undef'

Is it possible to pass (get) the version string from another module?

Maybe there is another way to do it, please support me.


Solution

  • When you use VERSION_FROM, ExtUtils::MakeMaker doesn't run the file you point at, it parses it itself and tries to find a version number that way. In this case, that won't work. Using VERSION instead of VERSION_FROM in Makefile.PL and calling the other module from there should work.