From 240c8cd59ab0554c075af8ee7ab9893ee9bf2aab Mon Sep 17 00:00:00 2001 From: LKedward Date: Sun, 7 Mar 2021 10:56:09 +0000 Subject: Update: model with list of include dirs A library package must consist of at least a source directory, an include directory or both. Default values of "src" and "include" are ignored if non-existent. --- fpm/src/fpm.f90 | 23 +++++++++++++++++++---- fpm/src/fpm_model.f90 | 3 +++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/fpm/src/fpm.f90 b/fpm/src/fpm.f90 index 68385cd..8557869 100644 --- a/fpm/src/fpm.f90 +++ b/fpm/src/fpm.f90 @@ -42,6 +42,7 @@ subroutine build_model(model, settings, package, error) integer :: i type(package_config_t) :: dependency character(len=:), allocatable :: manifest, lib_dir + type(string_t) :: include_dir if(settings%verbose)then write(*,*)'BUILD_NAME:',settings%build_name @@ -50,6 +51,7 @@ subroutine build_model(model, settings, package, error) model%package_name = package%name + allocate(model%include_dirs(0)) allocate(model%link_libraries(0)) call new_dependency_tree(model%deps, cache=join_path("build", "cache.toml")) @@ -141,10 +143,23 @@ subroutine build_model(model, settings, package, error) model%packages(i)%name = dependency%name if (allocated(dependency%library)) then - lib_dir = join_path(dep%proj_dir, dependency%library%source_dir) - call add_sources_from_dir(model%packages(i)%sources, lib_dir, FPM_SCOPE_LIB, & - error=error) - if (allocated(error)) exit + + if (allocated(dependency%library%source_dir)) then + lib_dir = join_path(dep%proj_dir, dependency%library%source_dir) + if (is_dir(lib_dir)) then + call add_sources_from_dir(model%packages(i)%sources, lib_dir, FPM_SCOPE_LIB, & + error=error) + if (allocated(error)) exit + end if + end if + + if (allocated(dependency%library%include_dir)) then + include_dir%s = join_path(dep%proj_dir, dependency%library%include_dir) + if (is_dir(include_dir%s)) then + model%include_dirs = [model%include_dirs, include_dir] + end if + end if + end if if (allocated(dependency%build%link)) then diff --git a/fpm/src/fpm_model.f90 b/fpm/src/fpm_model.f90 index 072ac5f..bfb0115 100644 --- a/fpm/src/fpm_model.f90 +++ b/fpm/src/fpm_model.f90 @@ -123,6 +123,9 @@ type :: fpm_model_t !> Base directory for build character(:), allocatable :: output_directory + !> Include directories + type(string_t), allocatable :: include_dirs(:) + !> Native libraries to link against type(string_t), allocatable :: link_libraries(:) -- cgit v1.2.3