Skip to content

Commit

Permalink
Enable separate building of TFE and the “AdjustableHud” mod:
Browse files Browse the repository at this point in the history
* `CMakeLists.txt`: Add `ENABLE_TFE` and `ENABLE_ADJUSTABLEHOD_MOD`
   configuration options to for package maintainers to be able to build separate
   packages
* Add AppStream component meta data for the built‑in “AdjustableHud” mod
* `README.md`: Add info on packaging TFE to
* `ProjectStructure.md`: Add `Mods` directory and description
  • Loading branch information
JakeSmarter committed Mar 11, 2024
1 parent 065897c commit 526c9a1
Show file tree
Hide file tree
Showing 5 changed files with 209 additions and 96 deletions.
215 changes: 119 additions & 96 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,116 +46,139 @@ endif()
include(GNUInstallDirs)

## Options
option(ENABLE_TFE "Enable building “The Force Engine”" ON)
option(DISABLE_SYSMIDI "Disable System-MIDI Output" OFF)
option(ENABLE_EDITOR "Enable TFE Editor" OFF)
option(ENABLE_FORCE_SCRIPT "Enable Force Script" OFF)

add_executable(tfe)
set_target_properties(tfe PROPERTIES OUTPUT_NAME "theforceengine")

if(LINUX)
find_package(PkgConfig REQUIRED)
find_package(Threads REQUIRED)
find_package(SDL2 2.0.20 REQUIRED)
pkg_check_modules(SDL2_IMAGE REQUIRED SDL2_image)
pkg_check_modules(GLEW REQUIRED glew)
set(OpenGL_GL_PREFERENCE GLVND)
find_package(OpenGL REQUIRED)
target_include_directories(tfe PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(tfe PRIVATE ${SDL2_INCLUDE_DIRS})
target_include_directories(tfe PRIVATE ${SDL2_IMAGE_INCLUDE_DIRS})
target_link_libraries(tfe PRIVATE
${OPENGL_LIBRARIES}
${GLEW_LIBRARIES}
${SDL2_LIBRARIES}
${SDL2_IMAGE_LIBRARIES}
)

if(NOT DISABLE_SYSMIDI)
pkg_check_modules(RTMIDI REQUIRED rtmidi>=5.0.0)
target_link_libraries(tfe PRIVATE ${RTMIDI_LIBRARIES})
option(ENABLE_ADJUSTABLEHUD_MOD "Install the build‑in “AdjustableHud mod” with TFE" ON)

if(ENABLE_TFE)
add_executable(tfe)
set_target_properties(tfe PROPERTIES OUTPUT_NAME "theforceengine")

if(LINUX)
find_package(PkgConfig REQUIRED)
find_package(Threads REQUIRED)
find_package(SDL2 2.0.20 REQUIRED)
pkg_check_modules(SDL2_IMAGE REQUIRED SDL2_image)
pkg_check_modules(GLEW REQUIRED glew)
set(OpenGL_GL_PREFERENCE GLVND)
find_package(OpenGL REQUIRED)
target_include_directories(tfe PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(tfe PRIVATE ${SDL2_INCLUDE_DIRS})
target_include_directories(tfe PRIVATE ${SDL2_IMAGE_INCLUDE_DIRS})
target_link_libraries(tfe PRIVATE
${OPENGL_LIBRARIES}
${GLEW_LIBRARIES}
${SDL2_LIBRARIES}
${SDL2_IMAGE_LIBRARIES}
)

if(NOT DISABLE_SYSMIDI)
pkg_check_modules(RTMIDI REQUIRED rtmidi>=5.0.0)
target_link_libraries(tfe PRIVATE ${RTMIDI_LIBRARIES})
endif()

# set up build directory to be able to run TFE immediately: symlink
# the necessary support file directories into the build env.
execute_process(COMMAND ln -sf ${CMAKE_SOURCE_DIR}/TheForceEngine/Captions)
execute_process(COMMAND ln -sf ${CMAKE_SOURCE_DIR}/TheForceEngine/Documentation)
execute_process(COMMAND ln -sf ${CMAKE_SOURCE_DIR}/TheForceEngine/Fonts)
execute_process(COMMAND ln -sf ${CMAKE_SOURCE_DIR}/TheForceEngine/Mods)
execute_process(COMMAND ln -sf ${CMAKE_SOURCE_DIR}/TheForceEngine/Shaders)
execute_process(COMMAND ln -sf ${CMAKE_SOURCE_DIR}/TheForceEngine/SoundFonts)
execute_process(COMMAND ln -sf ${CMAKE_SOURCE_DIR}/TheForceEngine/UI_Images)
execute_process(COMMAND ln -sf ${CMAKE_SOURCE_DIR}/TheForceEngine/UI_Text)
execute_process(COMMAND ln -sf ${CMAKE_SOURCE_DIR}/TheForceEngine/EditorDef)
include(CreateGitVersionH.cmake)
create_git_version_h()
endif()

# set up build directory to be able to run TFE immediately: symlink
# the necessary support file directories into the build env.
execute_process(COMMAND ln -sf ${CMAKE_SOURCE_DIR}/TheForceEngine/Captions)
execute_process(COMMAND ln -sf ${CMAKE_SOURCE_DIR}/TheForceEngine/Documentation)
execute_process(COMMAND ln -sf ${CMAKE_SOURCE_DIR}/TheForceEngine/Fonts)
execute_process(COMMAND ln -sf ${CMAKE_SOURCE_DIR}/TheForceEngine/Mods)
execute_process(COMMAND ln -sf ${CMAKE_SOURCE_DIR}/TheForceEngine/Shaders)
execute_process(COMMAND ln -sf ${CMAKE_SOURCE_DIR}/TheForceEngine/SoundFonts)
execute_process(COMMAND ln -sf ${CMAKE_SOURCE_DIR}/TheForceEngine/UI_Images)
execute_process(COMMAND ln -sf ${CMAKE_SOURCE_DIR}/TheForceEngine/UI_Text)
execute_process(COMMAND ln -sf ${CMAKE_SOURCE_DIR}/TheForceEngine/EditorDef)
include(CreateGitVersionH.cmake)
create_git_version_h()
endif()
if(COMPILER_ENABLE_AUTOZERO)
message(STATUS "enabled -ftrivial-auto-var-init=zero")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftrivial-auto-var-init=zero")
endif()

if(COMPILER_ENABLE_AUTOZERO)
message(STATUS "enabled -ftrivial-auto-var-init=zero")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftrivial-auto-var-init=zero")
endif()
if(DISABLE_SYSMIDI)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNOSYSMIDI")
endif()
if(ENABLE_EDITOR)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBUILD_EDITOR")
endif()
if(ENABLE_FORCE_SCRIPT)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBUILD_FORCE_SCRIPT")
endif()

if(DISABLE_SYSMIDI)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNOSYSMIDI")
endif()
if(ENABLE_EDITOR)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBUILD_EDITOR")
endif()
if(ENABLE_FORCE_SCRIPT)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBUILD_FORCE_SCRIPT")
endif()

if(ENABLE_FORCE_SCRIPT)
target_include_directories(tfe PRIVATE "TheForceEngine/TFE_ForceScript/Angelscript/angelscript/include")
target_include_directories(tfe PRIVATE "TheForceEngine/TFE_ForceScript/Angelscript/add_on")
endif()
target_include_directories(tfe PRIVATE TheForceEngine)

if(ENABLE_FORCE_SCRIPT)
target_include_directories(tfe PRIVATE "TheForceEngine/TFE_ForceScript/Angelscript/angelscript/include")
target_include_directories(tfe PRIVATE "TheForceEngine/TFE_ForceScript/Angelscript/add_on")
add_subdirectory(TheForceEngine/)
endif()
target_include_directories(tfe PRIVATE TheForceEngine)


add_subdirectory(TheForceEngine/)


### installation ###

# Main binary
install(TARGETS tfe
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
BUNDLE DESTINATION "${CMAKE_INSTALL_BINDIR}"
)

# Support data
install(DIRECTORY
"${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/Captions"
"${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/Documentation"
"${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/UI_Text"
"${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/UI_Images"
"${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/EditorDef"
"${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/Shaders"
"${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/SoundFonts"
"${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/Fonts"
"${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/Mods"
DESTINATION "${CMAKE_INSTALL_DATADIR}"
FILE_PERMISSIONS
OWNER_READ OWNER_WRITE
GROUP_READ
WORLD_READ
DIRECTORY_PERMISSIONS
OWNER_READ OWNER_EXECUTE OWNER_WRITE
GROUP_READ GROUP_EXECUTE GROUP_WRITE
WORLD_READ WORLD_EXECUTE
)

# Linux .desktop files
if(LINUX)
install(
FILES "${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/io.github.theforceengine.tfe.desktop" DESTINATION "share/applications"
if(ENABLE_TFE)
# Main binary
install(TARGETS tfe
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
BUNDLE DESTINATION "${CMAKE_INSTALL_BINDIR}"
)
install(
FILES "${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/io.github.theforceengine.tfe.png" DESTINATION "${TFE_ICONDIR}/256x256/apps"

# Support data
install(DIRECTORY
"${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/Captions"
"${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/Documentation"
"${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/UI_Text"
"${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/UI_Images"
"${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/EditorDef"
"${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/Shaders"
"${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/SoundFonts"
"${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/Fonts"
DESTINATION "${CMAKE_INSTALL_DATADIR}"
FILE_PERMISSIONS
OWNER_READ OWNER_WRITE
GROUP_READ
WORLD_READ
DIRECTORY_PERMISSIONS
OWNER_READ OWNER_EXECUTE OWNER_WRITE
GROUP_READ GROUP_EXECUTE GROUP_WRITE
WORLD_READ WORLD_EXECUTE
)
install(
FILES "${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/io.github.theforceengine.tfe.metainfo.xml" DESTINATION "share/metainfo"
# Always install the “Mods” directory but not always the “AdjustableHud” mod
install(DIRECTORY
DESTINATION "${CMAKE_INSTALL_DATADIR}/TheForceEngine/Mods"
DIRECTORY_PERMISSIONS
OWNER_READ OWNER_EXECUTE OWNER_WRITE
GROUP_READ GROUP_EXECUTE GROUP_WRITE
WORLD_READ WORLD_EXECUTE
)

# Linux .desktop files
if(LINUX)
install(
FILES "${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/io.github.theforceengine.tfe.desktop" DESTINATION "share/applications"
)
install(
FILES "${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/io.github.theforceengine.tfe.png" DESTINATION "${TFE_ICONDIR}/256x256/apps"
)
install(
FILES "${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/io.github.theforceengine.tfe.metainfo.xml"
DESTINATION "share/metainfo"
)
endif()
endif()

if(ENABLE_ADJUSTABLEHUD_MOD)
add_subdirectory(TheForceEngine/Mods/TFE/AdjustableHud)

if(LINUX)
install(
FILES "${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/io.github.theforceengine.tfe.Mod.AdjustableHud.metainfo.xml"
DESTINATION "share/metainfo"
)
endif()
endif()
3 changes: 3 additions & 0 deletions ProjectStructure.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,6 @@ The core system module, this covers the logging system, thread management, non-g

### TFE_UI
The low-level UI system used by TFE for the System UI. This is built on top of imGUI, which is also included. This adds extra support such as markdown and file dialogs.

### Mods
The directory where mods go. Each mod must be placed in a separate sub‑directory.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,11 @@ __sudo make install__

##### Launch
* Start the Engine by clicking on the __"The Force Engine"__ Desktop icon or by running __"theforceengine"__ in a shell.

## Packaging
TFE comes with the build‑in “[AdjustableHud](TheForceEngine/Mods/TFE/AdjustableHud)” mod. Package maintainers may wish and are encouraged to package “AdjustableHud” into a separate *required* or *recommended* package.

By default TFE builds and installs with the “AdjustableHud” mod. If you do not want to install the “AdjustableHud” mod, for example when building separate packages, configure the CMake build with the `-DENABLE_ADJUSTABLEHUD_MOD=OFF` option. If you want to install the “AdjustableHud” mod only use the `-DENABLE_TFE=OFF` option.

### Freedesktop
On freedesktop compliant systems package maintainers are encouraged to use the provided [AppStream meta data file](TheForceEngine/io.github.theforceengine.tfe.Mod.AdjustableHud.metadata.xml) when packing the “AdjustableHud” mod into a separate package.
41 changes: 41 additions & 0 deletions TheForceEngine/Mods/TFE/AdjustableHud/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
project(
AdjustableHud
HOMEPAGE_URL "https://theforceengine.github.io"
DESCRIPTION "“The Force Engine’s” built‑in “AdjustableHud” mod"
)

add_custom_target(
${PROJECT_NAME}
""
SOURCES
AdjustableHud.txt
Credits.txt
HudStatusLeftAddon.bm
HudStatusLeftAddon.png
HudStatusRightAddon.bm
HudStatusRightAddon.png
BYPRODUCTS
"${CMAKE_INSTALL_DATADIR}/Mods/TFE/${PROJECT_NAME}/AdjustableHud.txt"
"${CMAKE_INSTALL_DATADIR}/Mods/TFE/${PROJECT_NAME}/Credits.txt"
"${CMAKE_INSTALL_DATADIR}/Mods/TFE/${PROJECT_NAME}/HudStatusLeftAddon.bm"
"${CMAKE_INSTALL_DATADIR}/Mods/TFE/${PROJECT_NAME}/HudStatusLeftAddon.png"
"${CMAKE_INSTALL_DATADIR}/Mods/TFE/${PROJECT_NAME}/HudStatusRightAddon.bm"
"${CMAKE_INSTALL_DATADIR}/Mods/TFE/${PROJECT_NAME}/HudStatusRightAddon.png"
)

install(
DIRECTORY
"${CMAKE_CURRENT_SOURCE_DIR}"
DESTINATION
"${CMAKE_INSTALL_DATADIR}/Mods/TFE"
FILE_PERMISSIONS
OWNER_READ OWNER_WRITE
GROUP_READ
WORLD_READ
DIRECTORY_PERMISSIONS
OWNER_READ OWNER_EXECUTE OWNER_WRITE
GROUP_READ GROUP_EXECUTE GROUP_WRITE
WORLD_READ WORLD_EXECUTE
PATTERN
CMakeLists.txt EXCLUDE
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="addon">
<id>io.github.theforceengine.tfe.Mod.AdjustableHud</id>
<name>The Force Engine Adjustable Hud Mod</name>
<name xml:lang="de">„The Force Engine“ Einstellbare Bildschirmanzeigen Modifikation</name>
<name xml:lang="pl">Modyfikacja „The Force Engine” ustawiania wskaźników</name>
<developer id="com.twitter.dzierzan23">
<name>Paweł “Dzierzan” Dzierżanowski</name>
<name xml:lang="de">Paweł „Dzierzan“ Dzierżanowski</name>
<name xml:lang="pl">Paweł „Dzierzan” Dzierżanowski</name>
<url type="homepage">https://twitter.com/Dzierzan23</url>
</developer>
<summary>A “The Force Engine” built&#x2011;in mod enabling adjustable floating HUD elements in “STAR WARS: Dark Forces”</summary>
<summary xml:lang="de">Eine in „The Force Engine“ eingebaute Mod, die einstellbar bewegliche Bildschirmanzeigen in „STAR WARS: Dark Forces“ ermöglicht</summary>
<summary xml:lang="pl">W „The Force Engine” wbudowana modyfikacja, umożliwiająca ustawianie unoszących się wskaźników w „STAR WARS: Dark Forces”</summary>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-2.0</project_license>
<extends>io.github.theforceengine.tfe</extends>
<url type="homepage">https://theforceengine.github.io</url>
<url type="bugtracker">https://github.com/luciusDXL/TheForceEngine/issues</url>
<url type="help">https://theforceengine.github.io/Documentation.html</url>
<url type="vcs-browser">https://github.com/luciusDXL/TheForceEngine/tree/master/TheForceEngine/Mods/TFE/AdjustableHud</url>
<description>
<p>A “The Force Engine” built&#x2011;in mod based on the work by Paweł “Dzierzan” Dzierżanowski. The purpose of the mod is to enable the floating HUD elements in “STAR WARS: Dark Forces” to be adjustable – specifically being able to move them away from the edges of the screen on widescreen displays.</p>
<p xml:lang="de">Eine auf der Arbeit von Paweł „Dzierzan“ Dzierżanowski basierende in „The Force Engine“ eingebaute Mod. Die Mod hat zum Zwecke die Einstellbarkeit von beweglichen Bildschirmanzeigen in “STAR WARS: Dark Forces” zu ermöglichen, insbesondere sie weg von den Rändern auf Breitbildschirmen zu bewegen.</p>
<p xml:lang="pl">Wbudowana w „The Force Engine” modyfikacja na podstawie pracy Pawła „Dzierzan” Dzierżanowskiego. Celem modyfikacji jest umożliwienie ustawienia unoszących się wskaźników w „STAR WARS: Dark Forces”, zwłaszcza móc je odsunąć od krawędzi ekranu na szerokich ekranach.</p>
</description>
<categories>
<category>Game</category>
<category>Shooter</category>
<category>ActionGame</category>
</categories>
<update_contact>https://theforceengine.github.io</update_contact>
<requires>
<id>io.github.theforceengine.tfe</id>
<internet>offline-only</internet>
</requires>
</component>

0 comments on commit 526c9a1

Please sign in to comment.