Skip to content

Commit

Permalink
🚀 Added install and package target for installing the game on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
AnotherFoxGuy committed Feb 5, 2024
1 parent 8b2aa1f commit ec05da3
Show file tree
Hide file tree
Showing 9 changed files with 783 additions and 173 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/build-game.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ jobs:
ninja
shell: cmd

- name: Upload bin folder
uses: actions/upload-artifact@v4
with:
name: Windows
path: bin/Release/


- name: Clean Conan pkgs
run: conan cache clean "*" -sbd
shell: cmd
16 changes: 16 additions & 0 deletions CMake/FixupBundle.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
include(BundleUtilities)
include(${BIN_DIR}/cmake/ConanBinDirs.cmake)

if (APPLE)
set(PLUGIN_EXTENSION "dylib")
elseif (WIN32)
set(PLUGIN_EXTENSION "dll")
else()
set(PLUGIN_EXTENSION "so")
endif()

file(GLOB PLUGINS "${LIB_DIR}/Plugin_*.${PLUGIN_EXTENSION}")
file(GLOB RENDERSYSTEMS "${LIB_DIR}/RenderSystem_*.${PLUGIN_EXTENSION}")

set(EXTRA_LIBS ${PLUGINS} ${RENDERSYSTEMS})
fixup_bundle("${EXECUTABLE}" "${EXTRA_LIBS}" "${CONAN_BIN_DIRS}")
58 changes: 56 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if (NOT WIN32)
find_package(PkgConfig)
endif ()

project(StuntRally3)
project(StuntRally3 VERSION "3.0.2")


# User Options to disable building components --------
Expand Down Expand Up @@ -76,7 +76,6 @@ endif ()
# Check for dependencies
include(DependenciesConfig)


macro(add_recursive dir retVal)
file(GLOB GLOB_RESULT ${dir}/*.h ${dir}/*.cpp ${dir}/*.c)
list(APPEND ${retVal} ${GLOB_RESULT})
Expand Down Expand Up @@ -191,8 +190,63 @@ foreach (EXE ${EXE_LIST})
Vorbis::vorbisfile
)

if (WIN32)
install(TARGETS ${EXE} DESTINATION .)

# add a post-build command to copy DLLs beside the executable
add_custom_command(
TARGET ${EXE}
POST_BUILD
COMMAND ${CMAKE_COMMAND}
-DEXECUTABLE="$<TARGET_FILE:${EXE}>"
-DBIN_DIR="${CMAKE_BINARY_DIR}"
-DLIB_DIR="$<TARGET_FILE_DIR:${EXE}>"
-P "${CMAKE_SOURCE_DIR}/CMake/FixupBundle.cmake"
)
endif ()
endforeach ()

message(STATUS "---------- SR end")


# Install targets
# -----------------------

if (WIN32)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/data/ DESTINATION . PATTERN ".git/*" EXCLUDE)
install(DIRECTORY ${EXECUTABLE_OUTPUT_PATH}/ DESTINATION . FILES_MATCHING PATTERN "*.dll" )
install(FILES ${CMAKE_SOURCE_DIR}/dist/plugins_Windows.cfg DESTINATION . RENAME plugins.cfg)
install(FILES ${CMAKE_SOURCE_DIR}/dist/resources2.cfg DESTINATION .)
endif ()


# CPack
# -----------------------
set(CPACK_PACKAGE_NAME "Stunt Rally")
set(CPACK_PACKAGE_FILE_NAME "stunt-rally-${CMAKE_PROJECT_VERSION}")
set(CPACK_PACKAGE_DESCRIPTION "Stunt Rally is a 3D racing game with own Track Editor")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Stunt Rally is a 3D racing game with own Track Editor")
set(CPACK_PACKAGE_VENDOR "Crystal Hammer")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/dist/license.rtf")
set(CPACK_PACKAGE_EXECUTABLES "StuntRally3" "Stunt Rally 3")

if (WIN32)
set(CPACK_GENERATOR INNOSETUP)
set(CPACK_ADD_REMOVE TRUE)
set(CPACK_CREATE_DESKTOP_LINKS "StuntRally3" "Stunt Rally 3")

set(CPACK_INNOSETUP_ALLOW_CUSTOM_DIRECTORY ON)
set(CPACK_INNOSETUP_USE_MODERN_WIZARD ON)
# set(CPACK_INNOSETUP_ICON_FILE "${CMAKE_CURRENT_SOURCE_DIR}/sr3.ico")
set(CPACK_INNOSETUP_SETUP_AppId "{{67B750C8-691F-4AAB-A79C-7557314B24A4}")

set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}")
# set(CPACK_INNOSETUP_SETUP_DiskSpanning True)
else ()
set(CPACK_GENERATOR 7Z)
endif ()

include(CPack)


feature_summary(WHAT ALL)
4 changes: 2 additions & 2 deletions bin/Release/plugins_Windows.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
PluginFolder=.

# Define plugins
#PluginOptional=RenderSystem_Direct3D11
PluginOptional=RenderSystem_GL3Plus
PluginOptional=RenderSystem_Direct3D11
PluginOptional=RenderSystem_Vulkan
PluginOptional=Plugin_ParticleFX
35 changes: 24 additions & 11 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMakeDeps
from conan.tools.files import copy
from conan.tools.files import save, copy


class StuntRally3(ConanFile):
Expand All @@ -19,7 +19,7 @@ def layout(self):
def requirements(self):
self.requires("boost/1.83.0")
self.requires("ogre3d-next/2024.01@anotherfoxguy/stable", force=True)
self.requires("bullet3/3.25@anotherfoxguy/patched")
self.requires("bullet3/3.25@anotherfoxguy/patched")
self.requires("sdl/2.28.5")
self.requires("mygui-next/2024.01@anotherfoxguy/stable")
self.requires("ogg/1.3.5")
Expand All @@ -43,13 +43,26 @@ def generate(self):
deps.configuration = "RelWithDebInfo"
deps.generate()

bindirs = []
for dep in self.dependencies.values():
for f in dep.cpp_info.bindirs:
self.cp_data(f)
for f in dep.cpp_info.libdirs:
self.cp_data(f)

def cp_data(self, src):
bindir = os.path.join(self.build_folder, "bin")
copy(self, "*.dll", src, bindir, False)
copy(self, "*.so*", src, bindir, False)
bindirs += dep.cpp_info.bindirs

bindirs_win = []
for dir in bindirs:
bindirs_win.append(os.path.join(dir, f"{self.settings.build_type}"))

conan_data = 'set(CONAN_BIN_DIRS "%s;%s")\n' % (
";".join(bindirs).replace("\\", "/"),
";".join(bindirs_win).replace("\\", "/"),
)

save(
self,
os.path.join(self.build_folder, "cmake", "ConanBinDirs.cmake"),
conan_data,
)

if self.settings.os == "Windows":
libdir = os.path.join(self.source_folder, "bin", f"{self.settings.build_type}")
for f in self.dependencies["ogre3d-next"].cpp_info.bindirs:
copy(self, "*.dll", f, libdir, False)
158 changes: 0 additions & 158 deletions dist/installer.nsi

This file was deleted.

Loading

0 comments on commit ec05da3

Please sign in to comment.