aboutsummaryrefslogtreecommitdiff
path: root/src/fpm_backend.f90
diff options
context:
space:
mode:
authorSebastian Ehlert <28669218+awvwgk@users.noreply.github.com>2021-10-10 18:03:37 +0200
committerGitHub <noreply@github.com>2021-10-10 18:03:37 +0200
commitdf9b01a652a37b968e29d32c24f3c690f130e890 (patch)
tree51cecbcf3e2b6b5435e1006e988555415f0ef85e /src/fpm_backend.f90
parentd129243af8dbff5ff5771bea8162699743c2aca7 (diff)
parent6f816ad20ffe8897feec9a8a91ab8c7bf1d2d753 (diff)
downloadfpm-df9b01a652a37b968e29d32c24f3c690f130e890.tar.gz
fpm-df9b01a652a37b968e29d32c24f3c690f130e890.zip
Merge pull request #575 from awvwgk/build-dirs
Enable multiple build output directories
Diffstat (limited to 'src/fpm_backend.f90')
-rw-r--r--src/fpm_backend.f9018
1 files changed, 15 insertions, 3 deletions
diff --git a/src/fpm_backend.f90 b/src/fpm_backend.f90
index b559343..6cf4f2d 100644
--- a/src/fpm_backend.f90
+++ b/src/fpm_backend.f90
@@ -32,6 +32,7 @@ use fpm_error, only : fpm_stop
use fpm_environment, only: run, get_os_type, OS_WINDOWS
use fpm_filesystem, only: basename, dirname, join_path, exists, mkdir
use fpm_model, only: fpm_model_t
+use fpm_strings, only: string_t, operator(.in.)
use fpm_targets, only: build_target_t, build_target_ptr, FPM_TARGET_OBJECT, &
FPM_TARGET_C_OBJECT, FPM_TARGET_ARCHIVE, FPM_TARGET_EXECUTABLE
implicit none
@@ -50,11 +51,22 @@ subroutine build_package(targets,model)
type(build_target_ptr), allocatable :: queue(:)
integer, allocatable :: schedule_ptr(:), stat(:)
logical :: build_failed, skip_current
+ type(string_t), allocatable :: build_dirs(:)
+ type(string_t) :: temp
! Need to make output directory for include (mod) files
- if (.not.exists(join_path(model%output_directory,model%package_name))) then
- call mkdir(join_path(model%output_directory,model%package_name))
- end if
+ allocate(build_dirs(0))
+ do i = 1, size(targets)
+ associate(target => targets(i)%ptr)
+ if (target%output_dir .in. build_dirs) cycle
+ temp%s = target%output_dir
+ build_dirs = [build_dirs, temp]
+ end associate
+ end do
+
+ do i = 1, size(build_dirs)
+ call mkdir(build_dirs(i)%s)
+ end do
! Perform depth-first topological sort of targets
do i=1,size(targets)