diff --git a/build-linux.sh b/build-linux.sh new file mode 100755 index 00000000..cb0f2aff --- /dev/null +++ b/build-linux.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +BUILD_DIR=build-linux +EMBREE_TGZ="https://github.com/embree/embree/releases/download/v2.11.0/embree-2.11.0.x86_64.linux.tar.gz" +EMBREE_TGZ_NAME=$(basename "$EMBREE_TGZ") +EMBREE_DIR_NAME=$(basename "$EMBREE_TGZ" ".tar.gz") +EMBREE_WITH_VERSION=$(basename "$EMBREE_TGZ" ".x86_64.linux.tar.gz") + +if [ -d "$BUILD_DIR" ]; then + echo "$BUILD_DIR already exists, remove it first" + exit 1 +fi + +mkdir "$BUILD_DIR" +cd "$BUILD_DIR" +wget "$EMBREE_TGZ" +tar xf "$EMBREE_TGZ_NAME" +EMBREE_CMAKE_DIR="$(pwd)/$EMBREE_DIR_NAME/lib/cmake/$EMBREE_WITH_VERSION" +cmake .. -DCMAKE_BUILD_TYPE=Release -Dembree_DIR="$EMBREE_CMAKE_DIR" +make -j8 +cpack + diff --git a/light/CMakeLists.txt b/light/CMakeLists.txt index 32e4d54d..35edc8f5 100644 --- a/light/CMakeLists.txt +++ b/light/CMakeLists.txt @@ -61,8 +61,17 @@ if (embree_FOUND) install(FILES ${EMBREE_DLLS} DESTINATION bin) endif() - if(APPLE) - file(GLOB EMBREE_DYLIBS_WITH_SYMLINKS "${embree_DIR}/../../*.dylib") + if(UNIX) + if (APPLE) + set(SHARED_LIB_EXT dylib) + elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux") + set(SHARED_LIB_EXT "so.*") + else () + message(FATAL_ERROR "only Linux and macOS currently supported") + endif() + + + file(GLOB EMBREE_DYLIBS_WITH_SYMLINKS "${embree_DIR}/../../*.${SHARED_LIB_EXT}") # Gather all .dylib's that are not symlinks foreach(EMBREE_DYLIB ${EMBREE_DYLIBS_WITH_SYMLINKS}) @@ -77,7 +86,11 @@ if (embree_FOUND) endforeach() # so the executable will search for dylib's in the same directory as the executable - add_custom_command(TARGET light POST_BUILD COMMAND bash ARGS -c \"install_name_tool -add_rpath @loader_path $ || true\") + if(APPLE) + add_custom_command(TARGET light POST_BUILD COMMAND bash ARGS -c \"install_name_tool -add_rpath @loader_path $ || true\") + elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux") + SET(CMAKE_EXE_LINKER_FLAGS "-Wl,-rpath,\$ORIGIN") + endif() install(FILES ${EMBREE_DYLIBS} DESTINATION bin) endif()