Alien-proj

 view release on metacpan or  search on metacpan

alienfile  view on Meta::CPAN

    @sqlite_extra_args,
    #'-DSQLITE3_INCLUDE_DIR=??',
    #'-DSQLITE3_LIBRARY=??',
    "-DENABLE_CURL=$enable_curl",
    $enable_curl eq 'ON' ? @curl_extra_args : (),
    "-DENABLE_TIFF=$enable_tiff",
    $enable_tiff eq 'ON' ? @tiff_extra_args : (),
    '-DBUILD_PROJSYNC=OFF',
    #'-DENABLE_IPO=ON',
    #'-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=true',
    '-DCMAKE_INSTALL_PREFIX:PATH=%{.install.prefix}',
    '-DCMAKE_BUILD_TYPE=Release',
    @rpath,
    #'-DCMAKE_VERBOSE=ON',
    '..'
  ];
    
  build [
    #\&pause,
    'mkdir _build',
    'cd _build',
    $cmake_cmd,
    $make_cmd,
    #($run_tests ? '%{make} test' : ()),
    $make_inst_cmd,
  ];


};


#  git for windows clashes with MSYS
#  if its /usr/bin dir is in the path
sub remove_gitfw_from_path {
  my ($orig, $build, @args) = @_;

  return $orig->($build, @args)
    if !$on_windows;

  local $ENV{PATH} = $ENV{PATH};

  my $msys_path = eval {
    path('Alien::MSYS'->msys_path())
  };
  return if !defined $msys_path;
  my $count = @PATH;

  @PATH
    = grep {path($_)->stringify =~ m|/usr/bin$| && path($_) ne $msys_path ? () : $_}
      @PATH;

  my $removed = $count - @PATH;
  if ($removed) {
    $build->log ("$removed additional .../usr/bin dirs were removed from the path for compilation");
  }

  $orig->($build, @args);
}


sub update_pkg_conf_path {
  return;
    return if !$on_windows;
    #  should be a before or around hook
    use Env qw /@PKG_CONFIG_PATH/;
    say 'Modifying drive paths in PKG_CONFIG_PATH';
    say $ENV{PKG_CONFIG_PATH};
    #  msys-ificate drive paths
    @PKG_CONFIG_PATH = map {my $r=$_; $r=~s{^([a-z]):}{/$1}i; $r} @PKG_CONFIG_PATH;
    #  make sure we get the dynamic libcurl
    #  (although the proj configure script does not currently use it)
    @PKG_CONFIG_PATH
      = map {my $r=$_; $r=~s{Alien-curl[/\\]lib[/\\]pkgconfig}{Alien-curl/dynamic/pkgconfig}i; $r}
        @PKG_CONFIG_PATH;
    $ENV{PKG_CONFIG_PATH} = join ':', @PKG_CONFIG_PATH;
    say $ENV{PKG_CONFIG_PATH};
    return;
}

sub pause {
    return;  #  re-enable in case of debug
    return if $on_automated_rig;
    return if !$on_windows;

    say "CONTINUE?";
    my $response = <>;
    while (not $response =~ /yes/) {
        $response = <>;
    }
}

sub update_cmake_lists_file {
    my ($orig, $build, @args) = @_;

    #  only needed on windows for v9.0.0 or earlier
    return $orig->($build, @args)
      if $on_windows and versioncmp (get_proj_version(), '9.0.0') < 0; 

    $build->log ('updating CMakeLists.txt to properly handle proj.pc');
    
    #my $h = $build->install_prop;
    #use Data::Printer;
    #p $h;
    
    use File::Find::Rule;
    my ($cmake_lists_file)
      = File::Find::Rule
                ->file()
                ->name( 'CMakeLists.txt' )
                ->in( $build->install_prop->{extract} );
    #$build->log ("====\ncmake file: $cmake_lists_file \n ====");
    open my $fh , '<', $cmake_lists_file
      or die "Could not open $cmake_lists_file for reading, $!";
    my $file_contents;

    my $define_check = <<EOD
if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
  set(CMAKE_INSTALL_LIBDIR lib)
endif(NOT DEFINED CMAKE_INSTALL_LIBDIR)
EOD
  ;
  
    while (my $line = <$fh>) {
        if ($line =~ /^\s*configure_proj_pc/) {
#say STDERR "ADDING TO CMAKE LISTS"; 
          $line .= $define_check;
        }
        $file_contents .= $line;
    }
    $fh->close;

    rename $cmake_lists_file, "$cmake_lists_file.bak";
    open my $ofh, '>', $cmake_lists_file
      or die "Could not open $cmake_lists_file for writing, $!";
    print {$ofh} $file_contents;
    $ofh->close or die $!;

    $orig->($build, @args);
}


sub find_lib_file {
  my %args = @_;
  
  my(@lib_files) = find_lib(
      %args,
      systempath => $args{alien} ? [] : undef,  #  only search the alien if one is passed
  );
  #  we grab the first, assuming they are
  #  all the same or point to the same origin
  my $libfile = $lib_files[0];
  $libfile =~ s|\\|/|g if $on_windows;

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 1.390 second using v1.00-cache-2.02-grep-82fe00e-cpan-1310916c57ae )