-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from h67ma/basic_cpack
Basic cpack
- Loading branch information
Showing
12 changed files
with
290 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: CPack and upload | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{matrix.os}} | ||
|
||
strategy: | ||
fail-fast: true | ||
|
||
matrix: | ||
os: [ubuntu-latest, windows-latest] | ||
build_type: [Release] | ||
include: | ||
- os: windows-latest | ||
c_compiler: cl | ||
cpp_compiler: cl | ||
- os: ubuntu-latest | ||
c_compiler: gcc | ||
cpp_compiler: g++ | ||
|
||
steps: | ||
- name: Install Linux dependencies | ||
if: ${{ matrix.os == 'ubuntu-latest' }} | ||
run: | | ||
sudo apt update | ||
sudo apt install -y libfreetype-dev libx11-dev libxrandr-dev libudev-dev libgl-dev libflac-dev libvorbis-dev libopenal-dev libxcursor-dev | ||
- name: Install Windows dependencies | ||
if: ${{ matrix.os == 'windows-latest' }} | ||
run: | | ||
iwr -useb get.scoop.sh -outfile 'install.ps1' | ||
.\install.ps1 -RunAsAdmin | ||
scoop update | ||
scoop bucket add extras | ||
scoop install nsis | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Configure | ||
run: > | ||
cmake -B ${{github.workspace}}/build | ||
-DCMAKE_CXX_COMPILER=${{matrix.cpp_compiler}} | ||
-DCMAKE_C_COMPILER=${{matrix.c_compiler}} | ||
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} | ||
-S ${{github.workspace}} | ||
- name: Build | ||
run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} | ||
|
||
- name: Package | ||
run: cpack --config ${{github.workspace}}/build/CPackConfig.cmake | ||
|
||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: cpacked | ||
path: | | ||
${{github.workspace}}/foerr-*.tar.gz | ||
${{github.workspace}}/foerr-*.exe | ||
if-no-files-found: ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
foerr | ||
.cache/ | ||
.vscode/ | ||
build/ | ||
*.dll | ||
*.gch | ||
*.log | ||
*.o | ||
*.svg | ||
*.tmp | ||
_CPack_Packages/ | ||
foerr-*.tar.gz | ||
foerr-*.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,28 @@ | ||
# based on https://github.com/nocnokneo/cmake-git-versioning-example | ||
if(GIT_EXECUTABLE) | ||
get_filename_component(SRC_DIR ${SRC} DIRECTORY) | ||
execute_process( | ||
COMMAND ${GIT_EXECUTABLE} describe --tags --dirty --match "v*" | ||
WORKING_DIRECTORY ${SRC_DIR} | ||
OUTPUT_VARIABLE GIT_DESCRIBE_VERSION | ||
RESULT_VARIABLE GIT_DESCRIBE_ERROR_CODE | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
if(NOT GIT_DESCRIBE_ERROR_CODE) | ||
set(GIT_VERSION ${GIT_DESCRIBE_VERSION}) | ||
function(get_git_version GIT_EXECUTABLE SRC_DIR) | ||
if(GIT_EXECUTABLE) | ||
execute_process( | ||
COMMAND ${GIT_EXECUTABLE} describe --tags --dirty --match "v*" | ||
WORKING_DIRECTORY ${SRC_DIR} | ||
OUTPUT_VARIABLE GIT_DESCRIBE_VERSION | ||
RESULT_VARIABLE GIT_DESCRIBE_ERROR_CODE | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
if(NOT GIT_DESCRIBE_ERROR_CODE) | ||
set(_GIT_VERSION ${GIT_DESCRIBE_VERSION}) | ||
endif() | ||
endif() | ||
endif() | ||
|
||
if(NOT DEFINED GIT_VERSION) | ||
set(GIT_VERSION v0.0.0-unknown) | ||
message(WARNING "Failed to determine GIT_VERSION. Using default version: \"${GIT_VERSION}\".") | ||
endif() | ||
if(NOT DEFINED _GIT_VERSION) | ||
set(_GIT_VERSION v0.0.0-unknown) | ||
message(WARNING "Failed to determine GIT_VERSION. Using default version: \"${_GIT_VERSION}\".") | ||
endif() | ||
|
||
configure_file(${SRC} ${DST} @ONLY) | ||
set(GIT_VERSION ${_GIT_VERSION} PARENT_SCOPE) | ||
endfunction() | ||
|
||
if(DEFINED SRC) | ||
get_filename_component(SRC_DIR ${SRC} DIRECTORY) | ||
get_git_version(${GIT_EXECUTABLE} ${SRC_DIR}) | ||
configure_file(${SRC} ${DST} @ONLY) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
# SPDX-License-Identifier: GPL-3.0-only | ||
# | ||
# (c) 2022 h67ma <[email protected]> | ||
# (c) 2022-2023 h67ma <[email protected]> | ||
|
||
cmake_minimum_required(VERSION 3.15) | ||
set(CMAKE_CXX_STANDARD 17) | ||
set(CXX_STANDARD_REQUIRED ON) | ||
include(CMakeGitVersion.cmake) | ||
|
||
project(foerr_game | ||
project(foerr | ||
LANGUAGES CXX | ||
) | ||
|
||
|
@@ -15,6 +16,46 @@ if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0") | |
cmake_policy(SET CMP0135 NEW) | ||
endif() | ||
|
||
add_subdirectory(deps/sfml) | ||
# EXCLUDE_FROM_ALL skips SFML's files from being installed. | ||
# we don't need them, also some of them want to install to system paths and require superuser privileges to do so | ||
add_subdirectory(deps/sfml EXCLUDE_FROM_ALL) | ||
|
||
add_subdirectory(deps/nlohmann_json) | ||
add_subdirectory(src) | ||
|
||
install(DIRECTORY res DESTINATION ".") | ||
install(DIRECTORY fonts DESTINATION ".") | ||
install(FILES LICENSE DESTINATION ".") | ||
|
||
if(WIN32) | ||
# seems a bit hacky but I guess it works? | ||
# TODO detect x86/x64 and select dll from proper path | ||
install(FILES "${PROJECT_BINARY_DIR}/_deps/sfml-src/extlibs/bin/x64/openal32.dll" DESTINATION ".") | ||
endif() | ||
|
||
set(CPACK_BINARY_STGZ "OFF") | ||
set(CPACK_BINARY_TZ "OFF") | ||
|
||
if(WIN32) | ||
set(CPACK_BINARY_NSIS "ON") | ||
set(CPACK_NSIS_MUI_ICON "${CMAKE_SOURCE_DIR}/res/ico/foerr.ico") | ||
set(CPACK_NSIS_INSTALLED_ICON_NAME "foerr.exe") | ||
set(CPACK_NSIS_PACKAGE_NAME "FoE: Remains of Remains") | ||
set(CPACK_NSIS_EXECUTABLES_DIRECTORY ".") | ||
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL "ON") | ||
elseif(UNIX) | ||
set(CPACK_BINARY_TGZ "ON") | ||
endif() | ||
|
||
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE") | ||
set(CPACK_PACKAGE_INSTALL_DIRECTORY "foerr") | ||
set(CPACK_MONOLITHIC_INSTALL "ON") | ||
|
||
# ':' not allowed in shortcut name as it will be a file name. | ||
# for some reason these shortcuts remain in "Start Menu" after uninstall | ||
set(CPACK_PACKAGE_EXECUTABLES "foerr" "FoE Remains of Remains") | ||
|
||
get_git_version(${GIT_EXECUTABLE} ${CMAKE_SOURCE_DIR}) | ||
set(CPACK_PACKAGE_VERSION ${GIT_VERSION}) | ||
|
||
include(CPack) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
# SPDX-License-Identifier: GPL-3.0-only | ||
# | ||
# (c) 2022 h67ma <[email protected]> | ||
# (c) 2022-2023 h67ma <[email protected]> | ||
|
||
file(GLOB_RECURSE SOURCES *.cpp) | ||
|
||
add_executable(foerr ${SOURCES}) | ||
if(WIN32) | ||
# WIN32 flag prevents the console window from showing up alongside graphical window | ||
# see https://www.sfml-dev.org/faq.php#tr-win-console | ||
add_executable(foerr WIN32 ${SOURCES} exe_icon.rc) | ||
else() | ||
add_executable(foerr ${SOURCES}) | ||
endif() | ||
|
||
if(WIN32) | ||
# set a tolerable warning level | ||
|
@@ -16,10 +22,13 @@ else() | |
endif() | ||
|
||
target_link_libraries(foerr PRIVATE sfml-graphics sfml-window sfml-system sfml-audio nlohmann_json) | ||
if(WIN32) | ||
# needed for the WIN32 flag | ||
# see https://www.sfml-dev.org/faq.php#tr-win-console | ||
target_link_libraries(foerr PRIVATE sfml-main) | ||
endif() | ||
|
||
install(TARGETS foerr DESTINATION foerr) | ||
install(DIRECTORY "${PROJECT_BINARY_DIR}/../res" DESTINATION foerr) | ||
# TODO? on binbows also copy openal to install dir | ||
install(TARGETS foerr DESTINATION ".") | ||
|
||
# add version from git-describe | ||
# based on https://github.com/nocnokneo/cmake-git-versioning-example | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
IDI_ICON1 ICON DISCARDABLE "../res/ico/foerr.ico" |
Oops, something went wrong.