Skip to content

Commit

Permalink
[SCons] Remove duplicated flags from cantera.pc
Browse files Browse the repository at this point in the history
  • Loading branch information
speth committed Aug 21, 2023
1 parent 978f147 commit c85fdb5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 25 deletions.
37 changes: 13 additions & 24 deletions platform/posix/SConscript
Expand Up @@ -18,12 +18,17 @@ pc_libdirs = []
pc_incdirs = []
pc_cflags = list(localenv['CXXFLAGS'])

if 'Accelerate' in localenv['FRAMEWORKS']:
pc_cflags.append('-framework Accelerate')

if '-pthread' in localenv['thread_flags']:
pc_cflags.append('-pthread')
pc_libs.append('pthread')

flag_excludes = []
if localenv["package_build"]:
# Remove local conda build environment from the installed include list
for i in range(len(pc_cflags) - 1):
if pc_cflags[i] == '-isystem' and '/_build_env/' in pc_cflags[i+1]:
del pc_cflags[i:i+2]
break
flag_excludes.extend(("-isysroot", "-mmacosx", "-march", "-mtune",
"-fdebug-prefix-map", ".*/_build_env/"))
else:
pc_incdirs.extend(localenv["extra_inc_dirs"])
pc_libdirs.extend(localenv["extra_lib_dirs"])
Expand All @@ -37,29 +42,13 @@ else:
if localenv["use_hdf5"]:
pc_incdirs.append(localenv["hdf_include"])

if 'Accelerate' in localenv['FRAMEWORKS']:
pc_cflags.append('-framework Accelerate')

if '-pthread' in localenv['thread_flags']:
pc_cflags.append('-pthread')
pc_libs.append('pthread')

if localenv["package_build"]:
# Remove sysroot flags in templated output files. This only applies to the
# conda package for now.
# Users should compile against their local SDKs, which should be backwards
# compatible with the SDK used for building.
excludes = (
"-isysroot", "-mmacosx", "-march", "-mtune", "-fdebug-prefix-map")
localenv["CCFLAGS"] = compiler_flag_list(localenv["CCFLAGS"], env["CC"], excludes)
localenv["CXXFLAGS"] = compiler_flag_list(localenv["CXXFLAGS"], env["CC"], excludes)
pc_cflags.extend(f"-isystem {dir}" for dir in pc_incdirs if dir)

# Generate cantera.pc for use with pkg-config
localenv["pc_prefix"] = localenv["prefix"]
localenv["pc_libdirs"] = " ".join(f"-L{dir}" for dir in pc_libdirs)
localenv["pc_libdirs"] = " ".join(f"-L{dir}" for dir in pc_libdirs if dir)
localenv["pc_libs"] = " ".join(f"-l{lib}" for lib in pc_libs)
localenv["pc_incdirs"] = " ".join(f"-I{dir}" for dir in pc_incdirs)
localenv["pc_cflags"] = " ".join(pc_cflags)
localenv["pc_cflags"] = " ".join(compiler_flag_list(pc_cflags, env["CC"], flag_excludes))

pc = build(localenv.SubstFile("cantera.pc", "cantera.pc.in"))
install("$inst_libdir/pkgconfig", pc)
2 changes: 1 addition & 1 deletion platform/posix/cantera.pc.in
Expand Up @@ -9,4 +9,4 @@ URL: https://cantera.org
Version: @cantera_version@

Libs: -L${libdir} -Wl,-rpath,${libdir} @pc_libdirs@ @pc_libs@
Cflags: @pc_cflags@ -I${includedir} @pc_incdirs@
Cflags: @pc_cflags@ -isystem ${includedir}

0 comments on commit c85fdb5

Please sign in to comment.