build: make building on linux with embree easier

This commit is contained in:
Eric Wasylishen 2016-09-23 00:06:21 -06:00
parent fedc7926ff
commit 048e19fbf2
2 changed files with 38 additions and 3 deletions

22
build-linux.sh Executable file
View File

@ -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

View File

@ -61,8 +61,17 @@ if (embree_FOUND)
install(FILES ${EMBREE_DLLS} DESTINATION bin)
endif()
if(UNIX)
if (APPLE)
file(GLOB EMBREE_DYLIBS_WITH_SYMLINKS "${embree_DIR}/../../*.dylib")
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
if(APPLE)
add_custom_command(TARGET light POST_BUILD COMMAND bash ARGS -c \"install_name_tool -add_rpath @loader_path $<TARGET_FILE:light> || true\")
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,-rpath,\$ORIGIN")
endif()
install(FILES ${EMBREE_DYLIBS} DESTINATION bin)
endif()