From 2e8606badeccbef91d1f04353e750d3a97ea72b8 Mon Sep 17 00:00:00 2001 From: Sebastian Ehlert <28669218+awvwgk@users.noreply.github.com> Date: Thu, 15 Apr 2021 16:56:24 +0200 Subject: [PATCH 1/2] Allow to find include files / modules in CPATH environment variable --- src/fpm_compiler.f90 | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/fpm_compiler.f90 b/src/fpm_compiler.f90 index a499bb9e18..ec6557125b 100644 --- a/src/fpm_compiler.f90 +++ b/src/fpm_compiler.f90 @@ -35,7 +35,10 @@ module fpm_compiler OS_WINDOWS, & OS_CYGWIN, & OS_SOLARIS, & - OS_FREEBSD + OS_FREEBSD, & + os_is_unix, & + get_env +use fpm_strings, only : split implicit none public :: is_unknown_compiler public :: get_module_flags @@ -310,6 +313,8 @@ subroutine get_module_flags(compiler, modpath, flags) case(id_caf, id_gcc, id_f95, id_cray) flags=' -J '//modpath//' -I '//modpath + call append_cpath(flags) + case(id_nvhpc, id_pgi, id_flang) flags=' -module '//modpath//' -I '//modpath @@ -439,4 +444,20 @@ function is_unknown_compiler(compiler) result(is_unknown) is_unknown = get_compiler_id(compiler) == id_unknown end function is_unknown_compiler +subroutine append_cpath(flags) + character(len=:), allocatable, intent(inout) :: flags + character(len=:), allocatable :: cpath, dirs(:) + integer :: i + cpath = get_env('CPATH') + if (len(cpath) > 0) then + call split(cpath, dirs, delimiters=merge(":", ";", os_is_unix())) + do i = 1, size(dirs) + ! dir can be an empty string for leading or trailing delimiters + if (len_trim(dirs(i)) > 0) then + flags = flags // ' -I ' // trim(dirs(i)) + end if + end do + end if +end subroutine append_cpath + end module fpm_compiler From e0767b4ad0f6f0944a2a000e5c6e1598812ec108 Mon Sep 17 00:00:00 2001 From: milancurcic Date: Sat, 17 Apr 2021 12:25:54 -0400 Subject: [PATCH 2/2] fix os_is_unix() --- src/fpm_environment.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fpm_environment.f90 b/src/fpm_environment.f90 index 0408ec4ec4..1b1ea0affb 100644 --- a/src/fpm_environment.f90 +++ b/src/fpm_environment.f90 @@ -121,7 +121,7 @@ logical function os_is_unix(os) result(unix) else build_os = get_os_type() end if - unix = os /= OS_WINDOWS + unix = build_os /= OS_WINDOWS end function os_is_unix !> echo command string and pass it to the system for execution