aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLKedward <laurence.kedward@bristol.ac.uk>2020-12-16 11:55:27 +0000
committerLKedward <laurence.kedward@bristol.ac.uk>2020-12-16 12:46:10 +0000
commitc99b2765f7e3496d742c2b265a6f9fe78c4f9e58 (patch)
treed5d6838e307abca9a1089b4b3cc3261e493f2e75
parent58cc2036e5af35c72e7864b5dd019c02dfd7ff23 (diff)
downloadfpm-c99b2765f7e3496d742c2b265a6f9fe78c4f9e58.tar.gz
fpm-c99b2765f7e3496d742c2b265a6f9fe78c4f9e58.zip
Fix: collision between app and example executables of the same name
Use a separate example subdirectory in 'build' to store example executables.
-rwxr-xr-xci/run_tests.bat3
-rwxr-xr-xci/run_tests.sh1
-rw-r--r--example_packages/with_examples/app/demo-prog.f903
-rw-r--r--example_packages/with_examples/demo/prog.f903
-rw-r--r--example_packages/with_examples/fpm.toml5
-rw-r--r--fpm/src/fpm_targets.f9026
6 files changed, 23 insertions, 18 deletions
diff --git a/ci/run_tests.bat b/ci/run_tests.bat
index 42f391c..9fcb63e 100755
--- a/ci/run_tests.bat
+++ b/ci/run_tests.bat
@@ -116,6 +116,9 @@ del /q /f build
%fpm_path% build
if errorlevel 1 exit 1
+.\build\gfortran_debug\example\demo-prog
+if errorlevel 1 exit 1
+
.\build\gfortran_debug\app\demo-prog
if errorlevel 1 exit 1
diff --git a/ci/run_tests.sh b/ci/run_tests.sh
index 7412fba..e32a41e 100755
--- a/ci/run_tests.sh
+++ b/ci/run_tests.sh
@@ -52,6 +52,7 @@ cd ../hello_complex_2
cd ../with_examples
"${f_fpm_path}" build
+./build/gfortran_debug/example/demo-prog
./build/gfortran_debug/app/demo-prog
cd ../auto_discovery_off
diff --git a/example_packages/with_examples/app/demo-prog.f90 b/example_packages/with_examples/app/demo-prog.f90
new file mode 100644
index 0000000..f26e898
--- /dev/null
+++ b/example_packages/with_examples/app/demo-prog.f90
@@ -0,0 +1,3 @@
+program demo
+ write(*, '(a)') "This is a simple program"
+end program demo
diff --git a/example_packages/with_examples/demo/prog.f90 b/example_packages/with_examples/demo/prog.f90
deleted file mode 100644
index 8b3d882..0000000
--- a/example_packages/with_examples/demo/prog.f90
+++ /dev/null
@@ -1,3 +0,0 @@
-program demo
- write(*, '(a)') "This is a simple demo program, but not a real application"
-end program demo
diff --git a/example_packages/with_examples/fpm.toml b/example_packages/with_examples/fpm.toml
index e10f783..a2b37b3 100644
--- a/example_packages/with_examples/fpm.toml
+++ b/example_packages/with_examples/fpm.toml
@@ -3,10 +3,5 @@ build.auto-examples = false
[[example]]
name = "demo-prog"
-source-dir = "demo"
-main = "prog.f90"
-
-[[example]]
-name = "example-prog"
source-dir = "example"
main = "prog.f90"
diff --git a/fpm/src/fpm_targets.f90 b/fpm/src/fpm_targets.f90
index f0c4f63..34f437f 100644
--- a/fpm/src/fpm_targets.f90
+++ b/fpm/src/fpm_targets.f90
@@ -62,7 +62,7 @@ subroutine targets_from_sources(model,sources)
type(srcfile_t), intent(in) :: sources(:)
integer :: i
- character(:), allocatable :: xsuffix
+ character(:), allocatable :: xsuffix, exe_dir
type(build_target_t), pointer :: dep
logical :: with_lib
@@ -99,18 +99,24 @@ subroutine targets_from_sources(model,sources)
source = sources(i) &
)
- if (any(sources(i)%unit_scope == [FPM_SCOPE_APP, FPM_SCOPE_EXAMPLE])) then
- call add_target(model%targets,type = FPM_TARGET_EXECUTABLE,&
- link_libraries = sources(i)%link_libraries, &
- output_file = join_path(model%output_directory,'app', &
- sources(i)%exe_name//xsuffix))
+ if (sources(i)%unit_scope == FPM_SCOPE_APP) then
+
+ exe_dir = 'app'
+
+ else if (sources(i)%unit_scope == FPM_SCOPE_EXAMPLE) then
+
+ exe_dir = 'example'
+
else
- call add_target(model%targets,type = FPM_TARGET_EXECUTABLE,&
+
+ exe_dir = 'test'
+
+ end if
+
+ call add_target(model%targets,type = FPM_TARGET_EXECUTABLE,&
link_libraries = sources(i)%link_libraries, &
- output_file = join_path(model%output_directory,'test', &
+ output_file = join_path(model%output_directory,exe_dir, &
sources(i)%exe_name//xsuffix))
-
- end if
! Executable depends on object
call add_dependency(model%targets(size(model%targets))%ptr, model%targets(size(model%targets)-1)%ptr)