diff options
-rw-r--r-- | fpm/src/fpm/manifest.f90 | 7 | ||||
-rw-r--r-- | fpm/src/fpm/manifest/library.f90 | 10 | ||||
-rw-r--r-- | fpm/test/fpm_test/test_manifest.f90 | 8 |
3 files changed, 22 insertions, 3 deletions
diff --git a/fpm/src/fpm/manifest.f90 b/fpm/src/fpm/manifest.f90 index 5a8f595..ef75941 100644 --- a/fpm/src/fpm/manifest.f90 +++ b/fpm/src/fpm/manifest.f90 @@ -16,7 +16,7 @@ module fpm_manifest use fpm_error, only : error_t, fatal_error, file_not_found_error use fpm_toml, only : toml_table, read_package_file use fpm_manifest_test, only : test_config_t - use fpm_filesystem, only: join_path, exists, dirname + use fpm_filesystem, only: join_path, exists, dirname, is_dir implicit none private @@ -35,6 +35,7 @@ contains type(library_config_t), intent(out) :: self self%source_dir = "src" + self%include_dir = "include" end subroutine default_library @@ -140,7 +141,9 @@ contains ! Populate library in case we find the default src directory if (.not.allocated(package%library) .and. & - & exists(join_path(root, "src"))) then + & (is_dir(join_path(root, "src")) .or. & + & is_dir(join_path(root, "include")))) then + allocate(package%library) call default_library(package%library) end if diff --git a/fpm/src/fpm/manifest/library.f90 b/fpm/src/fpm/manifest/library.f90 index 6c4630d..4bcd363 100644 --- a/fpm/src/fpm/manifest/library.f90 +++ b/fpm/src/fpm/manifest/library.f90 @@ -5,6 +5,7 @@ !>```toml !>[library] !>source-dir = "path" +!>include-dir = "path" !>build-script = "file" !>``` module fpm_manifest_library @@ -22,6 +23,9 @@ module fpm_manifest_library !> Source path prefix character(len=:), allocatable :: source_dir + !> Include path prefix + character(len=:), allocatable :: include_dir + !> Alternative build script to be invoked character(len=:), allocatable :: build_script @@ -52,6 +56,7 @@ contains if (allocated(error)) return call get_value(table, "source-dir", self%source_dir, "src") + call get_value(table, "include-dir", self%include_dir, "include") call get_value(table, "build-script", self%build_script) end subroutine new_library @@ -80,7 +85,7 @@ contains call syntax_error(error, "Key "//list(ikey)%key//" is not allowed in library") exit - case("source-dir", "build-script") + case("source-dir", "include-dir", "build-script") continue end select @@ -116,6 +121,9 @@ contains if (allocated(self%source_dir)) then write(unit, fmt) "- source directory", self%source_dir end if + if (allocated(self%include_dir)) then + write(unit, fmt) "- include directory", self%include_dir + end if if (allocated(self%build_script)) then write(unit, fmt) "- custom build", self%build_script end if diff --git a/fpm/test/fpm_test/test_manifest.f90 b/fpm/test/fpm_test/test_manifest.f90 index 925eaf3..fc16d4d 100644 --- a/fpm/test/fpm_test/test_manifest.f90 +++ b/fpm/test/fpm_test/test_manifest.f90 @@ -183,6 +183,10 @@ contains & "Default library source-dir") if (allocated(error)) return + call check_string(error, package%library%include_dir, "include", & + & "Default library include-dir") + if (allocated(error)) return + end subroutine test_default_library @@ -579,6 +583,10 @@ contains & "Default library source-dir") if (allocated(error)) return + call check_string(error, library%include_dir, "include", & + & "Default library include-dir") + if (allocated(error)) return + end subroutine test_library_empty |