[SCons] Workaround for SCons ignoring RPATH in sample SConstruct files

This commit is contained in:
Ray Speth 2023-08-17 09:47:33 -04:00 committed by Ingmar Schoegl
parent cb02c5ccbb
commit c67d003c2f
2 changed files with 11 additions and 0 deletions

View File

@ -21,6 +21,11 @@ for programName, sources in samples:
linkflags.append(f"-Wl,-rpath,{localenv['ct_shlibdir']}") linkflags.append(f"-Wl,-rpath,{localenv['ct_shlibdir']}")
libdirs.extend(localenv["extra_lib_dirs"]) 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_compiler_flags"] = repr(localenv["CCFLAGS"])
localenv['tmpl_cantera_incdirs'] = repr([x for x in incdirs if x]) localenv['tmpl_cantera_incdirs'] = repr([x for x in incdirs if x])
localenv['tmpl_cantera_libs'] = repr(localenv['cantera_shared_libs']) localenv['tmpl_cantera_libs'] = repr(localenv['cantera_shared_libs'])

View File

@ -71,6 +71,12 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}
libdirs.extend(localenv["extra_lib_dirs"]) libdirs.extend(localenv["extra_lib_dirs"])
libdirs = list(set(libdirs)) 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"], cc_flags = compiler_flag_list(localenv["CCFLAGS"] + localenv["CXXFLAGS"],
flag_excludes) flag_excludes)
localenv["tmpl_compiler_flags"] = repr(cc_flags) localenv["tmpl_compiler_flags"] = repr(cc_flags)