Alien-gdal

 view release on metacpan or  search on metacpan

alienfile  view on Meta::CPAN

    #  try not to exceed the cpan-testers log limits
    if ($on_automated_rig) {
      say "Running under CI or automated testing";
      $make_cmd      .= q/ | perl -ne "BEGIN {$|=1; open our $log, q|>|, q|build.log|};   print qq|\n| if 0 == ($. %% 100); print q|.|; print {$log} $_;" /;
      $make_inst_cmd .= q/ | perl -ne "BEGIN {$|=1; open our $log, q|>|, q|install.log|}; print qq|\n| if 0 == ($. %% 100); print q|.|; print {$log} $_;" /;
      if (!$on_windows) {
          $make_cmd =~ s/%%/%/;
          $make_cmd =~ s/"/'/g;
          $make_cmd .= ' || (E=$? && cat build.log && exit $E)';
          $make_inst_cmd =~ s/%%/%/;
          $make_inst_cmd =~ s/"/'/g;
          $make_inst_cmd .= ' || (E=$? && cat install.log && exit $E)';
      }
      else {
          #  fake exit codes on failure, not sure how to get originals
          $make_cmd      .= q/ || perl -e"system ('type', 'build.log'); exit 1"/;
          $make_inst_cmd .= q/ || perl -e"system ('type', 'install.log'); exit 1"/;
      }
  
      #  clean up the build dir on cpan testers etc
      plugin 'Cleanse::BuildDir';
    }
    
    my @with_args = (
      #https://gdal.org/build_hints.html#cmdoption-arg-GDAL_USE_-Packagename_in_upper_case-BOOL
      @automated_rig_config_args,
      '-DGDAL_USE_GEOTIFF_INTERNAL:BOOL=ON',  #  until we have an alien
      '-DGDAL_USE_MSSQL_ODBC=OFF',
      '-DGDAL_USE_MSSQL_NCLI=OFF',
      '-DGDAL_USE_MYSQL=OFF',
      '-DBUILD_CSHARP_BINDINGS:BOOL=OFF',
      '-DBUILD_PYTHON_BINDINGS:BOOL=OFF',
      '-DBUILD_JAVA_BINDINGS:BOOL=OFF',
      #'--without-pg',
      #'--without-ogdi',
      #'--with-mongocxxv3=no',
      #$^O eq 'MSWin32' ? '--without-hdf5' : (),  #  issues with strawberry perl hdf5 dlls
      '-DGDAL_SET_INSTALL_RELATIVE_RPATH=ON',
    );

    #  need to disable these on Macs under Homebrew - see GH#37
    if ($^O =~ /darwin/i && defined $ENV{HOMEBREW_PREFIX}) {
      push @with_args, qw /-DCMAKE_DISABLE_FIND_PACKAGE_Arrow=ON -DGDAL_USE_LIBKML=OFF/;
    }
    
    Alien::Build->log('LD_LIBRARY_PATH: ' . join ':', map {defined $_ ? $_ : ''} @LD_LIBRARY_PATH);
    my @ld_flags;
    my @ld_lib_path;
    my @cmake_prefix_path;
    #  system installs won't necessarily have dist dirs
    if (Alien::proj->install_type eq 'share') {
      push @cmake_prefix_path, path('Alien::proj'->dist_dir);
      push @with_args, '-DPROJ_INCLUDE_DIR=' . path (Alien::proj->dist_dir . '/include')->stringify;
      my $libfile = find_lib_file (
        lib   => 'proj',
        alien => 'Alien::proj',
      );
      #  windows proj has non-conformant lib name, libproj_9_0.dll
      #  and this fails the checks in FFI::CheckLib < 0.29
      if ($on_windows && !$libfile) {
        my @files = grep {/libproj/} glob (Alien::proj->bin_dir . '/*.dll');
        $libfile = shift @files;
        Alien::Build->log ("Secondary search for proj dynamic lib found $libfile");
      }
      push @with_args, '-DPROJ_LIBRARY_RELEASE=' . $libfile;
      
      my $proj_lib = Alien::proj->dist_dir . '/share/proj';
      warn "======\nno proj lib\n=====" if !-e $proj_lib;
      if (!grep {($_ // '')=~ /^$proj_lib$/} @PROJ_LIB) {
        Alien::Build->log ("Appending $proj_lib to \$ENV{PROJ_LIB}");
        push @PROJ_LIB, $proj_lib;
        Alien::Build->log ("PROJ_LIB is now $ENV{PROJ_LIB}");
      }
      if (!$on_windows) {
        my $dir = List::Util::first {-d $_} map {Alien::proj->dist_dir . "/$_"} (qw/lib lib64 lib32/);
        push @ld_lib_path, $dir if $dir;
      }
    }
    if (Alien::libtiff->install_type eq 'share') {
      push @cmake_prefix_path, path('Alien::libtiff'->dist_dir);
      my $libtiff_include = path ('Alien::libtiff'->dist_dir . '/include')->stringify;
      my $libfile = find_lib_file (
        lib   => 'tiff',
        alien => 'Alien::libtiff',
      );
      push @with_args, (
        "-DTIFF_LIBRARY=$libfile",
        "-DTIFF_INCLUDE_DIR=$libtiff_include",
      );
      if (!$on_windows) {
        push @ld_lib_path, (Alien::libtiff->dist_dir . '/lib');
      }
    }
    if ($have_spatialite && Alien::spatialite->install_type eq 'share') {
      push @cmake_prefix_path, path('Alien::spatialite'->dist_dir);
      #  need to check for this under cmake?
    }
    elsif (Alien::proj->install_type eq 'share') {
      #  spatialite depends on proj and this can cause grief if proj is a share install
      #  and spatialite is found by CMake
      #  https://gdal.org/en/latest/development/building_from_source.html#conflicting-proj-libraries
      push @with_args, '-DGDAL_USE_SPATIALITE=OFF';
    }

    if (Alien::sqlite->install_type eq 'share') {
      push @cmake_prefix_path, path('Alien::sqlite'->dist_dir);
      my $sqlite_include = path ('Alien::sqlite'->dist_dir . '/include')->stringify;
      my $libfile = find_lib_file (
          lib   => 'sqlite3',
          alien => 'Alien::sqlite',
      );
      # my $exe_extension = ($on_windows ? '.exe' : '');
      # my $sqlite_exe = path ('Alien::sqlite'->dist_dir . "/bin/sqlite3$exe_extension");
      push @with_args, (
        # "-DEXE_SQLITE3=$sqlite_exe",
        "-DSQLite3_LIBRARY=$libfile",
        "-DSQLite3_INCLUDE_DIR=$sqlite_include",
      );
      if (!$on_windows) {
        push @ld_lib_path, (Alien::sqlite->dist_dir . '/lib');
      }



( run in 0.488 second using v1.01-cache-2.11-cpan-e1769b4cff6 )