diff options
author | LKedward <laurence.kedward@bristol.ac.uk> | 2021-03-07 10:56:09 +0000 |
---|---|---|
committer | LKedward <laurence.kedward@bristol.ac.uk> | 2021-03-07 10:56:09 +0000 |
commit | 240c8cd59ab0554c075af8ee7ab9893ee9bf2aab (patch) | |
tree | 643099cd0776d050be74fc138d04706120aacd9c | |
parent | d958be18680001cd752ccb8196450d2f8ea5e9ed (diff) | |
download | fpm-240c8cd59ab0554c075af8ee7ab9893ee9bf2aab.tar.gz fpm-240c8cd59ab0554c075af8ee7ab9893ee9bf2aab.zip |
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.
-rw-r--r-- | fpm/src/fpm.f90 | 23 | ||||
-rw-r--r-- | 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(*,*)'<INFO>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(:) |