aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLKedward <laurence.kedward@bristol.ac.uk>2021-03-07 10:56:09 +0000
committerLKedward <laurence.kedward@bristol.ac.uk>2021-03-07 10:56:09 +0000
commit240c8cd59ab0554c075af8ee7ab9893ee9bf2aab (patch)
tree643099cd0776d050be74fc138d04706120aacd9c
parentd958be18680001cd752ccb8196450d2f8ea5e9ed (diff)
downloadfpm-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.f9023
-rw-r--r--fpm/src/fpm_model.f903
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(:)