Files
UnrealEngineUWP/Engine/Source/ThirdParty/OpenSubdiv/BuildForUE/Linux/BuildForLinux.sh
matt johnson 080178292c OpenSubdiv: update build scripts for OpenSubdiv version 3.5.0
Dynamic libraries of OpenSubdiv are not generated for Windows and
were unused on Linux and Mac, so the build scripts now disable
generating them on all platforms.

The toolchain on Linux was also updated to the new current version.

#jira UE-190064
#rb none

[CL 26830682 by matt johnson in ue5-main branch]
2023-08-03 18:12:38 -04:00

175 lines
5.4 KiB
Bash
Executable File

#!/bin/bash
set -e
LIBRARY_NAME="OpenSubdiv"
REPOSITORY_NAME="OpenSubdiv"
# Informational, for the usage message.
CURRENT_LIBRARY_VERSION=3.5.0
BUILD_SCRIPT_NAME="$(basename $BASH_SOURCE)"
BUILD_SCRIPT_DIR=`cd $(dirname "$BASH_SOURCE"); pwd`
UsageAndExit()
{
echo "Build $LIBRARY_NAME for use with Unreal Engine on Linux"
echo
echo "Usage:"
echo
echo " $BUILD_SCRIPT_NAME <$LIBRARY_NAME Version> <Architecture Name>"
echo
echo "Usage examples:"
echo
echo " $BUILD_SCRIPT_NAME $CURRENT_LIBRARY_VERSION x86_64-unknown-linux-gnu"
echo " -- Installs $LIBRARY_NAME version $CURRENT_LIBRARY_VERSION for x86_64 architecture."
echo
echo " $BUILD_SCRIPT_NAME $CURRENT_LIBRARY_VERSION aarch64-unknown-linux-gnueabi"
echo " -- Installs $LIBRARY_NAME version $CURRENT_LIBRARY_VERSION for arm64 architecture."
echo
exit 1
}
# Get version and architecture from arguments.
LIBRARY_VERSION=$1
if [ -z "$LIBRARY_VERSION" ]
then
UsageAndExit
fi
ARCH_NAME=$2
if [ -z "$ARCH_NAME" ]
then
UsageAndExit
fi
UE_MODULE_LOCATION=`cd $BUILD_SCRIPT_DIR/../..; pwd`
UE_THIRD_PARTY_LOCATION=`cd $UE_MODULE_LOCATION/..; pwd`
UE_ENGINE_LOCATION=`cd $UE_THIRD_PARTY_LOCATION/../..; pwd`
SOURCE_LOCATION="$UE_MODULE_LOCATION/$REPOSITORY_NAME-$LIBRARY_VERSION"
BUILD_LOCATION="$UE_MODULE_LOCATION/Intermediate"
# Specify all of the include/bin/lib directory variables so that CMake can
# compute relative paths correctly for the imported targets.
INSTALL_INCLUDEDIR=include
INSTALL_BIN_DIR="Unix/$ARCH_NAME/bin"
INSTALL_LIB_DIR="Unix/$ARCH_NAME/lib"
INSTALL_LOCATION="$UE_MODULE_LOCATION/Deploy/$REPOSITORY_NAME-$LIBRARY_VERSION"
INSTALL_INCLUDE_LOCATION="$INSTALL_LOCATION/$INSTALL_INCLUDEDIR"
INSTALL_UNIX_ARCH_LOCATION="$INSTALL_LOCATION/Unix/$ARCH_NAME"
rm -rf $BUILD_LOCATION
rm -rf $INSTALL_INCLUDE_LOCATION
rm -rf $INSTALL_UNIX_ARCH_LOCATION
mkdir $BUILD_LOCATION
pushd $BUILD_LOCATION > /dev/null
# Run Engine/Build/BatchFiles/Linux/SetupToolchain.sh first to ensure
# that the toolchain is setup and verify that this name matches.
TOOLCHAIN_NAME=v22_clang-16.0.6-centos7
UE_TOOLCHAIN_LOCATION="$UE_ENGINE_LOCATION/Extras/ThirdPartyNotUE/SDKs/HostLinux/Linux_x64/$TOOLCHAIN_NAME"
C_FLAGS=""
CXX_FLAGS="-I$UE_THIRD_PARTY_LOCATION/Unix/LibCxx/include/c++/v1"
LINKER_FLAGS="-nodefaultlibs -L$UE_THIRD_PARTY_LOCATION/Unix/LibCxx/lib/Unix/$ARCH_NAME/ -lc++ -lc++abi -lm -lc -lgcc_s -lgcc"
# Determine whether we're cross compiling for an architecture that doesn't
# match the host. This is the way that CMake determines the value for the
# CMAKE_HOST_SYSTEM_PROCESSOR variable.
HOST_SYSTEM_PROCESSOR=`uname -m`
TARGET_SYSTEM_PROCESSOR=$HOST_SYSTEM_PROCESSOR
if [[ $ARCH_NAME != $HOST_SYSTEM_PROCESSOR* ]]
then
ARCH_NAME_PARTS=(${ARCH_NAME//-/ })
TARGET_SYSTEM_PROCESSOR=${ARCH_NAME_PARTS[0]}
fi
( cat <<_EOF_
# Auto-generated by script: $BUILD_SCRIPT_DIR/$BUILD_SCRIPT_NAME
message (STATUS "UE_TOOLCHAIN_LOCATION is '${UE_TOOLCHAIN_LOCATION}'")
message (STATUS "ARCH_NAME is '${ARCH_NAME}'")
message (STATUS "TARGET_SYSTEM_PROCESSOR is '${TARGET_SYSTEM_PROCESSOR}'")
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR ${TARGET_SYSTEM_PROCESSOR})
set(CMAKE_SYSROOT ${UE_TOOLCHAIN_LOCATION}/${ARCH_NAME})
set(CMAKE_LIBRARY_ARCHITECTURE ${ARCH_NAME})
set(CMAKE_C_COMPILER \${CMAKE_SYSROOT}/bin/clang)
set(CMAKE_C_COMPILER_TARGET ${ARCH_NAME})
set(CMAKE_C_FLAGS "-target ${ARCH_NAME} ${C_FLAGS}")
set(CMAKE_CXX_COMPILER \${CMAKE_SYSROOT}/bin/clang++)
set(CMAKE_CXX_COMPILER_TARGET ${ARCH_NAME})
set(CMAKE_CXX_FLAGS "-target ${ARCH_NAME} ${CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${LINKER_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "${LINKER_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "${LINKER_FLAGS}")
set(CMAKE_FIND_ROOT_PATH ${UE_TOOLCHAIN_LOCATION})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
_EOF_
) > /tmp/__cmake_toolchain.cmake
CMAKE_ARGS=(
-DCMAKE_TOOLCHAIN_FILE="/tmp/__cmake_toolchain.cmake"
-DCMAKE_INSTALL_PREFIX="$INSTALL_LOCATION"
-DCMAKE_BINDIR_BASE="$INSTALL_BIN_DIR"
-DCMAKE_LIBDIR_BASE="$INSTALL_LIB_DIR"
-DCMAKE_DEBUG_POSTFIX=_d
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DNO_REGRESSION=ON
-DNO_TESTS=ON
-DNO_DOC=ON
-DNO_EXAMPLES=ON
-DNO_TUTORIALS=ON
-DNO_PTEX=ON
-DNO_TBB=ON
-DNO_OMP=ON
-DNO_CUDA=ON
-DNO_OPENCL=ON
-DNO_OPENGL=ON
-DNO_DX=ON
-DNO_GLEW=ON
-DNO_GLFW=ON
-DBUILD_SHARED_LIBS=OFF
)
NUM_CPU=`grep -c ^processor /proc/cpuinfo`
echo Configuring Debug build for $LIBRARY_NAME version $LIBRARY_VERSION...
cmake -G "Unix Makefiles" $SOURCE_LOCATION -DCMAKE_BUILD_TYPE=Debug "${CMAKE_ARGS[@]}"
echo Building $LIBRARY_NAME for Debug...
cmake --build . -j$NUM_CPU
echo Installing $LIBRARY_NAME for Debug...
cmake --install .
# The Unix Makefiles generator does not support multiple configurations, so we
# need to re-configure for Release.
echo Configuring Release build for $LIBRARY_NAME version $LIBRARY_VERSION...
cmake -G "Unix Makefiles" $SOURCE_LOCATION -DCMAKE_BUILD_TYPE=Release "${CMAKE_ARGS[@]}"
echo Building $LIBRARY_NAME for Release...
cmake --build . -j$NUM_CPU
echo Installing $LIBRARY_NAME for Release...
cmake --install .
popd > /dev/null
echo Done.