Skip to content

Commit 60d151f

Browse files
committed
Check if the package is actually installable for fpm-install
1 parent 657318e commit 60d151f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

fpm/src/fpm/cmd/install.f90

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module fpm_cmd_install
22
use fpm, only : build_model
33
use fpm_backend, only : build_package
44
use fpm_command_line, only : fpm_install_settings
5-
use fpm_error, only : error_t
5+
use fpm_error, only : error_t, fatal_error
66
use fpm_filesystem, only : join_path, list_files
77
use fpm_installer, only : installer_t, new_installer
88
use fpm_manifest, only : package_config_t, get_package_data
@@ -25,13 +25,21 @@ subroutine cmd_install(settings)
2525
type(fpm_model_t) :: model
2626
type(installer_t) :: installer
2727
character(len=:), allocatable :: lib, exe, dir
28+
logical :: installable
2829

2930
call get_package_data(package, "fpm.toml", error, apply_defaults=.true.)
3031
call handle_error(error)
3132

3233
call build_model(model, settings%fpm_build_settings, package, error)
3334
call handle_error(error)
3435

36+
installable = (allocated(package%library) .and. package%install%library) &
37+
.or. allocated(package%executable)
38+
if (.not.installable) then
39+
call fatal_error(error, "Project does not contain any installable targets")
40+
call handle_error(error)
41+
end if
42+
3543
if (.not.settings%no_rebuild) then
3644
call build_package(model)
3745
end if
@@ -114,7 +122,7 @@ end function is_module_file
114122
subroutine handle_error(error)
115123
type(error_t), intent(in), optional :: error
116124
if (present(error)) then
117-
print '(a)', error%message
125+
print '("[Error]", 1x, a)', error%message
118126
error stop 1
119127
end if
120128
end subroutine handle_error

0 commit comments

Comments
 (0)