aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Ehlert <28669218+awvwgk@users.noreply.github.com>2022-01-10 08:13:42 +0100
committerGitHub <noreply@github.com>2022-01-10 08:13:42 +0100
commit64ce7b9da5826b3b728d470ae11994c23e234440 (patch)
tree22b9b0c87c4455d2deb47b7f90f4d1d400be441a
parent32401f1fa1ed9d42e6a59d988a03fdf6f3fc9716 (diff)
downloadfpm-64ce7b9da5826b3b728d470ae11994c23e234440.tar.gz
fpm-64ce7b9da5826b3b728d470ae11994c23e234440.zip
Respect user provided main-files (#646)
- add example package for C-main
-rwxr-xr-xci/run_tests.sh4
-rw-r--r--example_packages/c_main/app/main.c5
-rw-r--r--example_packages/c_main/fpm.toml5
-rw-r--r--src/fpm_sources.f9016
4 files changed, 24 insertions, 6 deletions
diff --git a/ci/run_tests.sh b/ci/run_tests.sh
index ff477e7..9525422 100755
--- a/ci/run_tests.sh
+++ b/ci/run_tests.sh
@@ -98,5 +98,9 @@ pushd c_header_only
"$fpm" build
popd
+pushd c_main
+"$fpm" run
+popd
+
# Cleanup
rm -rf ./*/build
diff --git a/example_packages/c_main/app/main.c b/example_packages/c_main/app/main.c
new file mode 100644
index 0000000..398ec67
--- /dev/null
+++ b/example_packages/c_main/app/main.c
@@ -0,0 +1,5 @@
+int
+main (void)
+{
+ return 0;
+}
diff --git a/example_packages/c_main/fpm.toml b/example_packages/c_main/fpm.toml
new file mode 100644
index 0000000..eb18e9b
--- /dev/null
+++ b/example_packages/c_main/fpm.toml
@@ -0,0 +1,5 @@
+name = "c-main"
+
+[[executable]]
+name = "c-main"
+main = "main.c"
diff --git a/src/fpm_sources.f90 b/src/fpm_sources.f90
index f349a0e..af2870f 100644
--- a/src/fpm_sources.f90
+++ b/src/fpm_sources.f90
@@ -163,6 +163,7 @@ subroutine add_executable_sources(sources,executables,scope,auto_discover,error)
if (allocated(executables(i)%link)) then
sources(j)%link_libraries = executables(i)%link
end if
+ sources(j)%unit_type = FPM_UNIT_PROGRAM
cycle exe_loop
end if
@@ -170,12 +171,15 @@ subroutine add_executable_sources(sources,executables,scope,auto_discover,error)
end do
! Add if not already discovered (auto_discovery off)
- exe_source = parse_source(join_path(executables(i)%source_dir,executables(i)%main),error)
- exe_source%exe_name = executables(i)%name
- if (allocated(executables(i)%link)) then
- exe_source%link_libraries = executables(i)%link
- end if
- exe_source%unit_scope = scope
+ associate(exe => executables(i))
+ exe_source = parse_source(join_path(exe%source_dir,exe%main),error)
+ exe_source%exe_name = exe%name
+ if (allocated(exe%link)) then
+ exe_source%link_libraries = exe%link
+ end if
+ exe_source%unit_type = FPM_UNIT_PROGRAM
+ exe_source%unit_scope = scope
+ end associate
if (allocated(error)) return