mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 11:08:03 +00:00
run-cmake.py: dont set any env variables
And pass needed values as cmake args instead
This commit is contained in:
@@ -18,6 +18,12 @@
|
|||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# Create a cache entry if absent for environment variables
|
# Create a cache entry if absent for environment variables
|
||||||
|
#
|
||||||
|
# The env var fallback was mostly relied on by the Windows buil. It's not used anymore
|
||||||
|
# (all build scripts now pass these as -D cache args instead), so in theory it could be
|
||||||
|
# dropped in the future.
|
||||||
|
# It also lets unrelated/stray environment state silently configure the build, since these
|
||||||
|
# var names aren't namespaced to this project.
|
||||||
macro(UNIFY_ENVVARS_AND_CACHE VAR)
|
macro(UNIFY_ENVVARS_AND_CACHE VAR)
|
||||||
if(NOT DEFINED ${VAR} AND DEFINED ENV{${VAR}} AND NOT ENV{${VAR}} STREQUAL "")
|
if(NOT DEFINED ${VAR} AND DEFINED ENV{${VAR}} AND NOT ENV{${VAR}} STREQUAL "")
|
||||||
set(${VAR} "$ENV{${VAR}}" CACHE STRING "${VAR}" FORCE)
|
set(${VAR} "$ENV{${VAR}}" CACHE STRING "${VAR}" FORCE)
|
||||||
|
|||||||
+12
-9
@@ -51,8 +51,8 @@ class Dep(NamedTuple):
|
|||||||
rel_path: Path | None
|
rel_path: Path | None
|
||||||
cmake_prefix: bool = True
|
cmake_prefix: bool = True
|
||||||
"""Whether the dep's dir should be added to CMAKE_PREFIX_PATH."""
|
"""Whether the dep's dir should be added to CMAKE_PREFIX_PATH."""
|
||||||
pass_to_env: bool = False
|
pass_as_cmake_arg: bool = False
|
||||||
"""Whether `env_var` should be added to the subprocess env passed to cmake."""
|
"""Whether `env_var` should be passed to cmake as a `-D` cache variable."""
|
||||||
required: bool = True
|
required: bool = True
|
||||||
"""Whether to error out if the dep's value can't be resolved."""
|
"""Whether to error out if the dep's value can't be resolved."""
|
||||||
base: Literal["DEPS", "INSTALL"] = "INSTALL"
|
base: Literal["DEPS", "INSTALL"] = "INSTALL"
|
||||||
@@ -66,7 +66,7 @@ class Deps:
|
|||||||
"opencollada": Dep("OPENCOLLADA_INSTALL_DIR", Path("OpenCOLLADA")),
|
"opencollada": Dep("OPENCOLLADA_INSTALL_DIR", Path("OpenCOLLADA")),
|
||||||
# We don't install Eigen currently,
|
# We don't install Eigen currently,
|
||||||
# so there's no Eigen3config.cmake and therefore we provide path explicitly.
|
# so there's no Eigen3config.cmake and therefore we provide path explicitly.
|
||||||
"eigen": Dep("EIGEN_DIR", Path("Eigen"), cmake_prefix=False, pass_to_env=True),
|
"eigen": Dep("EIGEN_DIR", Path("Eigen"), cmake_prefix=False, pass_as_cmake_arg=True),
|
||||||
"cgal": Dep("CGAL_INSTALL_DIR", Path("cgal")),
|
"cgal": Dep("CGAL_INSTALL_DIR", Path("cgal")),
|
||||||
"gmp": Dep("GMP_INSTALL_DIR", Path("mpir")),
|
"gmp": Dep("GMP_INSTALL_DIR", Path("mpir")),
|
||||||
"mpfr": Dep("MPFR_INSTALL_DIR", Path("mpfr")),
|
"mpfr": Dep("MPFR_INSTALL_DIR", Path("mpfr")),
|
||||||
@@ -75,15 +75,18 @@ class Deps:
|
|||||||
"zstd": Dep("ZSTD_INSTALL_DIR", Path("zstd")),
|
"zstd": Dep("ZSTD_INSTALL_DIR", Path("zstd")),
|
||||||
"swig": Dep("SWIG_INSTALL_DIR", None),
|
"swig": Dep("SWIG_INSTALL_DIR", None),
|
||||||
"rocksdb": Dep("ROCKSDB_INSTALL_DIR", Path("rocksdb")),
|
"rocksdb": Dep("ROCKSDB_INSTALL_DIR", Path("rocksdb")),
|
||||||
"json": Dep("JSON_INCLUDE_DIR", Path("json"), cmake_prefix=False, pass_to_env=True),
|
"json": Dep("JSON_INCLUDE_DIR", Path("json"), cmake_prefix=False, pass_as_cmake_arg=True),
|
||||||
"libxml2_libraries": Dep(
|
"libxml2_libraries": Dep(
|
||||||
"LIBXML2_LIBRARIES", Path("OpenCOLLADA/lib/opencollada/xml.lib"), cmake_prefix=False, pass_to_env=True
|
"LIBXML2_LIBRARIES",
|
||||||
|
Path("OpenCOLLADA/lib/opencollada/xml.lib"),
|
||||||
|
cmake_prefix=False,
|
||||||
|
pass_as_cmake_arg=True,
|
||||||
),
|
),
|
||||||
"libxml2_include_dir": Dep(
|
"libxml2_include_dir": Dep(
|
||||||
"LIBXML2_INCLUDE_DIR",
|
"LIBXML2_INCLUDE_DIR",
|
||||||
Path("OpenCOLLADA/Externals/LibXML/include"),
|
Path("OpenCOLLADA/Externals/LibXML/include"),
|
||||||
cmake_prefix=False,
|
cmake_prefix=False,
|
||||||
pass_to_env=True,
|
pass_as_cmake_arg=True,
|
||||||
base="DEPS",
|
base="DEPS",
|
||||||
),
|
),
|
||||||
# TODO: drop this TRANSITION check once everyone has re-run build-deps.py with manifold support.
|
# TODO: drop this TRANSITION check once everyone has re-run build-deps.py with manifold support.
|
||||||
@@ -129,8 +132,8 @@ class Deps:
|
|||||||
]
|
]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def env_dict(cls) -> dict[str, str]:
|
def cmake_args(cls) -> list[str]:
|
||||||
return {dep.env_var: str(cls.values()[name]) for name, dep in cls.DEPS.items() if dep.pass_to_env}
|
return [f"-D{dep.env_var}={cls.values()[name]}" for name, dep in cls.DEPS.items() if dep.pass_as_cmake_arg]
|
||||||
|
|
||||||
|
|
||||||
def get_var(deps_cache: dict[str, str], key: str, *, deps_cache_only: bool = False) -> str | None:
|
def get_var(deps_cache: dict[str, str], key: str, *, deps_cache_only: bool = False) -> str | None:
|
||||||
@@ -321,13 +324,13 @@ def main() -> None:
|
|||||||
cmake_args.append(f"-DQT_HOST_PATH={qt_host_path}")
|
cmake_args.append(f"-DQT_HOST_PATH={qt_host_path}")
|
||||||
if Deps.values()["manifold"]:
|
if Deps.values()["manifold"]:
|
||||||
cmake_args.append("-DWITH_MANIFOLD=ON")
|
cmake_args.append("-DWITH_MANIFOLD=ON")
|
||||||
|
cmake_args += Deps.cmake_args()
|
||||||
cmake_args += ARGS.extra_args
|
cmake_args += ARGS.extra_args
|
||||||
|
|
||||||
run_streamed(
|
run_streamed(
|
||||||
"cmake",
|
"cmake",
|
||||||
*cmake_args,
|
*cmake_args,
|
||||||
cwd=build_dir,
|
cwd=build_dir,
|
||||||
env=Deps.env_dict(),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
logger.info("")
|
logger.info("")
|
||||||
|
|||||||
Reference in New Issue
Block a user