diff --git a/.github/workflows/build-ci.yml b/.github/workflows/build-ci.yml index 20724f4f40a..ec8a405376a 100644 --- a/.github/workflows/build-ci.yml +++ b/.github/workflows/build-ci.yml @@ -19,6 +19,7 @@ concurrency: cancel-in-progress: ${{ github.ref == 'refs/heads/master' }} env: + RELEASE_TAG: ${{ github.ref_name }} packages: > mesa-common-dev libfreeimage-dev @@ -123,6 +124,54 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + build-cmake: + runs-on: ubuntu-20.04 + + steps: + # Checkout the repository as $GITHUB_WORKSPACE + - uses: actions/checkout@v3 + + - name: Install Dependencies + run: | + sudo apt-fast update + sudo apt-fast install -y ${{ env.packages }} + + - name: Setup CMake + run: | + cp scripts/CMakeBuildPresetsCI.json CMakeUserPresets.json + cmake --list-presets + cmake --preset linux-x64-release + + - name: Build GCC + run: cmake --build ./build --target all + + - name: Build Pioneer Data + run: cmake --build ./build --target build-data + + - name: Run Tests + run: ./build/unittest + + - name: Build Release + run: | + cmake --build ./build --target install + mkdir release && cd release + mv out/install/linux-x64-release "pioneer-linux-x64-$RELEASE_TAG" + tar -czf "pioneer-linux-x64-$RELEASE_TAG.tar.gz" "pioneer-linux-x64-$RELEASE_TAG" + + - name: Upload Artifact + uses: actions/upload-artifact@v3 + with: + name: Linux-Artifacts + path: release/pioneer-linux-x64-release-$RELEASE_TAG.tar.gz + + - name: Upload Release Files + uses: softprops/action-gh-release@v1 + if: ${{ github.event_name == 'release' }} + with: + files: release/pioneer-*.tar.gz + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + build-clang: runs-on: ubuntu-20.04 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 450b2575fdb..34e17a506ae 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) configure_file(CI/appveyor/msvc/publish.cmd.cmakein publish.cmd @ONLY) @@ -440,7 +441,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} @@ -456,4 +457,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" + ] + } + } + } + ] +}