diff --git a/.github/workflows/build-ci.yml b/.github/workflows/build-ci.yml index 20724f4f40a..35748d95a21 100644 --- a/.github/workflows/build-ci.yml +++ b/.github/workflows/build-ci.yml @@ -97,29 +97,36 @@ jobs: sudo apt-fast update sudo apt-fast install -y ${{ env.packages }} + - name: Setup CMake + run: | + cp scripts/CMakeBuildPresetsCI.json CMakeUserPresets.json + cmake --preset linux-x64-release + - name: Build GCC - run: ./bootstrap cmake && make -C build + run: cmake --build ./build --target all - name: Build Pioneer Data - run: make -C build build-data + run: cmake --build ./build --target build-data - name: Run Tests run: ./build/unittest - name: Build Release - run: ./scripts/build-release.sh + run: | + cmake --build ./build --target install + ./scripts/package-release.sh - name: Upload Artifact uses: actions/upload-artifact@v3 with: name: Linux-Artifacts - path: release/zip/*.tar.gz + path: release/pioneer-linux-x64-release-*.tar.gz - name: Upload Release Files uses: softprops/action-gh-release@v1 if: ${{ github.event_name == 'release' }} with: - files: release/zip/pioneer-*.tar.gz + files: release/pioneer-linux-x64-release-*.tar.gz env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -137,16 +144,17 @@ jobs: sudo apt-fast update sudo apt-fast install -y clang-8 ${{ env.packages }} - - name: Build Clang + - name: Setup CMake run: | + cp scripts/CMakeBuildPresetsCI.json CMakeUserPresets.json export CC=clang CXX=clang++ - ./bootstrap cmake && make -C build + cmake --preset linux-x64-release + + - name: Build Clang + run: cmake --build ./build --target all - name: Build Pioneer Data - run: make -C build build-data + run: cmake --build ./build --target build-data - name: Run Tests run: ./build/unittest - - - name: Build Release - run: ./scripts/build-release.sh diff --git a/.gitignore b/.gitignore index 7951d0855a8..314cbc078b0 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,8 @@ codedoc/ nd/Data/ doxygen/html doxygen/latex +/release +/out .deps *.swp @@ -80,12 +82,12 @@ pioneer-*.tar.* # meta-build tooling products etc. shouldn't be tracked Makefile Makefile.in -/release Debug/ PreRelease/ Profile/ Release/ cmake-* +CMakeUserPresets.json compile # IDEs make their local configurations shouldn't be tracked diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c93c62c60b..977bdd20f50 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,17 +12,13 @@ if(POLICY CMP0072) endif() include(GNUInstallDirs) +include(cmake/InstallPioneer.cmake) if (MINGW) # Fix build errors on AppVeyor with MinGW due to a broken GLEW config script list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake/Modules) endif (MINGW) -# We don't want a 'bin' folder on Windows -if (WIN32) - set(CMAKE_INSTALL_BINDIR ${CMAKE_INSTALL_PREFIX}) -endif (WIN32) - # Put the output into the root dir so it can be run from Visual Studio if (MSVC) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}) @@ -107,13 +103,6 @@ endif() string(TIMESTAMP PROJECT_VERSION "%Y%m%d") -if (NOT PIONEER_DATA_DIR) - set(PIONEER_DATA_DIR ${CMAKE_INSTALL_FULL_DATADIR}/pioneer/data CACHE PATH - "Path where game data will be installed" FORCE) -endif (NOT PIONEER_DATA_DIR) - -file(TO_NATIVE_PATH ${PIONEER_DATA_DIR} _PIONEER_DATA_DIR) - if (MINGW) # Enable PRIxYY macros on MinGW add_definitions(-D__STDC_FORMAT_MACROS) @@ -415,20 +404,32 @@ else (MODELCOMPILER) endif(MODELCOMPILER) install(TARGETS ${PROJECT_NAME} editor modelcompiler savegamedump - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + RUNTIME DESTINATION ${PIONEER_INSTALL_BINDIR} ) install(DIRECTORY data/ - DESTINATION ${PIONEER_DATA_DIR} + DESTINATION ${PIONEER_INSTALL_DATADIR}/data REGEX "/models" EXCLUDE PATTERN ".gitignore" EXCLUDE PATTERN "listdata.*" EXCLUDE PATTERN "Makefile.am" EXCLUDE ) install(DIRECTORY data/models/ - DESTINATION ${PIONEER_DATA_DIR}/models + DESTINATION ${PIONEER_INSTALL_DATADIR}/data/models FILES_MATCHING PATTERN "*.sgm" PATTERN "*.dds" PATTERN "*.png" ) +list(APPEND install_txt + "AUTHORS.txt" + "Changelog.txt" + "Modelviewer.txt" + "Quickstart.txt" + "README.md") + +install(FILES ${install_txt} DESTINATION ${PIONEER_INSTALL_DATADIR}) + +install(DIRECTORY ${CMAKE_SOURCE_DIR}/licenses + DESTINATION ${PIONEER_INSTALL_DATADIR}) + if (WIN32) configure_file(pioneer.iss.cmakein pioneer.iss @ONLY) file(GLOB win_libs ../pioneer-thirdparty/win32/bin/${MSVC_ARCH}/vs2019/*.dll) @@ -439,7 +440,7 @@ if (WIN32) add_custom_target(win-installer COMMAND ${ISCC} /Q pioneer.iss) endif (WIN32) -if (UNIX) +if (UNIX AND NOT PIONEER_INSTALL_INPLACE) set(PIONEER_DESKTOP_FILE ${CMAKE_BINARY_DIR}/metadata/net.pioneerspacesim.Pioneer.desktop) configure_file(metadata/net.pioneerspacesim.Pioneer.desktop.cmakein ${PIONEER_DESKTOP_FILE} @ONLY) install(FILES ${PIONEER_DESKTOP_FILE} @@ -455,4 +456,4 @@ if (UNIX) RENAME net.pioneerspacesim.Pioneer.png ) endforeach() -endif (UNIX) +endif (UNIX AND NOT PIONEER_INSTALL_INPLACE) diff --git a/buildopts.h.cmakein b/buildopts.h.cmakein index 850b26f65b5..1a8eef2c49c 100644 --- a/buildopts.h.cmakein +++ b/buildopts.h.cmakein @@ -3,7 +3,7 @@ #define PIONEER_EXTRAVERSION "@PROJECT_VERSION_GIT@" #define PIONEER_VERSION "@PROJECT_VERSION@" -#define PIONEER_DATA_DIR "@_PIONEER_DATA_DIR@" +#define PIONEER_DATA_DIR "@PIONEER_DATA_RUNTIME_DIR@" #define REMOTE_LUA_REPL_PORT @REMOTE_LUA_REPL_PORT@ #cmakedefine01 WITH_OBJECTVIEWER diff --git a/cmake/InstallPioneer.cmake b/cmake/InstallPioneer.cmake new file mode 100644 index 00000000000..2722239a6c5 --- /dev/null +++ b/cmake/InstallPioneer.cmake @@ -0,0 +1,34 @@ +# Setup script for Pioneer installation paths + +option(PIONEER_INSTALL_INPLACE "Should an in-place install be generated" OFF) + +if (NOT PIONEER_INSTALL_DATADIR) + set(PIONEER_INSTALL_DATADIR ${CMAKE_INSTALL_DATADIR}/pioneer CACHE PATH + "Path where pioneer's data/ folder will be installed" FORCE) +endif (NOT PIONEER_INSTALL_DATADIR) + +if (NOT PIONEER_INSTALL_BINDIR) + set(PIONEER_INSTALL_BINDIR ${CMAKE_INSTALL_BINDIR} CACHE PATH + "Path where Pioneer's executables will be installed" FORCE) +endif (NOT PIONEER_INSTALL_BINDIR) + +# We don't want a 'bin' folder on Windows +if (WIN32) + set(CMAKE_INSTALL_BINDIR ${CMAKE_INSTALL_PREFIX}) +endif (WIN32) + +# If doing an in-place installation, everything is installed in the root of the prefix +if (PIONEER_INSTALL_INPLACE) + set(PIONEER_INSTALL_BINDIR ${CMAKE_INSTALL_PREFIX}) + set(PIONEER_INSTALL_DATADIR ${CMAKE_INSTALL_PREFIX}) + # don't load data from system-wide install + set(PIONEER_DATA_DIR "data") +endif (PIONEER_INSTALL_INPLACE) + +# Expected location of game data +if (NOT PIONEER_DATA_DIR) + set(PIONEER_DATA_DIR ${CMAKE_INSTALL_FULL_DATADIR}/pioneer/data CACHE PATH + "Runtime path to load game data from" FORCE) +endif (NOT PIONEER_DATA_DIR) + +file(TO_NATIVE_PATH ${PIONEER_DATA_DIR} PIONEER_DATA_RUNTIME_DIR) diff --git a/scripts/CMakeBuildPresetsCI.json b/scripts/CMakeBuildPresetsCI.json new file mode 100644 index 00000000000..48a7e9b6741 --- /dev/null +++ b/scripts/CMakeBuildPresetsCI.json @@ -0,0 +1,42 @@ +{ + "version": 2, + "configurePresets": [ + { + "name": "linux-x64-release", + "displayName": "Linux x64 Release", + "description": "in-place installation target; Opt=yes; Profiler=no", + "binaryDir": "${sourceDir}/build/", + "generator": "Unix Makefiles", + "cacheVariables": { + "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}", + "PIONEER_INSTALL_INPLACE": "1", + "CMAKE_BUILD_TYPE": "RelWithDebInfo" + }, + "vendor": { + "microsoft.com/VisualStudioSettings/CMake/1.0": { + "hostOS": [ + "Linux" + ] + } + } + }, + { + "name": "linux-x64-release-global", + "displayName": "Linux x64 Release", + "description": "global installation target; Opt=yes; Profiler=no", + "binaryDir": "${sourceDir}/build/", + "generator": "Unix Makefiles", + "cacheVariables": { + "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}", + "CMAKE_BUILD_TYPE": "RelWithDebInfo" + }, + "vendor": { + "microsoft.com/VisualStudioSettings/CMake/1.0": { + "hostOS": [ + "Linux" + ] + } + } + } + ] +} diff --git a/scripts/package-release.sh b/scripts/package-release.sh new file mode 100755 index 00000000000..cbb0a952ce7 --- /dev/null +++ b/scripts/package-release.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +# Package a build and prepare it for upload to Github. + +TAG_NAME=$(git describe HEAD) +if [ -z "$TAG_NAME" ]; then + TAG_NAME=$(date +%Y%m%d) +fi + +mkdir release + +mv out/install/linux-x64-release "release/pioneer-linux-x64-$TAG_NAME" +cd release + +tar -czf "pioneer-linux-x64-$TAG_NAME.tar.gz" "pioneer-linux-x64-$TAG_NAME" + +if [ $? -ne 0 ]; then + echo "Release failed!" + exit 1 +fi + +echo "Release finished successfully!" + +exit 0