CMake: add WITH_LIBS_PRECOMPILED option (UNIX only)

This makes it convenient to build blender without referencing
pre-compiled libraries which don't always work on newer Linux systems.

Previously I had to rename ../lib while creating the CMakeCache.txt
to ensure my systems libraries would be used.

This change ensures LIBDIR is undefined when WITH_LIBS_PRECOMPILED is
disabled, so any accidental use warns with CMake's `--warn-unused-vars`
argument is given.
This commit is contained in:
Campbell Barton
2023-01-19 17:07:24 +11:00
parent 66dee44088
commit bc502f3b19
7 changed files with 86 additions and 45 deletions

View File

@@ -605,7 +605,10 @@ if(UNIX AND NOT APPLE)
)
endif()
if(EXISTS ${LIBDIR}/mesa)
# NOTE: there is a bug in CMake 3.25.1 where `LIBDIR` is reported as undefined.
if(NOT DEFINED LIBDIR)
# Pass.
elseif(EXISTS ${LIBDIR}/mesa)
install(DIRECTORY ${LIBDIR}/mesa/lib/ DESTINATION "lib/mesa/")
install(
@@ -665,7 +668,7 @@ if(UNIX AND NOT APPLE)
DESTINATION ${TARGETDIR_VER}/python/bin
)
if(EXISTS ${LIBDIR})
if(DEFINED LIBDIR)
# Precompiled libraries, copy over complete lib directory.
install_dir(
${PYTHON_LIBPATH}
@@ -1499,7 +1502,7 @@ endif()
# Always install USD shared library and datafiles regardless if Blender
# itself uses them, the bundled Python module still needs it.
if(LIBDIR AND TARGETDIR_LIB)
if((DEFINED LIBDIR) AND TARGETDIR_LIB)
# On windows the usd library sits in ./blender.shared copy the files
# relative to the location of the USD dll, if the dll does not exist
# assume we are linking against the static 3.5 lib.
@@ -1556,7 +1559,7 @@ endif()
# Always install MaterialX files regardless if Blender itself uses them, the
# bundled Python module still needs it.
if(WITH_MATERIALX AND LIBDIR AND TARGETDIR_LIB)
if((DEFINED LIBDIR) AND TARGETDIR_LIB AND WITH_MATERIALX )
install(
DIRECTORY ${LIBDIR}/materialx/libraries
DESTINATION "${TARGETDIR_LIB}/materialx"