Skip to content

Commit ba65b21

Browse files
committed
[macOS] add dynamic library path from command line
1 parent f57a8b8 commit ba65b21

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/fpm.f90

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,12 @@ subroutine cmd_run(settings,test)
604604
if (settings%runner/=' ') run_cmd = settings%runner_command()//' '//run_cmd
605605
if (allocated(settings%args)) run_cmd = run_cmd//" "//settings%args
606606

607+
! System Integrity Protection will not propagate the .dylib environment variables
608+
! to the child process: add paths manually
609+
if (get_os_type()==OS_MACOS) run_cmd = "env DYLD_LIBRARY_PATH=" // &
610+
get_env("DYLD_LIBRARY_PATH","") // &
611+
" " // run_cmd
612+
607613
call run(run_cmd,echo=settings%verbose,exitstat=stat(i))
608614

609615
else

src/fpm_compiler.F90

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,6 +1126,7 @@ function get_install_name_flags(self, target_dir, target_name) result(flags)
11261126
class(compiler_t), intent(in) :: self
11271127
character(len=*), intent(in) :: target_dir, target_name
11281128
character(len=:), allocatable :: flags
1129+
character(len=:), allocatable :: library_file
11291130

11301131
if (get_os_type() /= OS_MACOS) then
11311132
flags = ""
@@ -1134,10 +1135,12 @@ function get_install_name_flags(self, target_dir, target_name) result(flags)
11341135

11351136
! Shared library basename (e.g., libfoo.dylib)
11361137
if (str_ends_with(target_name, ".dylib")) then
1137-
flags = " -Wl,-install_name,@rpath/" // target_name
1138+
library_file = target_name
11381139
else
1139-
flags = " -Wl,-install_name,@rpath/" // target_name // ".dylib"
1140+
library_file = library_filename(target_name,.true.,.false.,OS_MACOS)
11401141
end if
1142+
1143+
flags = " -Wl,-install_name,@rpath/" // library_file
11411144

11421145
end function get_install_name_flags
11431146

0 commit comments

Comments
 (0)