├── .gitignore ├── utils ├── replace ├── clear ├── create_python_wheel.sh ├── install └── prepare ├── distfiles ├── cblosc-install.sh ├── qt-install.sh ├── tbb-install.sh ├── bzip2-1.0.8-fpic.patch ├── embree-install.sh ├── oidn-install.sh ├── luxmark.start ├── nvrtc-install.sh ├── luxcore.cmake ├── boost.python-1.72.0.patch └── oiio-2.2.13.1-compiler.cmake ├── first_run.sh ├── .github └── FUNDING.yml └── README /.gitignore: -------------------------------------------------------------------------------- 1 | distfiles/*.gz 2 | distfiles/*.tgz 3 | distfiles/*.xz 4 | distfiles/*.bz2 5 | target-64-sse2/ 6 | -------------------------------------------------------------------------------- /utils/replace: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | from sys import argv 4 | 5 | print(argv[1].replace('/', '\/')) 6 | -------------------------------------------------------------------------------- /distfiles/cblosc-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | INCLUDE_INSTALL_DIR="$1"/include 4 | LIBRARY_INSTALL_DIR="$1"/lib 5 | 6 | mkdir -p $INCLUDE_INSTALL_DIR 7 | mkdir -p $LIBRARY_INSTALL_DIR 8 | 9 | cp -vr include/*.h $INCLUDE_INSTALL_DIR 10 | 11 | cp -vr lib/lib*.a $LIBRARY_INSTALL_DIR 12 | -------------------------------------------------------------------------------- /distfiles/qt-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | mkdir $1/qt5-v5.12.2 4 | cp -av 5.12.2/gcc_64/bin $1/qt5-v5.12.2 5 | cp -av 5.12.2/gcc_64/include $1/qt5-v5.12.2 6 | cp -av 5.12.2/gcc_64/lib $1/qt5-v5.12.2 7 | cp -av 5.12.2/gcc_64/mkspecs $1/qt5-v5.12.2 8 | cp -av 5.12.2/gcc_64/plugins $1/qt5-v5.12.2 9 | -------------------------------------------------------------------------------- /distfiles/tbb-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | INCLUDE_INSTALL_DIR="$1"/include 4 | LIBRARY_INSTALL_DIR="$1"/lib 5 | 6 | mkdir -p $INCLUDE_INSTALL_DIR 7 | mkdir -p $LIBRARY_INSTALL_DIR 8 | 9 | cp -vr include/serial include/tbb $INCLUDE_INSTALL_DIR 10 | 11 | cp -vr ../tbb2019_20191006oss/lib/intel64/gcc4.8/lib* $LIBRARY_INSTALL_DIR 12 | -------------------------------------------------------------------------------- /distfiles/bzip2-1.0.8-fpic.patch: -------------------------------------------------------------------------------- 1 | --- Makefile.bak 2014-05-16 13:58:28.994279562 +0700 2 | +++ Makefile 2014-05-16 13:58:36.964278887 +0700 3 | @@ -21,7 +21,7 @@ 4 | LDFLAGS= 5 | 6 | BIGFILES=-D_FILE_OFFSET_BITS=64 7 | -CFLAGS=-Wall -Winline -O2 -g $(BIGFILES) 8 | +CFLAGS=-Wall -Winline -O2 -fPIC -g $(BIGFILES) 9 | 10 | # Where you want it installed when you do 'make install' 11 | PREFIX=/usr/local 12 | -------------------------------------------------------------------------------- /distfiles/embree-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | INCLUDE_INSTALL_DIR="$1"/include 4 | LIBRARY_INSTALL_DIR="$1"/lib 5 | 6 | mkdir -p $INCLUDE_INSTALL_DIR 7 | mkdir -p $LIBRARY_INSTALL_DIR 8 | 9 | cp -av include/embree3 $INCLUDE_INSTALL_DIR 10 | 11 | cp -av lib/lib* $LIBRARY_INSTALL_DIR 12 | 13 | rm $LIBRARY_INSTALL_DIR/libtbb.so 14 | rm $LIBRARY_INSTALL_DIR/libtbb.so.12 15 | cp $LIBRARY_INSTALL_DIR/libtbb.so.12.1 $LIBRARY_INSTALL_DIR/libtbb.so.12 16 | -------------------------------------------------------------------------------- /distfiles/oidn-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | INCLUDE_INSTALL_DIR="$1"/include 4 | LIBRARY_INSTALL_DIR="$1"/lib 5 | 6 | mkdir -p $INCLUDE_INSTALL_DIR 7 | mkdir -p $LIBRARY_INSTALL_DIR 8 | 9 | cp -av include/OpenImageDenoise $INCLUDE_INSTALL_DIR 10 | 11 | cp -av lib/lib* $LIBRARY_INSTALL_DIR 12 | 13 | rm $LIBRARY_INSTALL_DIR/libtbb.so 14 | rm $LIBRARY_INSTALL_DIR/libtbb.so.12 15 | cp $LIBRARY_INSTALL_DIR/libtbb.so.12.1 $LIBRARY_INSTALL_DIR/libtbb.so.12 16 | -------------------------------------------------------------------------------- /distfiles/luxmark.start: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 4 | # You may run in trouble on localized Linux installations 5 | # because of ',' parsed as decimal separator instead of '.' char 6 | export LC_ALL=C 7 | # Embree and OpenImageDenoise dynamic libraries are assumed to be located in the 'lib' 8 | # subdirectory. 9 | export LD_PRELOAD="$ROOT/lib/libembree3.so.3:$ROOT/lib/libOpenImageDenoise.so.0:$ROOT/lib/libtbb.so.2:$ROOT/lib/libtbbmalloc.so.2" 10 | 11 | cd "$ROOT" 12 | ./luxmark.bin "$@" 13 | -------------------------------------------------------------------------------- /first_run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Install dependencies that are not handled by LinuxCompileDeps 4 | sudo apt update 5 | sudo apt install -y libtool-bin cmake flex bison libgtk-3-dev libgl1-mesa-dev python3-dev python3-numpy git patchelf 6 | 7 | # Download LuxCore sources 8 | git clone https://github.com/LuxCoreRender/LuxCore.git 9 | 10 | # Start build script, pass the path to the LuxCore sources as first argument 11 | # This will take a very long time on the first run because it needs to compile all dependencies 12 | ./build-64-sse2 LuxCore 13 | -------------------------------------------------------------------------------- /utils/clear: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd /root/luxbuild 4 | 5 | if [[ ! -d $1 ]] ; then 6 | echo "Please provide Lux snapshot dir" 7 | echo "Usage: " 8 | fi 9 | 10 | cd ~/luxbuild 11 | 12 | if [[ $2 == 1 ]] ; then 13 | echo " * Removing compiled distributions" 14 | sleep 3 15 | rm -vfr target-*/"$1" 16 | exit 0 17 | elif [[ $2 == 2 ]] ; then 18 | echo " * Removing distributions and sources" 19 | sleep 3 20 | rm -vfr target-*/"$1" 21 | rm -fr $1 22 | exit 0 23 | fi 24 | 25 | echo "Targets:" 26 | echo " 1 - compiled distributions" 27 | echo " 2 - distributions and sources" 28 | echo 29 | exit 1 30 | -------------------------------------------------------------------------------- /distfiles/nvrtc-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | INCLUDE_INSTALL_DIR="$1"/include 4 | LIBRARY_INSTALL_DIR="$1"/lib 5 | 6 | mkdir -p $INCLUDE_INSTALL_DIR 7 | mkdir -p $LIBRARY_INSTALL_DIR 8 | 9 | cp -avr targets/x86_64-linux/lib/libnvrtc* "$LIBRARY_INSTALL_DIR" 10 | 11 | # Fix missing rpath, so one shared lib can find the other when it is loaded by BlendLuxCore 12 | echo "Fixing NVRTC rpath" 13 | 14 | NVRTC="$LIBRARY_INSTALL_DIR"/libnvrtc.so 15 | patchelf --set-rpath ./ "$NVRTC" 16 | echo "new rpath of $NVRTC:" 17 | patchelf --print-rpath "$NVRTC" 18 | 19 | NVRTC_BUILTINS="$LIBRARY_INSTALL_DIR"/libnvrtc-builtins.so 20 | patchelf --set-rpath ./ "$NVRTC_BUILTINS" 21 | echo "new rpath of $NVRTC_BUILTINS:" 22 | patchelf --print-rpath "$NVRTC_BUILTINS" 23 | -------------------------------------------------------------------------------- /distfiles/luxcore.cmake: -------------------------------------------------------------------------------- 1 | 2 | ########################################################################### 3 | # 4 | # Configuration 5 | # 6 | ########################################################################### 7 | 8 | #cmake -DLUXRAYS_CUSTOM_CONFIG=cmake/SpecializedConfig/sattva.cmake . 9 | 10 | MESSAGE(STATUS "Using my own settings") 11 | 12 | set(FREEIMAGE_ROOT "${LuxRays_SOURCE_DIR}/../target/include") 13 | set(BOOST_SEARCH_PATH "${LuxRays_SOURCE_DIR}/../target/lib") 14 | 15 | # set(OPENCL_SEARCH_PATH "$ENV{ATISTREAMSDKROOT}") 16 | set(OPENCL_SEARCH_PATH "/usr/src/opencl-sdk/include") 17 | set(OPENCL_LIBRARYDIR "${OPENCL_SEARCH_PATH}/lib/x86_64") 18 | 19 | # set(BUILD_LUXMARK TRUE) 20 | set(CMAKE_BUILD_TYPE "Release") 21 | 22 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | # For more info, see https://help.github.com/en/github/administering-a-repository/displaying-a-sponsor-button-in-your-repository 3 | 4 | #github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 5 | #patreon: # Replace with a single Patreon username 6 | #open_collective: # Replace with a single Open Collective username 7 | #ko_fi: # Replace with a single Ko-fi username 8 | #tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 9 | #community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 10 | #liberapay: # Replace with a single Liberapay username 11 | #issuehunt: # Replace with a single IssueHunt username 12 | #otechie: # Replace with a single Otechie username 13 | 14 | custom: ["https://salt.bountysource.com/teams/luxcorerender"] 15 | -------------------------------------------------------------------------------- /distfiles/boost.python-1.72.0.patch: -------------------------------------------------------------------------------- 1 | --- exec.cpp.orig 2019-12-10 01:19:39.000000000 +0100 2 | +++ exec.cpp 2021-11-25 11:11:49.933084600 +0100 3 | @@ -104,9 +104,16 @@ 4 | if (local.is_none()) local = global; 5 | // should be 'char const *' but older python versions don't use 'const' yet. 6 | char *f = const_cast(filename); 7 | - // Let python open the file to avoid potential binary incompatibilities. 8 | -#if PY_VERSION_HEX >= 0x03040000 9 | - FILE *fs = _Py_fopen(f, "r"); 10 | +#if PY_VERSION_HEX >= 0x03010000 11 | + // Backported from Boost.Python v1.75.0 to build LuxCore for Python 3.10 12 | + // Let python manage any UTF bits to avoid potential incompatibilities. 13 | + PyObject *fo = Py_BuildValue("s", f); 14 | + PyObject *fb = Py_None; 15 | + PyUnicode_FSConverter(fo, &fb); 16 | + f = PyBytes_AsString(fb); 17 | + FILE *fs = fopen(f, "r"); 18 | + Py_DECREF(fo); 19 | + Py_DECREF(fb); 20 | #elif PY_VERSION_HEX >= 0x03000000 21 | PyObject *fo = Py_BuildValue("s", f); 22 | FILE *fs = _Py_fopen(fo, "r"); 23 | -------------------------------------------------------------------------------- /utils/create_python_wheel.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Edit LuxCore/pywheel/setup.y, update version there and in this file, than: 4 | # 5 | # ./utils/create_python_wheel.sh target-64-sse2 luxcorerender-v2.0-linux64 6 | # ./utils/create_python_wheel.sh target-64-sse2 luxcorerender-v2.0-linux64-opencl 7 | 8 | if [[ ! $2 ]] ; then 9 | echo " * Unable to create Python Wheel" 10 | exit 1 11 | fi 12 | 13 | TARGET=$1 14 | LUX_TAG=$2 15 | 16 | rm -rf $TARGET/$LUX_TAG-wheel 17 | mkdir -p $TARGET/$LUX_TAG-wheel/pyluxcore 18 | 19 | cp $LUX_TAG/pywheel/setup.py $TARGET/$LUX_TAG-wheel 20 | cp $LUX_TAG/pywheel/setup.cfg $TARGET/$LUX_TAG-wheel 21 | cp $LUX_TAG/pywheel/MANIFEST.in $TARGET/$LUX_TAG-wheel 22 | cp $LUX_TAG/pywheel/__init__.py $TARGET/$LUX_TAG-wheel/pyluxcore 23 | 24 | cp -r $LUX_TAG/src/pyluxcoretools/pyluxcoretools $TARGET/$LUX_TAG-wheel/pyluxcoretools 25 | 26 | cp $LUX_TAG/README.md $TARGET/$LUX_TAG-wheel/README.rst 27 | cp $LUX_TAG/AUTHORS.txt $TARGET/$LUX_TAG-wheel/AUTHORS.txt 28 | cp $LUX_TAG/COPYING.txt $TARGET/$LUX_TAG-wheel/LICENSE.txt 29 | 30 | cp $LUX_TAG/lib/*.so $TARGET/$LUX_TAG-wheel/pyluxcore 31 | cp $TARGET/lib/libOpenImageDenoise.so.0 $TARGET/lib/libembree3.so.3 $TARGET/lib/libtbb.so.2 $TARGET/lib/libtbbmalloc.so.2 $TARGET/$LUX_TAG-wheel/pyluxcore 32 | 33 | 34 | cd $TARGET/$LUX_TAG-wheel 35 | python3 setup.py bdist_wheel --plat-name manylinux1_x86_64 36 | #twine upload dist/luxcorerender-2.0-cp34-cp34m-manylinux1_x86_64.whl 37 | # 38 | mv dist/luxcorerender-2.0-cp34-cp34m-manylinux1_x86_64.whl dist/luxcorerender-2.0b-cp34-cp34m-manylinux1_x86_64.whl 39 | twine upload dist/luxcorerender-2.0b-cp34-cp34m-manylinux1_x86_64.whl 40 | cd - 41 | -------------------------------------------------------------------------------- /utils/install: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [[ ! $2 ]] ; then 4 | echo " * Unable to install" 5 | exit 1 6 | fi 7 | 8 | TARGET=$1 9 | LUX_TAG=$2 10 | DIST=$3 11 | 12 | # Check if I have to build the stand alone version or the SDK version 13 | if echo $LUX_TAG | grep -iq 'sdk' ; then 14 | echo 15 | echo " * Installing SDK version at $TARGET/$LUX_TAG" 16 | 17 | rm -rf $TARGET/$LUX_TAG 18 | mkdir $TARGET/$LUX_TAG 19 | 20 | mkdir $TARGET/$LUX_TAG/bin 21 | cp $LUX_TAG/bin/luxcoreui $LUX_TAG/bin/luxcoreconsole $LUX_TAG/bin/luxcoredemo \ 22 | $LUX_TAG/bin/luxcorescenedemo $TARGET/$LUX_TAG/bin 23 | 24 | mkdir $TARGET/$LUX_TAG/lib 25 | cp $LUX_TAG/lib/*.so $TARGET/$LUX_TAG/lib 26 | cp $TARGET/lib/libOpenImageDenoise.so.1 $TARGET/lib/libembree3.so.3 $TARGET/lib/libtbb.so.12 $TARGET/lib/libtbb.so.2 $TARGET/$LUX_TAG/lib 27 | cp -a $TARGET/lib/libnvrtc* $TARGET/$LUX_TAG 28 | 29 | cp $LUX_TAG/README.md $TARGET/$LUX_TAG 30 | cp $LUX_TAG/COPYING.txt $TARGET/$LUX_TAG 31 | cp $LUX_TAG/AUTHORS.txt $TARGET/$LUX_TAG 32 | cp $LUX_TAG/sdk/CMakeLists.txt $TARGET/$LUX_TAG 33 | 34 | mkdir $TARGET/$LUX_TAG/cmake 35 | 36 | mkdir $TARGET/$LUX_TAG/include 37 | mkdir $TARGET/$LUX_TAG/include/luxrays 38 | mkdir $TARGET/$LUX_TAG/include/luxrays/utils 39 | cp -r $LUX_TAG/include/luxrays/utils/cyhair $TARGET/$LUX_TAG/include/luxrays/utils 40 | cp $LUX_TAG/include/luxrays/utils/exportdefs.h $TARGET/$LUX_TAG/include/luxrays/utils 41 | cp $LUX_TAG/include/luxrays/utils/properties.h $TARGET/$LUX_TAG/include/luxrays/utils 42 | cp $LUX_TAG/include/luxrays/utils/utils.h $TARGET/$LUX_TAG/include/luxrays/utils 43 | 44 | mkdir $TARGET/$LUX_TAG/include/luxcore 45 | cp $LUX_TAG/generated/include/luxcore/cfg.h $TARGET/$LUX_TAG/include/luxcore 46 | cp $LUX_TAG/include/luxcore/luxcore.h $TARGET/$LUX_TAG/include/luxcore 47 | 48 | cp -r $LUX_TAG/samples $TARGET/$LUX_TAG 49 | cp -r $LUX_TAG/scenes $TARGET/$LUX_TAG 50 | 51 | cd $TARGET 52 | tar -cvjf ${LUX_TAG}.tar.bz2 $LUX_TAG 53 | cd .. 54 | 55 | echo 56 | else 57 | echo 58 | echo " * Installing STANDALONE version at $TARGET/$LUX_TAG" 59 | 60 | rm -rf $TARGET/$LUX_TAG 61 | mkdir $TARGET/$LUX_TAG 62 | 63 | # Build PyInstaller 64 | # 65 | # PyInstaller is pretty much broken on Linux: https://github.com/LuxCoreRender/LuxCore/issues/80 66 | # cd $LUX_TAG 67 | # pyinstaller samples/pyluxcoretool/pyluxcoretool.linux.spec 68 | # cd - 69 | # 70 | # cp $LUX_TAG/bin/luxcoreui $LUX_TAG/dist/pyluxcoretool $TARGET/$LUX_TAG 71 | # Workaround to PyInstaller, just run "python3 pyluxcoretools.zip" 72 | cp $LUX_TAG/lib/pyluxcoretools.zip $TARGET/$LUX_TAG 73 | 74 | cp $LUX_TAG/bin/luxcoreui $TARGET/$LUX_TAG 75 | cp $LUX_TAG/lib/*.so $TARGET/$LUX_TAG 76 | cp $TARGET/lib/libOpenImageDenoise.so.1 $TARGET/lib/libembree3.so.3 $TARGET/lib/libtbb.so.12 $TARGET/lib/libtbb.so.2 $TARGET/$LUX_TAG 77 | cp -a $TARGET/lib/libnvrtc* $TARGET/$LUX_TAG 78 | 79 | cp $LUX_TAG/README.md $TARGET/$LUX_TAG 80 | cp $LUX_TAG/COPYING.txt $TARGET/$LUX_TAG 81 | cp $LUX_TAG/AUTHORS.txt $TARGET/$LUX_TAG 82 | mkdir -p $TARGET/$LUX_TAG/scenes/cornell 83 | cp $LUX_TAG/scenes/cornell/cornell.cfg $TARGET/$LUX_TAG/scenes/cornell 84 | cp $LUX_TAG/scenes/cornell/cornell.scn $TARGET/$LUX_TAG/scenes/cornell 85 | cp $LUX_TAG/scenes/cornell/Khaki.ply $TARGET/$LUX_TAG/scenes/cornell 86 | cp $LUX_TAG/scenes/cornell/HalveRed.ply $TARGET/$LUX_TAG/scenes/cornell 87 | cp $LUX_TAG/scenes/cornell/DarkGreen.ply $TARGET/$LUX_TAG/scenes/cornell 88 | cp $LUX_TAG/scenes/cornell/Grey.ply $TARGET/$LUX_TAG/scenes/cornell 89 | 90 | cd $TARGET 91 | tar -cvjf ${LUX_TAG}.tar.bz2 $LUX_TAG 92 | cd .. 93 | 94 | echo 95 | fi 96 | 97 | # Check if I have to pack LuxMark too 98 | if [[ -d "LuxMark" ]] ; then 99 | echo 100 | echo " * Installing LuxMark at $TARGET/luxmark" 101 | 102 | rm -rf $TARGET/luxmark 103 | mkdir $TARGET/luxmark 104 | mkdir $TARGET/luxmark/lib 105 | 106 | cp $LUX_TAG/bin/luxcoreui $TARGET/luxmark 107 | cp $TARGET/lib/libOpenImageDenoise.so.1 $TARGET/lib/libembree3.so.3 $TARGET/lib/libtbb.so.12 $TARGET/lib/libtbb.so.2 $TARGET/luxmark/lib 108 | #cp $TARGET/qt5-v5.12.2/lib/libQt5Widgets.so $TARGET/luxmark/libQt5Widgets.so.5 109 | #cp $TARGET/qt5-v5.12.2/lib/libQt5Network.so $TARGET/luxmark/libQt5Network.so.5 110 | #cp $TARGET/qt5-v5.12.2/lib/libQt5Gui.so $TARGET/luxmark/libQt5Gui.so.5 111 | #cp $TARGET/qt5-v5.12.2/lib/libQt5Core.so $TARGET/luxmark/libQt5Core.so.5 112 | 113 | cp LuxMark/README.md $TARGET/luxmark 114 | cp LuxMark/COPYING.txt $TARGET/luxmark 115 | cp LuxMark/AUTHORS.txt $TARGET/luxmark 116 | cp LuxMark/bin/luxmark $TARGET/luxmark/luxmark.bin 117 | cp $DIST/luxmark.start $TARGET/luxmark/luxmark 118 | 119 | tar zxf $DIST/scenes.tgz -C $TARGET/luxmark 120 | 121 | cd $TARGET 122 | tar cvjf luxmark.tar.bz2 luxmark 123 | cd .. 124 | 125 | echo 126 | fi 127 | -------------------------------------------------------------------------------- /utils/prepare: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # target dir 4 | TARGET=$1 5 | # distfiles dir 6 | DIST=$2 7 | 8 | ARCH="x86_64" 9 | if echo $TARGET | grep -q '\-32' ; then ARCH="i686" ; fi 10 | 11 | function symlink_python() { 12 | local pylib=$1 13 | local location=$2 14 | 15 | echo " * Found at $location" 16 | echo " * Updating symlink" 17 | ln -vfs $location $TARGET/lib/$pylib 18 | } 19 | 20 | function symlink_libstdc() { 21 | local location=$1 22 | directory=`dirname $location` 23 | 24 | echo " * Found at $location" 25 | echo " * Updating symlink" 26 | ln -vfs $location $TARGET/lib/libstdc++.a 27 | 28 | # echo " * Symlinking GOMP" 29 | # for filename in libgomp.a libgomp.spec ; do 30 | # ln -vfs $directory/$filename $TARGET/lib/$filename 31 | # done 32 | } 33 | 34 | function verify_hash() { 35 | local hash=$1 36 | local filepath=$2 37 | echo "$hash $filepath" | sha1sum --status -c - 38 | return $? 39 | } 40 | 41 | echo " * Checking distfiles" 42 | FILE=linux_deps.tgz 43 | HASH=7aab4a72ffebe961f0df734364436c99f29f4708 44 | URL=https://github.com/LuxCoreRender/LinuxCompileDeps/releases/download/luxcorerender_v2.6alpha0/linux_deps.tgz 45 | if [ ! -f $DIST/$FILE ] ; then 46 | echo " * Downloading $FILE" 47 | wget -O $DIST/$FILE $URL 48 | fi 49 | verify_hash $HASH "$DIST/$FILE" 50 | if [ $? != 0 ] ; then 51 | echo " * Resume downloading $FILE" 52 | wget -c -O $DIST/$FILE $URL 53 | 54 | verify_hash $HASH "$DIST/$FILE" 55 | if [ $? != 0 ] ; then 56 | echo " !!! Hash mismatch for $FILE" 57 | exit 1 58 | fi 59 | fi 60 | tar zxvf $DIST/$FILE -C $DIST 61 | echo " * Done checking distfiles" 62 | 63 | echo " * Checking target tree" 64 | if [[ ! -d $TARGET ]] ; then 65 | echo " * Target tree is absent, populating" 66 | mkdir -pv $TARGET/{bin,include,lib,share} 2>/dev/null 67 | echo " * Done creating target tree" 68 | else 69 | echo " * Target tree exists" 70 | fi 71 | 72 | echo " * Checking libstdc++" 73 | if [[ ! -e $TARGET/lib/libstdc++.a ]] ; then 74 | echo " * Library symlink is missing, attempting to figure out the proper location" 75 | GCCVER=`gcc -dumpversion` 76 | GCCVERMAJOR=`echo $GCCVER | cut -d'.' -f1-2` 77 | if STDCLIBPATH=/usr/lib/gcc/${ARCH}-linux-gnu/$GCCVER/libstdc++.a && [[ -e $STDCLIBPATH ]] ; then 78 | symlink_libstdc $STDCLIBPATH 79 | elif STDCLIBPATH=/usr/lib/gcc/${ARCH}-linux-gnu/$GCCVERMAJOR/libstdc++.a && [[ -e $STDCLIBPATH ]] ; then 80 | symlink_libstdc $STDCLIBPATH 81 | else 82 | echo " !!! Unable to find libstdc++.a at known locations." 83 | echo " !!! You have to find the library manually and symlink" 84 | echo " !!! it to the following path:" 85 | echo " !!! $TARGET/lib/libstdc++.a" 86 | exit 1 87 | fi 88 | fi 89 | echo " * Done checking libstdc++" 90 | 91 | echo " * Checking python" 92 | PYVER=`${PYTHON_CMD} --version 2>&1` 93 | if [ `echo $PYVER | cut -d' ' -f2 | cut -d'.' -f1` != '3' ] ; then 94 | echo " !!! Python major version '3' is required" 95 | exit 1 96 | fi 97 | PYVER=`echo $PYVER | cut -d' ' -f2 | cut -d'.' -f'1-2'` 98 | PYLIB=libpython"$PYVER".a 99 | PYLIBm=libpython"$PYVER"m.a 100 | if echo $TARGET | grep -q '\-64' ; then EXT="64" ; fi 101 | if [[ ! -e $TARGET/lib/$PYLIB ]] ; then 102 | echo " * Library symlink is missing, attempting to figure out the proper location" 103 | if PYLIBPATH=/usr/lib${EXT}/$PYLIB && [[ -e $PYLIBPATH ]] ; then 104 | symlink_python $PYLIB $PYLIBPATH 105 | elif PYLIBPATH=/usr/lib/${ARCH}-linux-gnu/$PYLIB && [[ -e $PYLIBPATH ]] ; then 106 | symlink_python $PYLIB $PYLIBPATH 107 | elif PYLIBPATH=/usr/lib/${ARCH}-linux-gnu/$PYLIBm && [[ -e $PYLIBPATH ]] ; then 108 | symlink_python $PYLIB $PYLIBPATH 109 | else 110 | echo " !!! Unable to find $PYLIB or $PYLIBm at known" 111 | echo " !!! locations. You have to find the library manually and" 112 | echo " !!! symlink it to the following path:" 113 | echo " !!! $TARGET/lib/$PYLIB" 114 | exit 1 115 | fi 116 | fi 117 | echo " * Done checking python" 118 | 119 | echo " * Checking LuxMark scenes" 120 | if [[ -d "LuxMark" ]] ; then 121 | FILE=scenes.tgz 122 | HASH=5db2cedea47d2f7758ecaa6802632f598cfd4ab7 123 | URL=https://github.com/LuxCoreRender/LuxMark/releases/download/luxmark_v4.0alpha0/scenes.tgz 124 | if [ ! -f $DIST/$FILE ] ; then 125 | echo " * Downloading $FILE" 126 | wget -O $DIST/$FILE $URL 127 | fi 128 | verify_hash $HASH "$DIST/$FILE" 129 | if [ $? != 0 ] ; then 130 | echo " * Resume downloading $FILE" 131 | wget -c -O $DIST/$FILE $URL 132 | 133 | verify_hash $HASH "$DIST/$FILE" 134 | if [ $? != 0 ] ; then 135 | echo " !!! Hash mismatch for $FILE" 136 | exit 1 137 | fi 138 | fi 139 | fi 140 | echo " * Done LuxMark scenes" 141 | 142 | # updating target link 143 | #ln -fs $TARGET ../target 144 | 145 | echo " * Prechecks completed" 146 | echo 147 | sleep 1 148 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | 2 | LuxCoreRender Static Compilation Environment 3 | ============================================ 4 | 5 | This collection of scripts is intended for automatic creation of build 6 | environment and Lux compilation with statically linked dependency libs. 7 | 8 | First Run: 9 | --------- 10 | On a recent Ubuntu (e.g. 19.10), you can compile LuxCore with one command: 11 | ./first_run.sh 12 | 13 | Updating: 14 | -------- 15 | To update to the latest sources, use standard git commands: 16 | 17 | cd LuxCore 18 | git pull 19 | # Go back to LinuxCompile folder and recompile the last stage (5) 20 | cd .. 21 | ./build-64-sse2 LuxCore 5 22 | 23 | Recompiling after Code Modifications: 24 | ------------------------------------ 25 | 26 | In case you edit any source files and want to recompile quickly, go to 27 | the LuxCore sources directory and run make: 28 | 29 | cd LuxCore 30 | make -j 8 31 | (-j specifies number of threads for the compilation process) 32 | 33 | The compiled binaries are in LuxCore/bin/, the compiled libraries 34 | (e.g. pyluxcore.so) are in LuxCore/lib/ 35 | 36 | Further Details 37 | =============== 38 | 39 | Layout: 40 | ------ 41 | - build 42 | The main routine. 43 | 44 | - build-64-sse2 45 | Wrapper script for compiling on the most common platforms. 46 | 47 | - distfiles 48 | Directory for the downloaded dependencies sources. 49 | 50 | - distfiles/files 51 | Dependencies manifest. 52 | 53 | - utils 54 | Directory containing a few helper scripts. 55 | 56 | Requirements: 57 | ------------ 58 | Some dependencies aren't addressed by the script, and must be resolved 59 | by the user prior to compilation. Among them are: 60 | - Python 3 (3.7 for use with Blender 2.80 and above) 61 | - OpenGL Graphics Library (MESA) 62 | - PyInstaller, it can usually be installed with a "sudo pip3 install pyinstaller" 63 | or "sudo pip install pyinstaller" 64 | - PySide, it can usually be installed with a "sudo pip3 install PySide" 65 | or "sudo pip install PySide". Ubuntu may require a 66 | "sudo apt-get install python3-pyside" 67 | - Python NumPy, it can usually be installed with on Ubuntu with a 68 | "sudo pip3 install python3-numpy" 69 | 70 | Running build script for the first time will download dependencies 71 | sources into the distfiles dir, taking about 300 MB of disk space. 72 | Complete environment requires additional 300-400 MB for each architecture. 73 | You also need enough space in your tmp directory to allow unpacking and 74 | compilation of the largest deps -- Boost and Qt. 75 | 76 | OpenCL & CUDA 77 | ------------- 78 | You don't need to install OpenCL or CUDA SDK anymore. The binaries will check at 79 | run time if OpenCL and/or CUDA are available and enable/disable the support 80 | accordingly. 81 | 82 | Usage: 83 | ----- 84 | When build script is envoked, it will check for the main prereqisites, 85 | try to figure out what's missing, and prepare the compilation environment 86 | below the 'root' directory -- the dir where the script resides (although 87 | paths are configurable in build-* wrapper scripts). 88 | 89 | The easiest way to start compilation is by using the wrapper scripts 90 | which have all the variables preconfigured for the most common platforms. 91 | Here is how you can do this: 92 | 93 | 1. Unpack LuxCoreRender sources into the subdirectory below 'root' directory 94 | (where scripts are located). The subdir with Lux sources may have 95 | any name, however 96 | if it contains 'dll' then the DLL version of LuxCore library is compiled; 97 | if it contains 'sdk' then the SDK version of LuxCore library is compiled; 98 | if it contains 'pyluxcore' then only pyluxcore target will be compiled. 99 | 100 | NOTE: you need git LFS extension (https://git-lfs.github.com) to clone 101 | LinuxCompileDeps repository. Or you can install and use 102 | https://desktop.github.com to clone the repositories; 103 | 104 | 2. Run the wrapper script passing it the name of LuxCoreRender sources dir 105 | and optionally the stage number: 106 | ./build-64-sse2 [stage] 107 | 108 | To see a list of valid stage numbers run the script without any 109 | parameters. Specifying a stage allows you to recompile any deps if 110 | needed (however in such a case it's usually better to delete 111 | target-* dir altogether and start from scratch). 112 | 113 | If stage number is omitted the script will continue from where it 114 | was previously terminated, i.e. resume compilation of unfinished 115 | deps, or begin compiling LuxCoreRender if all dependencies are in place. 116 | 117 | 3. Once the compilation is complete, Lux binaries and shared libs are 118 | packed in tar.bz2 archive and saved below the platform-specific 119 | 'target' subdirectory. 120 | 121 | 4. This step is optional. You can compile LuxMark too if you unpack the sources 122 | into the subdirectory below 'root' directory named "LuxMark". 123 | 124 | Clang: 125 | ----- 126 | The compilation environment supports Clang for compiling both LuxCoreRender 127 | dependencies and LuxCoreRender itself. In order to enable it, create an empty 128 | file named "use_clang" in compilation environment root directory. Make sure 129 | you have the following components properly installed in your system: 130 | - Clang compiler (with executable under PATH env var) 131 | - libomp (OMP library for Clang) 132 | - LLVM with Clang support and Gold linker 133 | 134 | Support: 135 | ------- 136 | If you have any questions and suggestions regarding these tools, 137 | feel free to open a topic in http://forums.luxcorerender.org/viewforum.php?f=5 138 | (or create an issue in this repository) 139 | -------------------------------------------------------------------------------- /distfiles/oiio-2.2.13.1-compiler.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2008-present Contributors to the OpenImageIO project. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | # https://github.com/OpenImageIO/oiio/blob/master/LICENSE.md 4 | 5 | ########################################################################### 6 | # 7 | # This file contains compiler-related detection, options, and actions. 8 | # 9 | # Each option declaration is kept close to the related logic for that 10 | # option. 11 | # 12 | ########################################################################### 13 | 14 | 15 | ########################################################################### 16 | # Print some basic status about the system and compiler 17 | # 18 | if (VERBOSE) 19 | message (STATUS "CMAKE_SYSTEM_NAME = ${CMAKE_SYSTEM_NAME}") 20 | message (STATUS "CMAKE_SYSTEM_VERSION = ${CMAKE_SYSTEM_VERSION}") 21 | message (STATUS "CMAKE_SYSTEM_PROCESSOR = ${CMAKE_SYSTEM_PROCESSOR}") 22 | endif () 23 | message (STATUS "CMAKE_CXX_COMPILER = ${CMAKE_CXX_COMPILER}") 24 | message (STATUS "CMAKE_CXX_COMPILER_ID = ${CMAKE_CXX_COMPILER_ID}") 25 | 26 | 27 | ########################################################################### 28 | # C++ language standard 29 | # 30 | set (CMAKE_CXX_STANDARD 11 CACHE STRING 31 | "C++ standard to prefer (11, 14, 17, 20, etc.)") 32 | set (CMAKE_CXX_STANDARD_REQUIRED ON) 33 | set (CMAKE_CXX_EXTENSIONS OFF) 34 | message (STATUS "Building for C++${CMAKE_CXX_STANDARD}") 35 | 36 | 37 | ########################################################################### 38 | # Figure out which compiler we're using 39 | # 40 | 41 | if (CMAKE_COMPILER_IS_GNUCC) 42 | execute_process (COMMAND ${CMAKE_CXX_COMPILER} -dumpversion 43 | OUTPUT_VARIABLE GCC_VERSION 44 | OUTPUT_STRIP_TRAILING_WHITESPACE) 45 | if (VERBOSE) 46 | message (STATUS "Using gcc ${GCC_VERSION} as the compiler") 47 | endif () 48 | else () 49 | set (GCC_VERSION 0) 50 | endif () 51 | 52 | if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER MATCHES "[Cc]lang") 53 | # If using any flavor of clang, set CMAKE_COMPILER_IS_CLANG. If it's 54 | # Apple's variety, set CMAKE_COMPILER_IS_APPLECLANG and 55 | # APPLECLANG_VERSION_STRING, otherwise for generic clang set 56 | # CLANG_VERSION_STRING. 57 | set (CMAKE_COMPILER_IS_CLANG 1) 58 | EXECUTE_PROCESS( COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE clang_full_version_string ) 59 | if (clang_full_version_string MATCHES "Apple") 60 | set (CMAKE_CXX_COMPILER_ID "AppleClang") 61 | set (CMAKE_COMPILER_IS_APPLECLANG 1) 62 | string (REGEX REPLACE ".* version ([0-9]+\\.[0-9]+).*" "\\1" APPLECLANG_VERSION_STRING ${clang_full_version_string}) 63 | if (VERBOSE) 64 | message (STATUS "The compiler is Clang: ${CMAKE_CXX_COMPILER_ID} version ${APPLECLANG_VERSION_STRING}") 65 | endif () 66 | else () 67 | string (REGEX REPLACE ".* version ([0-9]+\\.[0-9]+).*" "\\1" CLANG_VERSION_STRING ${clang_full_version_string}) 68 | if (VERBOSE) 69 | message (STATUS "The compiler is Clang: ${CMAKE_CXX_COMPILER_ID} version ${CLANG_VERSION_STRING}") 70 | endif () 71 | endif () 72 | elseif (CMAKE_CXX_COMPILER_ID MATCHES "Intel") 73 | set (CMAKE_COMPILER_IS_INTEL 1) 74 | if (VERBOSE) 75 | message (STATUS "Using Intel as the compiler") 76 | endif () 77 | endif () 78 | 79 | 80 | ########################################################################### 81 | # Turn on more detailed warnings and optionally consider warnings as errors 82 | # 83 | if (${PROJECT_NAME}_SUPPORTED_RELEASE) 84 | option (STOP_ON_WARNING "Stop building if there are any compiler warnings" OFF) 85 | else () 86 | option (STOP_ON_WARNING "Stop building if there are any compiler warnings" ON) 87 | endif() 88 | option (EXTRA_WARNINGS "Enable lots of extra pedantic warnings" OFF) 89 | if (NOT MSVC) 90 | add_compile_options ("-Wall") 91 | if (EXTRA_WARNINGS) 92 | add_compile_options ("-Wextra") 93 | endif () 94 | if (STOP_ON_WARNING OR DEFINED ENV{CI}) 95 | add_compile_options ("-Werror") 96 | # N.B. Force CI builds to use -Werror, even if STOP_ON_WARNING has 97 | # been switched off by default, which we may do in release 98 | # branches. 99 | endif () 100 | endif () 101 | 102 | 103 | ########################################################################### 104 | # Control symbol visibility 105 | # 106 | # We try hard to make default symbol visibility be "hidden", except for 107 | # symbols that are part of the public API, which should be marked in the 108 | # source code with a special decorator, OIIO_API. 109 | # 110 | # Additionally, there is a hidesymbols.map file that on some platforms may 111 | # give more fine-grained control for hiding symbols, because sometimes 112 | # dependent libraries may not be well behaved and need extra hiding. 113 | # 114 | set (CXX_VISIBILITY_PRESET "hidden" CACHE STRING "Symbol visibility (hidden or default") 115 | option (VISIBILITY_INLINES_HIDDEN "Hide symbol visibility of inline functions" ON) 116 | set (VISIBILITY_MAP_FILE "${PROJECT_SOURCE_DIR}/src/build-scripts/hidesymbols.map" CACHE FILEPATH "Visibility map file") 117 | set (C_VISIBILITY_PRESET ${CXX_VISIBILITY_PRESET}) 118 | if (${CXX_VISIBILITY_PRESET} STREQUAL "hidden" AND 119 | (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG) AND 120 | (CMAKE_SYSTEM_NAME MATCHES "Linux|kFreeBSD" OR CMAKE_SYSTEM_NAME STREQUAL "GNU")) 121 | # Linux/FreeBSD/Hurd: also hide all the symbols of dependent libraries 122 | # to prevent clashes if an app using this project is linked against 123 | # other versions of our dependencies. 124 | set (VISIBILITY_MAP_COMMAND "-Wl,--version-script=${VISIBILITY_MAP_FILE}") 125 | endif () 126 | 127 | 128 | ########################################################################### 129 | # Compiler-specific and platform-specific options. 130 | # 131 | # Here is where we add a whole bunch of options for specific compilers or 132 | # platforms. Usually this is to suppress false-positive compiler warnings. 133 | # 134 | if (CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_APPLECLANG) 135 | # Clang-specific options 136 | add_compile_options ("-Wno-unused-function") 137 | add_compile_options ("-Wno-overloaded-virtual") 138 | add_compile_options ("-Wno-unneeded-internal-declaration") 139 | add_compile_options ("-Wno-unused-private-field") 140 | add_compile_options ("-Wno-tautological-compare") 141 | # disable warning about unused command line arguments 142 | add_compile_options ("-Qunused-arguments") 143 | # Don't warn if we ask it not to warn about warnings it doesn't know 144 | add_compile_options ("-Wunknown-warning-option") 145 | if (CLANG_VERSION_STRING VERSION_GREATER_EQUAL 3.6 OR 146 | APPLECLANG_VERSION_STRING VERSION_GREATER 6.1) 147 | add_compile_options ("-Wno-unused-local-typedefs") 148 | endif () 149 | if (CLANG_VERSION_STRING VERSION_GREATER_EQUAL 3.9) 150 | # Don't warn about using unknown preprocessor symbols in `#if` 151 | add_compile_options ("-Wno-expansion-to-defined") 152 | endif () 153 | endif () 154 | 155 | if (CMAKE_COMPILER_IS_GNUCC AND NOT (CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_APPLECLANG)) 156 | # gcc specific options 157 | add_compile_options ("-Wno-unused-local-typedefs") 158 | add_compile_options ("-Wno-unused-result") 159 | if (NOT ${GCC_VERSION} VERSION_LESS 7.0) 160 | add_compile_options ("-Wno-aligned-new") 161 | add_compile_options ("-Wno-noexcept-type") 162 | endif () 163 | endif () 164 | 165 | if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG) 166 | # Options common to gcc and clang 167 | 168 | # Ensure this macro is set for stdint.h 169 | add_definitions ("-D__STDC_LIMIT_MACROS") 170 | add_definitions ("-D__STDC_CONSTANT_MACROS") 171 | # this allows native instructions to be used for sqrtf instead of a function call 172 | add_compile_options ("-fno-math-errno") 173 | endif () 174 | 175 | if (MSVC) 176 | # Microsoft specific options 177 | add_compile_options (/W1) 178 | add_definitions (-D_CRT_SECURE_NO_DEPRECATE) 179 | add_definitions (-D_CRT_SECURE_NO_WARNINGS) 180 | add_definitions (-D_CRT_NONSTDC_NO_WARNINGS) 181 | add_definitions (-D_SCL_SECURE_NO_WARNINGS) 182 | add_definitions (-DJAS_WIN_MSVC_BUILD) 183 | endif (MSVC) 184 | 185 | if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" 186 | AND ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i386") 187 | # For FreeBSD, minimum arch of i586 is needed for atomic cpu instructions 188 | add_compile_options (-march=i586) 189 | endif () 190 | 191 | 192 | ########################################################################### 193 | # Use ccache if found 194 | # 195 | # This can really speed up compilation by caching object files that have 196 | # been compiled previously with identical arguments and inputs. Putting this 197 | # logic here makes it work even if the user is unaware of ccache. If it's 198 | # not found on the system, it will simply be silently not used. 199 | option (USE_CCACHE "Use ccache if found" ON) 200 | find_program (CCACHE_FOUND ccache) 201 | if (CCACHE_FOUND AND USE_CCACHE) 202 | if (CMAKE_COMPILER_IS_CLANG AND USE_QT AND (NOT DEFINED ENV{CCACHE_CPP2})) 203 | message (STATUS "Ignoring ccache because clang + Qt + env CCACHE_CPP2 is not set") 204 | else () 205 | set_property (GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) 206 | set_property (GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) 207 | endif () 208 | endif () 209 | 210 | 211 | ########################################################################### 212 | # Option to force use of libc++ (the LLVM project's alternate C++ standard 213 | # library). Currently this only has an effect if using clang as the 214 | # compiler. Maybe it would also work for g++? Investigate. 215 | option (USE_LIBCPLUSPLUS "Compile with clang libc++" OFF) 216 | if (USE_LIBCPLUSPLUS AND CMAKE_COMPILER_IS_CLANG) 217 | message (STATUS "Using libc++") 218 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") 219 | endif () 220 | 221 | 222 | ########################################################################### 223 | # For gcc >= 5, allow an option to force which version of the C++ ABI to 224 | # use (mostly this affects the implementation of std::string). 225 | # 226 | # FIXME: In theory, this should also be needed for clang, if compiling with 227 | # the gcc libstdc++ toolchain. In practice, I could not get things to build 228 | # with clang properly when using this option, and I haven't yet seen a case 229 | # where it's needed. We can return to this and fix for clang if it becomes a 230 | # legit problem later. 231 | # 232 | set (GLIBCXX_USE_CXX11_ABI "" CACHE STRING "For gcc, use the new C++11 library ABI (0|1)") 233 | if (CMAKE_COMPILER_IS_GNUCC AND ${GCC_VERSION} VERSION_GREATER_EQUAL 5.0) 234 | if (NOT ${GLIBCXX_USE_CXX11_ABI} STREQUAL "") 235 | add_definitions ("-D_GLIBCXX_USE_CXX11_ABI=${GLIBCXX_USE_CXX11_ABI}") 236 | endif () 237 | endif () 238 | 239 | 240 | ########################################################################### 241 | # SIMD and machine architecture options. 242 | # 243 | # The USE_SIMD option may be set to a comma-separated list of machine / 244 | # instruction set options, such as "avx3,f16c". The list will be parsed and 245 | # the proper compiler directives added to generate code for those ISA 246 | # capabilities. 247 | # 248 | set (USE_SIMD "" CACHE STRING "Use SIMD directives (0, sse2, sse3, ssse3, sse4.1, sse4.2, avx, avx2, avx512f, f16c, aes)") 249 | set (SIMD_COMPILE_FLAGS "") 250 | if (NOT USE_SIMD STREQUAL "") 251 | message (STATUS "Compiling with SIMD level ${USE_SIMD}") 252 | if (USE_SIMD STREQUAL "0") 253 | set (SIMD_COMPILE_FLAGS ${SIMD_COMPILE_FLAGS} "-DOIIO_NO_SSE=1") 254 | else () 255 | string (REPLACE "," ";" SIMD_FEATURE_LIST ${USE_SIMD}) 256 | foreach (feature ${SIMD_FEATURE_LIST}) 257 | if (VERBOSE) 258 | message (STATUS "SIMD feature: ${feature}") 259 | endif () 260 | if (MSVC OR CMAKE_COMPILER_IS_INTEL) 261 | set (SIMD_COMPILE_FLAGS ${SIMD_COMPILE_FLAGS} "/arch:${feature}") 262 | else () 263 | set (SIMD_COMPILE_FLAGS ${SIMD_COMPILE_FLAGS} "-m${feature}") 264 | endif () 265 | if (feature STREQUAL "fma" AND (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)) 266 | # If fma is requested, for numerical accuracy sake, turn it 267 | # off by default except when we explicitly use madd. At some 268 | # future time, we should look at this again carefully and 269 | # see if we want to use it more widely by ffp-contract=fast. 270 | add_compile_options ("-ffp-contract=off") 271 | endif () 272 | endforeach() 273 | endif () 274 | add_compile_options (${SIMD_COMPILE_FLAGS}) 275 | endif () 276 | 277 | 278 | ########################################################################### 279 | # Preparation to test for compiler/language features 280 | if (NOT VERBOSE) 281 | set (CMAKE_REQUIRED_QUIET 1) 282 | endif () 283 | include (CMakePushCheckState) 284 | include (CheckCXXSourceRuns) 285 | include (CheckLibraryExists) 286 | 287 | ########################################################################### 288 | # Find out if it's safe for us to use std::regex or if we need boost.regex. 289 | # This is primarily about gcc 4.8 having a broken regex implementation. 290 | # This will be obsolete once our minimum supported gcc is >= 4.9. 291 | # 292 | #cmake_push_check_state () 293 | #check_cxx_source_runs(" 294 | # #include 295 | # int main() { 296 | # std::string r = std::regex_replace(std::string(\"abc\"), std::regex(\"b\"), \" \"); 297 | # return r == \"a c\" ? 0 : -1; 298 | # }" 299 | # USE_STD_REGEX) 300 | #cmake_pop_check_state () 301 | #if (USE_STD_REGEX) 302 | # add_definitions (-DUSE_STD_REGEX) 303 | #else () 304 | add_definitions (-DUSE_BOOST_REGEX) 305 | #endif () 306 | 307 | ########################################################################### 308 | # Check if we need libatomic on this platform. We shouldn't on mainstream 309 | # x86/x86_64, but might on some other platforms. 310 | # 311 | if (NOT MSVC AND NOT APPLE) 312 | cmake_push_check_state () 313 | check_cxx_source_runs( 314 | "#include 315 | #include 316 | std::atomic x {0}; 317 | int main() { 318 | uint64_t i = x.load(std::memory_order_relaxed); 319 | return 0; 320 | }" 321 | COMPILER_SUPPORTS_ATOMIC_WITHOUT_LIBATOMIC) 322 | cmake_pop_check_state () 323 | if (NOT COMPILER_SUPPORTS_ATOMIC_WITHOUT_LIBATOMIC) 324 | check_library_exists (atomic __atomic_load_8 "" LIBATOMIC_WORKS) 325 | if (LIBATOMIC_WORKS) 326 | list (APPEND GCC_ATOMIC_LIBRARIES "-latomic") 327 | message (STATUS "Compiler needs libatomic, added") 328 | else () 329 | message (FATAL_ERROR "Compiler needs libatomic, but not found") 330 | endif () 331 | else () 332 | if (VERBOSE) 333 | message (STATUS "Compiler supports std::atomic, no libatomic necessary") 334 | endif () 335 | endif () 336 | endif () 337 | 338 | 339 | ########################################################################### 340 | # Code coverage options 341 | # 342 | option (CODECOV "Build code coverage tests" OFF) 343 | if (CODECOV AND (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)) 344 | message (STATUS "Compiling for code coverage analysis") 345 | add_compile_options ("-ftest-coverage -fprofile-arcs -O0") 346 | add_definitions ("-D${PROJ_NAME}_CODE_COVERAGE=1") 347 | set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -ftest-coverage -fprofile-arcs") 348 | set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -ftest-coverage -fprofile-arcs") 349 | set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -ftest-coverage -fprofile-arcs") 350 | endif () 351 | 352 | 353 | ########################################################################### 354 | # Sanitizer options 355 | # 356 | set (SANITIZE "" CACHE STRING "Build code using sanitizer (address, thread)") 357 | if (SANITIZE AND (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)) 358 | message (STATUS "Compiling for sanitizer=${SANITIZE}") 359 | string (REPLACE "," ";" SANITIZE_FEATURE_LIST ${SANITIZE}) 360 | foreach (feature ${SANITIZE_FEATURE_LIST}) 361 | message (STATUS " sanitize feature: ${feature}") 362 | add_compile_options (-fsanitize=${feature}) 363 | set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=${feature}") 364 | set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fsanitize=${feature}") 365 | set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=${feature}") 366 | endforeach() 367 | add_compile_options (-g -fno-omit-frame-pointer) 368 | if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") 369 | set (SANITIZE_ON_LINUX 1) 370 | endif () 371 | if (CMAKE_COMPILER_IS_GNUCC AND ${CMAKE_SYSTEM_NAME} STREQUAL "Linux") 372 | add_compile_options ("-fuse-ld=gold") 373 | set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold") 374 | set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fuse-ld=gold") 375 | set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=gold") 376 | set (SANITIZE_LIBRARIES "asan;pthread") 377 | # set (SANITIZE_LIBRARIES "asan" "ubsan") 378 | endif() 379 | if (CMAKE_COMPILER_IS_GNUCC) 380 | # turn on glibcxx extra annotations to find vector writes past end 381 | add_definitions ("-D_GLIBCXX_SANITIZE_VECTOR=1") 382 | endif () 383 | add_definitions ("-D${PROJECT_NAME}_SANITIZE=1") 384 | endif () 385 | 386 | 387 | ########################################################################### 388 | # clang-tidy options 389 | # 390 | # clang-tidy is a static analyzer that is part of the LLVM tools. It has a 391 | # variety of the usual bug and security tests, linting, and also tests for 392 | # things like finding (and correcting!) use of older language constructs. 393 | # 394 | # If clang-tidy is found and enabled, a "clang-tidy" build target will be 395 | # enabled. The set of tests can be customized both here and through 396 | # the .clang-tidy file that is part of this project. 397 | # 398 | option (CLANG_TIDY "Enable clang-tidy" OFF) 399 | set (CLANG_TIDY_CHECKS "-*" CACHE STRING "clang-tidy checks to perform (none='-*')") 400 | set (CLANG_TIDY_ARGS "" CACHE STRING "clang-tidy args") 401 | option (CLANG_TIDY_FIX "Have clang-tidy fix source" OFF) 402 | if (CLANG_TIDY) 403 | find_program(CLANG_TIDY_EXE NAMES "clang-tidy" 404 | DOC "Path to clang-tidy executable") 405 | message (STATUS "CLANG_TIDY_EXE ${CLANG_TIDY_EXE}") 406 | if (CLANG_TIDY_EXE AND NOT ${CMAKE_VERSION} VERSION_LESS 3.6) 407 | set (CMAKE_CXX_CLANG_TIDY 408 | "${CLANG_TIDY_EXE}" 409 | ) 410 | if (CLANG_TIDY_ARGS) 411 | list (APPEND CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY_ARGS}) 412 | endif () 413 | if (CLANG_TIDY_CHECKS) 414 | list (APPEND CMAKE_CXX_CLANG_TIDY -checks="${CLANG_TIDY_CHECKS}") 415 | endif () 416 | execute_process (COMMAND ${CMAKE_CXX_CLANG_TIDY} -list-checks 417 | OUTPUT_VARIABLE tidy_checks 418 | OUTPUT_STRIP_TRAILING_WHITESPACE) 419 | if (CLANG_TIDY_FIX) 420 | list (APPEND CMAKE_CXX_CLANG_TIDY "-fix") 421 | endif () 422 | message (STATUS "clang-tidy command line is: ${CMAKE_CXX_CLANG_TIDY}") 423 | message (STATUS "${tidy_checks}") 424 | else () 425 | message (STATUS "Cannot run clang-tidy as requested") 426 | endif () 427 | # Hint: run with CLANG_TIDY_ARGS=-list-checks to list all the checks 428 | endif () 429 | 430 | 431 | ########################################################################### 432 | # clang-format options 433 | # 434 | # clang-format is a source code reformatter that is part of the LLVM tools. 435 | # It can be used to check adherence to project code formatting rules and 436 | # correct any deviations. If clang-format is found on the system, a 437 | # "clang-format" build target will trigger a reformatting. 438 | # 439 | # Note: skip all of this checking, setup, and cmake-format target if this 440 | # is being built as a subproject. 441 | if (NOT ${PROJECT_NAME}_IS_SUBPROJECT) 442 | set (CLANG_FORMAT_EXE_HINT "" CACHE PATH "clang-format executable's directory (will search if not specified") 443 | set (CLANG_FORMAT_INCLUDES "src/*.h" "src/*.cpp" 444 | CACHE STRING "Glob patterns to include for clang-format") 445 | set (CLANG_FORMAT_EXCLUDES "*pugixml*" "*SHA1*" "*/farmhash.cpp" 446 | "src/dpx.imageio/libdpx/*" 447 | "src/cineon.imageio/libcineon/*" 448 | "src/dds.imageio/squish/*" 449 | "src/gif.imageio/gif.h" 450 | "src/hdr.imageio/rgbe.cpp" 451 | "src/libutil/stb_sprintf.h" 452 | CACHE STRING "Glob patterns to exclude for clang-format") 453 | find_program (CLANG_FORMAT_EXE 454 | NAMES clang-format bin/clang-format 455 | HINTS ${CLANG_FORMAT_EXE_HINT} ENV CLANG_FORMAT_EXE_HINT 456 | ENV LLVM_DIRECTORY 457 | NO_DEFAULT_PATH 458 | DOC "Path to clang-format executable") 459 | find_program (CLANG_FORMAT_EXE NAMES clang-format bin/clang-format) 460 | if (CLANG_FORMAT_EXE) 461 | message (STATUS "clang-format found: ${CLANG_FORMAT_EXE}") 462 | # Start with the list of files to include when formatting... 463 | file (GLOB_RECURSE FILES_TO_FORMAT ${CLANG_FORMAT_INCLUDES}) 464 | # ... then process any list of excludes we are given 465 | foreach (_pat ${CLANG_FORMAT_EXCLUDES}) 466 | file (GLOB_RECURSE _excl ${_pat}) 467 | list (REMOVE_ITEM FILES_TO_FORMAT ${_excl}) 468 | endforeach () 469 | #message (STATUS "clang-format file list: ${FILES_TO_FORMAT}") 470 | file (COPY ${CMAKE_CURRENT_SOURCE_DIR}/.clang-format 471 | DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) 472 | add_custom_target (clang-format 473 | COMMAND "${CLANG_FORMAT_EXE}" -i -style=file ${FILES_TO_FORMAT} ) 474 | else () 475 | message (STATUS "clang-format not found.") 476 | endif () 477 | endif () 478 | 479 | ########################################################################### 480 | # Another way to sneak in custom compiler and DSO linking flags. 481 | # 482 | set (EXTRA_CPP_ARGS "" CACHE STRING "Extra C++ command line definitions") 483 | if (EXTRA_CPP_ARGS) 484 | message (STATUS "Extra C++ args: ${EXTRA_CPP_ARGS}") 485 | add_compile_options ("${EXTRA_CPP_ARGS}") 486 | endif() 487 | set (EXTRA_DSO_LINK_ARGS "" CACHE STRING "Extra command line definitions when building DSOs") 488 | 489 | 490 | ########################################################################### 491 | # Set the versioning for shared libraries. 492 | # 493 | if (${PROJECT_NAME}_SUPPORTED_RELEASE) 494 | # Supported releases guarantee ABI back-compatibility within the release 495 | # family, so SO versioning is major.minor. 496 | set (SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} 497 | CACHE STRING "Set the SO version for dynamic libraries") 498 | else () 499 | # Development master makes no ABI stability guarantee, so we make the 500 | # SO naming capture down to the major.minor.patch level. 501 | set (SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH} 502 | CACHE STRING "Set the SO version for dynamic libraries") 503 | endif () 504 | if (VERBOSE) 505 | message(STATUS "Setting SOVERSION to: ${SOVERSION}") 506 | endif () 507 | 508 | 509 | ########################################################################### 510 | # BUILD_SHARED_LIBS, if turned off, will disable building of .so/.dll 511 | # dynamic libraries and instead only build static libraries. 512 | # 513 | option (BUILD_SHARED_LIBS "Build shared libraries (set to OFF to build static libs)" ON) 514 | if (NOT BUILD_SHARED_LIBS) 515 | add_definitions (-D${PROJ_NAME}_STATIC_DEFINE=1) 516 | endif () 517 | 518 | 519 | ########################################################################### 520 | # LINKSTATIC, if enabled, will cause us to favor linking static versions 521 | # of library dependencies, if they are available. 522 | # 523 | option (LINKSTATIC "Link with static external libraries when possible" OFF) 524 | if (LINKSTATIC) 525 | #set (_orig_link_suffixes ${CMAKE_FIND_LIBRARY_SUFFIXES}) 526 | message (STATUS "Statically linking external libraries when possible") 527 | if (WIN32) 528 | set (CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) 529 | else () 530 | set (CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) 531 | endif () 532 | endif () 533 | 534 | 535 | ########################################################################### 536 | # Any extra logic to be run only for CI builds goes here. 537 | # 538 | if (DEFINED ENV{CI} OR DEFINED ENV{GITHUB_ACTIONS}) 539 | add_definitions ("-D${PROJ_NAME}_CI=1" "-DBUILD_CI=1") 540 | if (APPLE) 541 | # Keep Mono framework from being incorrectly searched for include 542 | # files on GitHub Actions CI. 543 | set(CMAKE_FIND_FRAMEWORK LAST) 544 | endif () 545 | endif () 546 | 547 | 548 | ########################################################################### 549 | # Rpath handling at the install step 550 | # 551 | set (MACOSX_RPATH ON) 552 | if (CMAKE_SKIP_RPATH) 553 | # We need to disallow the user from truly setting CMAKE_SKIP_RPATH, since 554 | # we want to run the generated executables from the build tree in order to 555 | # generate the manual page documentation. However, we make sure the 556 | # install rpath is unset so that the install tree is still free of rpaths 557 | # for linux packaging purposes. 558 | set (CMAKE_SKIP_RPATH FALSE) 559 | unset (CMAKE_INSTALL_RPATH) 560 | else () 561 | if (NOT CMAKE_INSTALL_RPATH) 562 | set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}") 563 | endif () 564 | # add the automatically determined parts of the RPATH that 565 | # point to directories outside the build tree to the install RPATH 566 | set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) 567 | if (VERBOSE) 568 | message (STATUS "CMAKE_INSTALL_RPATH = ${CMAKE_INSTALL_RPATH}") 569 | endif () 570 | endif () 571 | 572 | 573 | 574 | ########################################################################### 575 | # Macro to install targets to the appropriate locations. Use this instead 576 | # of the install(TARGETS ...) signature. Note that it adds it to the 577 | # export targets list for when we generate config files. 578 | # 579 | # Usage: 580 | # 581 | # install_targets (target1 [target2 ...]) 582 | # 583 | macro (install_targets) 584 | install (TARGETS ${ARGN} 585 | EXPORT ${PROJ_NAME}_EXPORTED_TARGETS 586 | RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT user 587 | LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT user 588 | ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT developer) 589 | endmacro() 590 | --------------------------------------------------------------------------------