@@ -198,15 +198,14 @@ subroutine build_target_list(targets,model)
198198 character (:), allocatable :: exe_dir, compile_flags
199199 logical :: with_lib
200200
201+ ! Initialize targets
202+ allocate (targets(0 ))
203+
201204 ! Check for empty build (e.g. header-only lib)
202205 n_source = sum ([(size (model% packages(j)% sources), &
203206 j= 1 ,size (model% packages))])
204207
205- if (n_source < 1 ) then
206- allocate (targets(0 ))
207- return
208- end if
209-
208+ if (n_source < 1 ) return
210209
211210 with_lib = any ([((model% packages(j)% sources(i)% unit_scope == FPM_SCOPE_LIB, &
212211 i= 1 ,size (model% packages(j)% sources)), &
@@ -826,7 +825,7 @@ subroutine resolve_target_linking(targets, model)
826825 if (.not. allocated (target % compile_flags)) allocate (character (len= 0 ) :: target % compile_flags)
827826
828827 target % compile_flags = target % compile_flags// ' '
829-
828+
830829 select case (target % target_type)
831830 case (FPM_TARGET_C_OBJECT)
832831 target % compile_flags = target % compile_flags// model% c_compile_flags
@@ -835,7 +834,7 @@ subroutine resolve_target_linking(targets, model)
835834 case default
836835 target % compile_flags = target % compile_flags// model% fortran_compile_flags &
837836 & // get_feature_flags(model% compiler, target % features)
838- end select
837+ end select
839838
840839 ! > Get macros as flags.
841840 target % compile_flags = target % compile_flags // get_macros(model% compiler% id, &
0 commit comments