[SCons] Distinguish between static and shared library directories

On Windows, the search path for DLLs is the "bin" dir. "lib" dirs are used
only for static and "import" libraries.
This commit is contained in:
Ray Speth 2023-06-22 08:27:51 -04:00 committed by Ingmar Schoegl
parent 1a6fb2fd8e
commit bfea771a0e
7 changed files with 36 additions and 12 deletions

View File

@ -520,8 +520,9 @@ jobs:
- name: Test Install
# spot-check installation locations
run: |
set -x
scons install
test -f ${CONDA_PREFIX}/Library/lib/cantera_shared.dll
test -f ${CONDA_PREFIX}/Library/bin/cantera_shared.dll
test -f ${CONDA_PREFIX}/Library/include/cantera/base/Solution.h
test -f ${CONDA_PREFIX}/Scripts/ck2yaml
test -f ${CONDA_PREFIX}/share/cantera/data/gri30.yaml
@ -531,6 +532,7 @@ jobs:
- name: Test Essentials
# ensure that Python package loads and converter scripts work
run: |
set -x
python -c 'import cantera as ct; import sys; sys.exit(0) if ct.__version__.startswith("3.0.0") else sys.exit(1)'
ck2yaml --input=test/data/h2o2.inp --output=h2o2-test.yaml
test -f h2o2-test.yaml

View File

@ -2024,7 +2024,8 @@ elif env["layout"] == "conda":
prefix = Path(env["prefix"])
if env["layout"] == "conda" and os.name == "nt":
env["ct_libdir"] = (prefix / "Library" / env["libdirname"]).as_posix()
env["ct_libdir"] = (prefix / "Library" / "lib").as_posix()
env["ct_shlibdir"] = (prefix / "Library" / "bin").as_posix()
env["ct_bindir"] = (prefix / "Scripts").as_posix()
env["ct_python_bindir"] = (prefix / "Scripts").as_posix()
env["ct_incdir"] = (prefix / "Library" / "include" / "cantera").as_posix()
@ -2035,6 +2036,14 @@ else:
env["prefix"] = prefix.as_posix()
env["ct_libdir"] = (prefix / env["libdirname"]).as_posix()
env["ct_bindir"] = (prefix / "bin").as_posix()
# On Windows, the search path for DLLs is the "bin" dir. "lib" dirs are used only for
# static and "import" libraries
if env["OS"] == "Windows":
env["ct_shlibdir"] = env["ct_bindir"]
else:
env["ct_shlibdir"] = env["ct_libdir"]
env["ct_python_bindir"] = (prefix / "bin").as_posix()
env["ct_incdir"] = (prefix / "include" / "cantera").as_posix()
env["ct_incroot"] = (prefix / "include").as_posix()
@ -2081,7 +2090,7 @@ if os.path.abspath(instRoot) == Dir('.').abspath:
sys.exit(1)
env["inst_root"] = instRoot
locations = ["libdir", "bindir", "python_bindir", "incdir", "incroot",
locations = ["libdir", "shlibdir", "bindir", "python_bindir", "incdir", "incroot",
"matlab_dir", "datadir", "sampledir", "docdir", "mandir"]
for loc in locations:
if env["prefix"] == ".":

View File

@ -16,7 +16,7 @@ for programName, sources in samples:
# Generate SConstruct files to be installed
linkflags = ["-g", localenv["thread_flags"]]
if not localenv["package_build"]:
linkflags.append(f"-Wl,-rpath,{localenv['ct_libdir']}")
linkflags.append(f"-Wl,-rpath,{localenv['ct_shlibdir']}")
incdirs = [localenv["ct_incroot"]]
libdirs = [localenv["ct_libdir"]] + localenv["extra_lib_dirs"]
else:

View File

@ -37,7 +37,7 @@ if localenv["package_build"]:
libdirs = []
else:
cc_flags = localenv["CCFLAGS"] + localenv["CXXFLAGS"]
linkflags.append(f"-Wl,-rpath,{localenv['ct_libdir']}")
linkflags.append(f"-Wl,-rpath,{localenv['ct_shlibdir']}")
incdirs = [localenv["ct_incroot"]]
incdirs.extend([localenv["sundials_include"], localenv["boost_inc_dir"]])

View File

@ -20,7 +20,7 @@ for programName, sources in samples:
incdirs = [pjoin(localenv["ct_incroot"], "cantera")] # path to fortran .mod
libdirs = []
if not localenv["package_build"]:
linkflags.append(f"-Wl,-rpath,{localenv['ct_libdir']}")
linkflags.append(f"-Wl,-rpath,{localenv['ct_shlibdir']}")
libdirs = [localenv["ct_libdir"]]
libdirs.extend([localenv["sundials_libdir"], localenv["blas_lapack_dir"]])
libdirs.append(localenv["hdf_libdir"])

View File

@ -89,7 +89,7 @@ if env["python_package"] == "full":
shim = pyenv.SharedObject("extensions/pythonShim.cpp")
pylibname = f"../lib/cantera_python{pyenv['py_version_short'].replace('.', '_')}"
lib = build(pyenv.SharedLibrary(pylibname, shim, SPAWN=get_spawn(pyenv)))
install("$inst_libdir", lib)
install("$inst_shlibdir", lib)
# build the Cantera static library
@ -162,11 +162,17 @@ if localenv['versioned_shared_library']:
lib = build(localenv.SharedLibrary(sharedName, libraryTargets + sharedIndicator,
SPAWN=get_spawn(localenv),
SHLIBVERSION=localenv['cantera_pure_version']))
install(localenv.InstallVersionedLib, '$inst_libdir', lib)
install(localenv.InstallVersionedLib, '$inst_shlibdir', lib)
else:
lib = build(localenv.SharedLibrary(sharedName, libraryTargets + sharedIndicator,
SPAWN=get_spawn(localenv)))
install('$inst_libdir', lib)
SPAWN=get_spawn(localenv)))
for libfile in lib:
if libfile.name.endswith(('.exp', '.lib')):
# On Windows, these are the export/import libraries used when linking, which
# should be installed in the same location as static libraries
install('$inst_libdir', libfile)
else:
install('$inst_shlibdir', libfile)
if env["OS"] == "Darwin":
localenv.AddPostAction(lib,

View File

@ -32,11 +32,18 @@ if localenv['layout'] != 'debian':
SHLIBVERSION=localenv['cantera_pure_version'],
LIBS=list(env['cantera_shared_libs'] + env['cxx_stdlib']),
LINK='$FORTRAN_LINK'))
install(localenv.InstallVersionedLib, '$inst_libdir', shlib)
install(localenv.InstallVersionedLib, '$inst_shlibdir', shlib)
else:
shlib = build(localenv.SharedLibrary(target=sharedName, source=objects,
SPAWN=get_spawn(localenv),
LIBS=list(env['cantera_shared_libs'] + env['cxx_stdlib']),
LINK='$FORTRAN_LINK'))
install('$inst_libdir', shlib)
for libfile in shlib:
if libfile.name.endswith(('.exp', '.lib')):
# On Windows, these are the export/import libraries used when linking, which
# should be installed in the same location as static libraries
install('$inst_libdir', libfile)
else:
install('$inst_shlibdir', libfile)
localenv.Depends(shlib, localenv['config_h_target'])