Skip to content

Commit f85a458

Browse files
committed
Fix include flags for c objects
1 parent c957b27 commit f85a458

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/fpm_backend.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ subroutine build_target(model,target)
242242
// " -o " // target%output_file)
243243

244244
case (FPM_TARGET_C_OBJECT)
245-
call run(model%c_compiler//" -c " // target%source%file_name &
245+
call run(model%c_compiler//" -c " // target%source%file_name // target%compile_flags &
246246
// " -o " // target%output_file)
247247

248248
case (FPM_TARGET_EXECUTABLE)

src/fpm_targets.f90

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ subroutine resolve_target_linking(targets, model)
445445

446446
integer :: i
447447
character(:), allocatable :: global_link_flags
448-
character(:), allocatable :: global_compile_flags
448+
character(:), allocatable :: global_include_flags
449449

450450
if (size(targets) == 0) return
451451

@@ -455,17 +455,16 @@ subroutine resolve_target_linking(targets, model)
455455
allocate(character(0) :: global_link_flags)
456456
end if
457457

458-
global_compile_flags = model%fortran_compile_flags
459-
460458
if (allocated(model%link_libraries)) then
461459
if (size(model%link_libraries) > 0) then
462460
global_link_flags = global_link_flags // " -l" // string_cat(model%link_libraries," -l")
463461
end if
464462
end if
465463

464+
allocate(character(0) :: global_include_flags)
466465
if (allocated(model%include_dirs)) then
467466
if (size(model%include_dirs) > 0) then
468-
global_compile_flags = global_compile_flags // &
467+
global_include_flags = global_include_flags // &
469468
& " -I" // string_cat(model%include_dirs," -I")
470469
end if
471470
end if
@@ -474,7 +473,11 @@ subroutine resolve_target_linking(targets, model)
474473

475474
associate(target => targets(i)%ptr)
476475

477-
target%compile_flags = global_compile_flags
476+
if (target%target_type /= FPM_TARGET_C_OBJECT) then
477+
target%compile_flags = model%fortran_compile_flags//" "//global_include_flags
478+
else
479+
target%compile_flags = global_include_flags
480+
end if
478481

479482
allocate(target%link_objects(0))
480483

0 commit comments

Comments
 (0)