@@ -5,8 +5,11 @@ module fpm
5
5
use fpm_command_line, only: fpm_build_settings, fpm_new_settings, &
6
6
fpm_run_settings, fpm_install_settings, fpm_test_settings
7
7
use fpm_environment, only: run, get_os_type, OS_LINUX, OS_MACOS, OS_WINDOWS
8
- use fpm_filesystem, only: join_path, number_of_rows, list_files, exists, basename
9
- use fpm_model, only: srcfile_ptr, srcfile_t, fpm_model_t
8
+ use fpm_filesystem, only: is_dir, join_path, number_of_rows, list_files, exists, basename
9
+ use fpm_model, only: srcfile_ptr, srcfile_t, fpm_model_t, &
10
+ FPM_SCOPE_UNKNOWN, FPM_SCOPE_LIB, &
11
+ FPM_SCOPE_DEP, FPM_SCOPE_APP, FPM_SCOPE_TEST
12
+
10
13
use fpm_sources, only: add_executable_sources, add_sources_from_dir, &
11
14
resolve_module_dependencies
12
15
use fpm_manifest, only : get_package_data, default_executable, &
@@ -54,20 +57,38 @@ subroutine build_model(model, settings, package, error)
54
57
model% link_flags = ' '
55
58
56
59
! Add sources from executable directories
57
- if (allocated (package% executable)) then
60
+ if (is_dir(' app' ) .and. package% build_config% auto_executables) then
61
+ call add_sources_from_dir(model% sources,' app' , FPM_SCOPE_APP, &
62
+ with_executables= .true. , error= error)
63
+
64
+ if (allocated (error)) then
65
+ return
66
+ end if
58
67
59
- call add_executable_sources(model% sources, package% executable, &
60
- is_test= .false. , error= error)
68
+ end if
69
+ if (is_dir(' test' ) .and. package% build_config% auto_tests) then
70
+ call add_sources_from_dir(model% sources,' test' , FPM_SCOPE_TEST, &
71
+ with_executables= .true. , error= error)
61
72
62
73
if (allocated (error)) then
63
74
return
64
75
end if
65
76
66
77
end if
67
- if (allocated (package% test)) then
78
+ if (allocated (package% executable)) then
79
+ call add_executable_sources(model% sources, package% executable, FPM_SCOPE_APP, &
80
+ auto_discover= package% build_config% auto_executables, &
81
+ error= error)
82
+
83
+ if (allocated (error)) then
84
+ return
85
+ end if
68
86
69
- call add_executable_sources(model% sources, package% test, &
70
- is_test= .true. , error= error)
87
+ end if
88
+ if (allocated (package% test)) then
89
+ call add_executable_sources(model% sources, package% test, FPM_SCOPE_TEST, &
90
+ auto_discover= package% build_config% auto_tests, &
91
+ error= error)
71
92
72
93
if (allocated (error)) then
73
94
return
@@ -76,17 +97,16 @@ subroutine build_model(model, settings, package, error)
76
97
end if
77
98
78
99
if (allocated (package% library)) then
79
-
80
- call add_sources_from_dir(model% sources,package% library% source_dir, &
81
- error= error)
100
+ call add_sources_from_dir(model% sources, package% library% source_dir, &
101
+ FPM_SCOPE_LIB, error= error)
82
102
83
103
if (allocated (error)) then
84
104
return
85
105
end if
86
106
87
107
end if
88
108
89
- call resolve_module_dependencies(model% sources)
109
+ call resolve_module_dependencies(model% sources,error )
90
110
91
111
end subroutine build_model
92
112
@@ -107,8 +127,9 @@ subroutine cmd_build(settings)
107
127
call default_library(package% library)
108
128
end if
109
129
110
- ! Populate executable in case we find the default app directory
111
- if (.not. allocated (package% executable) .and. exists(" app" )) then
130
+ ! Populate executable in case we find the default app
131
+ if (.not. allocated (package% executable) .and. &
132
+ exists(join_path(' app' ," main.f90" ))) then
112
133
allocate (package% executable(1 ))
113
134
call default_executable(package% executable(1 ), package% name)
114
135
end if
0 commit comments