Skip to content

Commit

Permalink
Add documentation describing use of vcpkg, add comments indicating sp…
Browse files Browse the repository at this point in the history
…ecial case logic in CMake setup
  • Loading branch information
SamVanheer committed Feb 14, 2024
1 parent 5fe9cf0 commit fc2487d
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 18 deletions.
2 changes: 1 addition & 1 deletion BUILDING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Building this SDK

This tutorial expects a strong grasp of of C++, build systems like Visual Studio or Make (depending on the platform you're developing for), CMake, command line interfaces and version control systems (Git in particular).
This tutorial expects a strong grasp of of C++, build systems like Visual Studio or Make (depending on the platform you're developing for), CMake, command line interfaces, version control systems (Git in particular) and package managers (vcpkg in particular).

All instructions for Linux development are written to apply to Ubuntu. Substitute commands and actions as needed for your distribution. It is expected that you understand how to work with the Linux terminal and command line.

Expand Down
13 changes: 12 additions & 1 deletion DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,29 @@

## Prerequisite knowledge

You will need a strong grasp of of C++, build systems like Visual Studio or Make (depending on the platform you're developing for), CMake, command line interfaces and version control systems (Git in particular) to make a mod with this SDK.
You will need a strong grasp of of C++, build systems like Visual Studio or Make (depending on the platform you're developing for), CMake, command line interfaces, version control systems (Git in particular) and package managers (vcpkg in particular).

Various configuration files use JSON so an understanding of its syntax is recommended.

Tools and scripts are written in C# so you will need to have an understanding of its syntax to modify them.

This project uses vcpkg in manifest mode to acquire most third party dependencies, with the exception of dependencies shipped with the game itself (vgui1 and SDL2). You should use vcpkg to add any dependencies you need. If a dependency is not provided by vcpkg's own registry you can add it to the local filesystem registry in `vcpkg-configuration.json`.

Note that the OpenAL library is a custom build that renames the dynamic library name to avoid conflicting with the engine's use of OpenAL on Linux. If you update OpenAL you must also update the patch used to rename the library.

Also note that Github Actions performs a shallow clone of the vcpkg repository. When updating vcpkg make sure all dependencies are using the latest version, otherwise Github Actions will fail to locate the package information.

You can use the local registry to reference an older version by copying the older version package definition from the vcpkg registry to the local registry, but do make note of transitive dependencies to avoid using multiple conflicting versions of the same package (e.g. `spdlog` references `fmtlib` which this project also directly references).

Consult the vcpkg documentation before changing anything to ensure you understand how it works and how your changes will affect the project.

Resources to learn these things:
* [Command line](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/windows-commands)
* [CMake](https://cliutils.gitlab.io/modern-cmake/)
* [C++](https://www.learncpp.com/)
* [C#](https://learn.microsoft.com/en-us/dotnet/csharp/)
* [JSON](https://www.w3schools.com/js/js_json_syntax.asp)
* [vcpkg](https://vcpkg.io/en/getting-started)

> **Make sure to learn these things first so you understand how this SDK works!**
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The [Half-Life Unified SDK](docs/README.md#developer-resources) is a project tha
The SDK provides a CMake-based project structure with support for Visual Studio 2019 and 2022 on Windows and GCC 11 on Linux, as well as many bug fixes and improvements.
Opposing Force and Blue Shift features have been integrated with code refactored to reduce the amount of code duplication.

**You will need a strong grasp of of C++, build systems like Visual Studio or Make (depending on the platform you're developing for), CMake, command line interfaces and version control systems (Git in particular) to make a mod with this SDK. If you do not have experience with these technologies then you will have a very hard time getting started.**
**You will need a strong grasp of of C++, build systems like Visual Studio or Make (depending on the platform you're developing for), CMake, command line interfaces, version control systems (Git in particular) and package managers (vcpkg in particular) to make a mod with this SDK. If you do not have experience with these technologies then you will have a very hard time getting started.**

The goal of the Unified SDK is to allow modders to make mods based on these games, while providing bug fixes that could be applied to the official games as well in addition to bug fixes that would be a breaking change. Check out the documentation linked below for a list of features.

Expand Down
34 changes: 19 additions & 15 deletions src/game/client/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
include(../shared/game_shared.cmake)

if (UNIX)
# Copy libraries provided by the game to the build directory so we can point the compiler and linker to the files.
configure_file(../../../utils/vgui/lib/linux/vgui${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_CURRENT_BINARY_DIR}/vgui${CMAKE_SHARED_LIBRARY_SUFFIX} COPYONLY)
configure_file(../../../external/SDL2/lib/libSDL2-2.0${CMAKE_SHARED_LIBRARY_SUFFIX}.0 ${CMAKE_CURRENT_BINARY_DIR}/libSDL2-2.0${CMAKE_SHARED_LIBRARY_SUFFIX}.0 COPYONLY)
endif()

find_package(OpenGL REQUIRED)

add_library(vgui SHARED IMPORTED)
# Begin special case stuff for dynamic libraries included with the game
# vgui and SDL2 are dynamic libraries that are load-time linked by the client
# For Windows this requires us to link with the import libraries
# For Linux this requires the .so files to be located next to the client
# so that the path embedded in the resulting client.so is a filename without any path component to it,
# so that when the library is loaded its path is resolved relative to the executable (hl_linux)
# The actual .so files are next to hl_linux so that's where the paths must point to.
# This is how it was done in the original Linux makefiles as well
# DO NOT DO THIS FOR ANY OTHER LIBRARIES YOU USE! If you must ship a dynamic library you should use the same approach used for OpenAL.

if (WIN32)
set_target_properties(vgui PROPERTIES IMPORTED_IMPLIB "${CMAKE_CURRENT_SOURCE_DIR}/../../../utils/vgui/lib/win32_vc6/vgui.lib")
else()
set_target_properties(vgui PROPERTIES IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/vgui${CMAKE_SHARED_LIBRARY_SUFFIX}")
endif()
add_library(vgui SHARED IMPORTED)
add_library(SDL2 SHARED IMPORTED)

target_include_directories(vgui INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/../../../utils/vgui/include)

add_library(SDL2 SHARED IMPORTED)
target_include_directories(SDL2 INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/../../../external/SDL2/include)

if (WIN32)
set_target_properties(vgui PROPERTIES IMPORTED_IMPLIB "${CMAKE_CURRENT_SOURCE_DIR}/../../../utils/vgui/lib/win32_vc6/vgui.lib")
set_target_properties(SDL2 PROPERTIES IMPORTED_IMPLIB "${CMAKE_CURRENT_SOURCE_DIR}/../../../external/SDL2/lib/SDL2.lib")
else()
# Copy libraries provided by the game to the build directory so we can point the compiler and linker to the files.
configure_file(../../../utils/vgui/lib/linux/vgui${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_CURRENT_BINARY_DIR}/vgui${CMAKE_SHARED_LIBRARY_SUFFIX} COPYONLY)
configure_file(../../../external/SDL2/lib/libSDL2-2.0${CMAKE_SHARED_LIBRARY_SUFFIX}.0 ${CMAKE_CURRENT_BINARY_DIR}/libSDL2-2.0${CMAKE_SHARED_LIBRARY_SUFFIX}.0 COPYONLY)

set_target_properties(vgui PROPERTIES IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/vgui${CMAKE_SHARED_LIBRARY_SUFFIX}")
set_target_properties(SDL2 PROPERTIES IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/libSDL2-2.0${CMAKE_SHARED_LIBRARY_SUFFIX}.0")
endif()

target_include_directories(SDL2 INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/../../../external/SDL2/include)
# End special case stuff for dynamic libraries included with the game

add_library(client SHARED)

Expand Down

0 comments on commit fc2487d

Please sign in to comment.