diff --git a/samples/clib/SConscript b/samples/clib/SConscript index 9aae544b9..345ee35d8 100644 --- a/samples/clib/SConscript +++ b/samples/clib/SConscript @@ -21,6 +21,11 @@ for programName, sources in samples: linkflags.append(f"-Wl,-rpath,{localenv['ct_shlibdir']}") libdirs.extend(localenv["extra_lib_dirs"]) + if env["OS"] == "Darwin" and env["use_rpath_linkage"] and not env.subst("$__RPATH"): + # SCons fails to specify RPATH on macOS, so circumvent that behavior by + # specifying this directly as part of LINKFLAGS + linkflags.extend(env.subst(f'$RPATHPREFIX{d}$RPATHSUFFIX') for d in libdirs) + localenv["tmpl_compiler_flags"] = repr(localenv["CCFLAGS"]) localenv['tmpl_cantera_incdirs'] = repr([x for x in incdirs if x]) localenv['tmpl_cantera_libs'] = repr(localenv['cantera_shared_libs']) diff --git a/samples/cxx/SConscript b/samples/cxx/SConscript index d0b0de2b4..578f5493e 100644 --- a/samples/cxx/SConscript +++ b/samples/cxx/SConscript @@ -71,6 +71,12 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS} libdirs.extend(localenv["extra_lib_dirs"]) libdirs = list(set(libdirs)) + if env["OS"] == "Darwin" and env["use_rpath_linkage"] and not env.subst("$__RPATH"): + # SCons fails to specify RPATH on macOS, so circumvent that behavior by + # specifying this directly as part of LINKFLAGS + localenv.Append(LINKFLAGS=[env.subst(f'$RPATHPREFIX{d}$RPATHSUFFIX') + for d in libdirs]) + cc_flags = compiler_flag_list(localenv["CCFLAGS"] + localenv["CXXFLAGS"], flag_excludes) localenv["tmpl_compiler_flags"] = repr(cc_flags)