@@ -35,7 +35,8 @@ module fpm_targets
35
35
private
36
36
37
37
public FPM_TARGET_UNKNOWN, FPM_TARGET_EXECUTABLE, &
38
- FPM_TARGET_ARCHIVE, FPM_TARGET_OBJECT
38
+ FPM_TARGET_ARCHIVE, FPM_TARGET_OBJECT, &
39
+ FPM_TARGET_C_OBJECT
39
40
public build_target_t, build_target_ptr
40
41
public targets_from_sources, resolve_module_dependencies
41
42
public resolve_target_linking, add_target, add_dependency
@@ -50,7 +51,8 @@ module fpm_targets
50
51
integer , parameter :: FPM_TARGET_ARCHIVE = 2
51
52
! > Target type is compiled object
52
53
integer , parameter :: FPM_TARGET_OBJECT = 3
53
-
54
+ ! > Target type is c compiled object
55
+ integer , parameter :: FPM_TARGET_C_OBJECT = 4
54
56
55
57
! > Wrapper type for constructing arrays of `[[build_target_t]]` pointers
56
58
type build_target_ptr
@@ -194,7 +196,8 @@ subroutine build_target_list(targets,model)
194
196
case (FPM_UNIT_MODULE,FPM_UNIT_SUBMODULE,FPM_UNIT_SUBPROGRAM,FPM_UNIT_CSOURCE)
195
197
196
198
call add_target(targets,source = sources(i), &
197
- type = FPM_TARGET_OBJECT,&
199
+ type = merge (FPM_TARGET_C_OBJECT,FPM_TARGET_OBJECT,&
200
+ sources(i)% unit_type== FPM_UNIT_CSOURCE), &
198
201
output_file = get_object_name(sources(i)))
199
202
200
203
if (with_lib .and. sources(i)% unit_scope == FPM_SCOPE_LIB) then
@@ -448,7 +451,7 @@ subroutine resolve_target_linking(targets, model)
448
451
449
452
integer :: i
450
453
character (:), allocatable :: global_link_flags
451
- character (:), allocatable :: global_compile_flags
454
+ character (:), allocatable :: global_include_flags
452
455
453
456
if (size (targets) == 0 ) return
454
457
@@ -458,17 +461,16 @@ subroutine resolve_target_linking(targets, model)
458
461
allocate (character (0 ) :: global_link_flags)
459
462
end if
460
463
461
- global_compile_flags = model% fortran_compile_flags
462
-
463
464
if (allocated (model% link_libraries)) then
464
465
if (size (model% link_libraries) > 0 ) then
465
466
global_link_flags = global_link_flags // " -l" // string_cat(model% link_libraries," -l" )
466
467
end if
467
468
end if
468
469
470
+ allocate (character (0 ) :: global_include_flags)
469
471
if (allocated (model% include_dirs)) then
470
472
if (size (model% include_dirs) > 0 ) then
471
- global_compile_flags = global_compile_flags // &
473
+ global_include_flags = global_include_flags // &
472
474
& " -I" // string_cat(model% include_dirs," -I" )
473
475
end if
474
476
end if
@@ -477,7 +479,11 @@ subroutine resolve_target_linking(targets, model)
477
479
478
480
associate(target = > targets(i)% ptr)
479
481
480
- target % compile_flags = global_compile_flags
482
+ if (target % target_type /= FPM_TARGET_C_OBJECT) then
483
+ target % compile_flags = model% fortran_compile_flags// " " // global_include_flags
484
+ else
485
+ target % compile_flags = global_include_flags
486
+ end if
481
487
482
488
allocate (target % link_objects(0 ))
483
489
0 commit comments