From 1e550e905991c18a44e5d3ad65574392c109164d Mon Sep 17 00:00:00 2001 From: Ted John Date: Tue, 30 May 2017 22:34:13 +0100 Subject: [PATCH] Create portable builds Which set rpath to $ORIGIN so it can be run out the box. --- .travis.yml | 4 ++-- CMakeLists.txt | 15 ++++++++++----- src/openrct2-ui/CMakeLists.txt | 5 +++++ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4e9ef7ac62..61ed0b283d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,13 +16,13 @@ matrix: services: - docker env: - - OPENRCT2_CMAKE_OPTS="-DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=OpenRCT2" TARGET=ubuntu_amd64 + - OPENRCT2_CMAKE_OPTS="-DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=OpenRCT2 -DPORTABLE=ON" TARGET=ubuntu_amd64 - secure: "S3u2VCE2Vy8KNXoeh+DhnzjCmgTX0r95uEZrXDU+IKANOOCKn7Dg4OFDZE3LY/i1y2/EUDpnR5yLC38Ks795EUP/sv/OoMl4tjQ20yERjqWh+gcIRrgx7SdVabuAh3t4aBdaLD4Pfnj5avxeCt6rL7yGnj0wdbrbJSBZPsgSnuQ=" after_success: - sudo chown -R $USER build - cd build # make install is done inside docker - - mv OpenRCT2/bin/openrct2 OpenRCT2/ && mv OpenRCT2/share/openrct2 OpenRCT2/data && mv OpenRCT2/share/doc/openrct2 OpenRCT2/doc + - mv OpenRCT2/bin/openrct2 OpenRCT2/ && mv OpenRCT2/bin/libopenrct2.so OpenRCT2/ && mv OpenRCT2/share/openrct2 OpenRCT2/data && mv OpenRCT2/share/doc/openrct2 OpenRCT2/doc - rm -rf OpenRCT2/bin OpenRCT2/share # remove empty dirs - tar cvzf openrct2-linux.tar.gz OpenRCT2/ - if [[ "z${TRAVIS_TAG}" != "z" ]] ; then diff --git a/CMakeLists.txt b/CMakeLists.txt index df831b8f11..e1d8c50121 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,7 @@ set(TITLE_SEQUENCE_SHA1 "79ffb2585d12abcbfce205d7696e3472a504b005") option(FORCE32 "Force 32-bit build. It will add `-m32` to compiler flags.") option(WITH_TESTS "Build tests") +option(PORTABLE "Create a portable build (-rpath=$ORIGIN)" OFF) # Define current git branch execute_process( @@ -81,11 +82,15 @@ install(CODE "file(DOWNLOAD ${TITLE_SEQUENCE_URL} \$ENV{DESTDIR}${CMAKE_INSTALL_ install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/share/${PROJECT}/title/ \"${CMAKE_COMMAND}\" -E tar xvf title-sequences.zip)") install(CODE "file(REMOVE \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/share/${PROJECT}/title/title-sequences.zip)") if (WIN32) - install(TARGETS "libopenrct2" RUNTIME DESTINATION bin) -else() - install(TARGETS "libopenrct2" LIBRARY DESTINATION lib) -endif() -install(TARGETS "openrct2" RUNTIME DESTINATION bin) + install(TARGETS "libopenrct2" RUNTIME DESTINATION "bin") +else () + if (PORTABLE) + install(TARGETS "libopenrct2" LIBRARY DESTINATION "bin") + else () + install(TARGETS "libopenrct2" LIBRARY DESTINATION "lib") + endif () +endif () +install(TARGETS "openrct2" RUNTIME DESTINATION "bin") install(FILES "${CMAKE_CURRENT_BINARY_DIR}/g2.dat" DESTINATION "share/openrct2") install(DIRECTORY "data/" DESTINATION "share/openrct2") install(FILES ${DOC_FILES} DESTINATION "share/doc/openrct2") diff --git a/src/openrct2-ui/CMakeLists.txt b/src/openrct2-ui/CMakeLists.txt index 7ff4d16ba3..091381affa 100644 --- a/src/openrct2-ui/CMakeLists.txt +++ b/src/openrct2-ui/CMakeLists.txt @@ -75,6 +75,11 @@ if (WIN32) # tell it that it is set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__USE_MINGW_ANSI_STDIO=1") endif () + +if (PORTABLE) + set(CMAKE_INSTALL_RPATH "$ORIGIN") +endif () + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11 ${TARGET_M}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++14 ${TARGET_M}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${TARGET_M}")