@@ -48,7 +48,7 @@ subroutine build_model(model, settings, package, error)
48
48
type (package_config_t), pointer :: manifest
49
49
character (len= :), allocatable :: file_name, lib_dir
50
50
logical :: has_cpp
51
- logical :: duplicates_found
51
+ logical :: duplicates_found, auto_exe, auto_example, auto_test
52
52
type (string_t) :: include_dir
53
53
54
54
model% package_name = package% name
@@ -71,9 +71,11 @@ subroutine build_model(model, settings, package, error)
71
71
call new_compiler_flags(model,settings)
72
72
model% build_dir = settings% build_dir
73
73
model% build_prefix = join_path(settings% build_dir, basename(model% compiler% fc))
74
- model% include_tests = settings% build_tests
75
- model% enforce_module_names = package% build% module_naming
76
- model% module_prefix = package% build% module_prefix
74
+ model% include_tests = settings% build_tests
75
+ if (allocated (package% build)) then
76
+ model% enforce_module_names = package% build% module_naming
77
+ model% module_prefix = package% build% module_prefix
78
+ endif
77
79
78
80
! Resolve meta-dependencies into the package and the model
79
81
call resolve_metapackages(model,package,settings,error)
@@ -159,18 +161,22 @@ subroutine build_model(model, settings, package, error)
159
161
end if
160
162
161
163
end if
164
+
165
+ if (allocated (manifest% build)) then
162
166
163
- if (allocated (manifest% build% link)) then
164
- model% link_libraries = [model% link_libraries, manifest% build% link]
165
- end if
167
+ if (allocated (manifest% build% link)) then
168
+ model% link_libraries = [model% link_libraries, manifest% build% link]
169
+ end if
166
170
167
- if (allocated (manifest% build% external_modules)) then
168
- model% external_modules = [model% external_modules, manifest% build% external_modules]
169
- end if
171
+ if (allocated (manifest% build% external_modules)) then
172
+ model% external_modules = [model% external_modules, manifest% build% external_modules]
173
+ end if
170
174
171
- ! Copy naming conventions from this dependency's manifest
172
- model% packages(i)% enforce_module_names = manifest% build% module_naming
173
- model% packages(i)% module_prefix = manifest% build% module_prefix
175
+ ! Copy naming conventions from this dependency's manifest
176
+ model% packages(i)% enforce_module_names = manifest% build% module_naming
177
+ model% packages(i)% module_prefix = manifest% build% module_prefix
178
+
179
+ endif
174
180
175
181
end associate
176
182
end do
@@ -180,7 +186,18 @@ subroutine build_model(model, settings, package, error)
180
186
if (has_cpp) call set_cpp_preprocessor_flags(model% compiler% id, model% fortran_compile_flags)
181
187
182
188
! Add sources from executable directories
183
- if (is_dir(' app' ) .and. package% build% auto_executables) then
189
+
190
+ if (allocated (package% build)) then
191
+ auto_exe = package% build% auto_executables
192
+ auto_example = package% build% auto_examples
193
+ auto_test = package% build% auto_tests
194
+ else
195
+ auto_exe = .true.
196
+ auto_example = .true.
197
+ auto_test = .true.
198
+ endif
199
+
200
+ if (is_dir(' app' ) .and. auto_exe) then
184
201
call add_sources_from_dir(model% packages(1 )% sources,' app' , FPM_SCOPE_APP, &
185
202
with_executables= .true. , with_f_ext= model% packages(1 )% preprocess% suffixes,&
186
203
error= error)
@@ -190,7 +207,7 @@ subroutine build_model(model, settings, package, error)
190
207
end if
191
208
192
209
end if
193
- if (is_dir(' example' ) .and. package % build % auto_examples ) then
210
+ if (is_dir(' example' ) .and. auto_example ) then
194
211
call add_sources_from_dir(model% packages(1 )% sources,' example' , FPM_SCOPE_EXAMPLE, &
195
212
with_executables= .true. , &
196
213
with_f_ext= model% packages(1 )% preprocess% suffixes,error= error)
@@ -200,7 +217,7 @@ subroutine build_model(model, settings, package, error)
200
217
end if
201
218
202
219
end if
203
- if (is_dir(' test' ) .and. package % build % auto_tests ) then
220
+ if (is_dir(' test' ) .and. auto_test ) then
204
221
call add_sources_from_dir(model% packages(1 )% sources,' test' , FPM_SCOPE_TEST, &
205
222
with_executables= .true. , &
206
223
with_f_ext= model% packages(1 )% preprocess% suffixes,error= error)
@@ -212,7 +229,7 @@ subroutine build_model(model, settings, package, error)
212
229
end if
213
230
if (allocated (package% executable)) then
214
231
call add_executable_sources(model% packages(1 )% sources, package% executable, FPM_SCOPE_APP, &
215
- auto_discover= package % build % auto_executables , &
232
+ auto_discover= auto_exe , &
216
233
with_f_ext= model% packages(1 )% preprocess% suffixes, &
217
234
error= error)
218
235
@@ -223,7 +240,7 @@ subroutine build_model(model, settings, package, error)
223
240
end if
224
241
if (allocated (package% example)) then
225
242
call add_executable_sources(model% packages(1 )% sources, package% example, FPM_SCOPE_EXAMPLE, &
226
- auto_discover= package % build % auto_examples , &
243
+ auto_discover= auto_example , &
227
244
with_f_ext= model% packages(1 )% preprocess% suffixes, &
228
245
error= error)
229
246
@@ -234,7 +251,7 @@ subroutine build_model(model, settings, package, error)
234
251
end if
235
252
if (allocated (package% test)) then
236
253
call add_executable_sources(model% packages(1 )% sources, package% test, FPM_SCOPE_TEST, &
237
- auto_discover= package % build % auto_tests , &
254
+ auto_discover= auto_test , &
238
255
with_f_ext= model% packages(1 )% preprocess% suffixes, &
239
256
error= error)
240
257
0 commit comments