Skip to content

Instantly share code, notes, and snippets.

@FreeSlave
Last active July 9, 2022 19:01
Show Gist options
  • Save FreeSlave/a15ad1a64331967b5f046fe9fc989c0c to your computer and use it in GitHub Desktop.
Save FreeSlave/a15ad1a64331967b5f046fe9fc989c0c to your computer and use it in GitHub Desktop.

Prerequisites

Install and run Visual Studio Installer. The installer allows you to choose specific components. Select Desktop development with C++. You can untick everything you don't need in Installation details, but you must keep MSVC and C++ CMake tools for Windows ticked.

Building

Run Developer command prompt for VS via Windows Start menu. Inside the prompt navigate to the hlsdk directory, using cd command, e.g.

cd C:\Users\username\projects\hlsdk-xash3d

Сonfigure the project:

cmake -A Win32 -B build -DGOLDSOURCE_SUPPORT=ON -DCMAKE_INSTALL_PREFIX="dist"

Once you configure the project you don't need to call cmake anymore unless you modify CMakeLists.txt files or want to reconfigure the project with different parameters.

The next step is to compile the libraries:

msbuild -verbosity:normal /property:Configuration=Release build/INSTALL.vcxproj

hl.dll and client.dll will appear in the directory configured via CMAKE_INSTALL_PREFIX option (dist in this example).

If you have a mod and want to automatically install libraries to the mod directory, set GAMEDIR variable to the directory name and CMAKE_INSTALL_PREFIX to your Half-Life or Xash3D installation path:

cmake -A Win32 -B build -DGAMEDIR=mod -DGOLDSOURCE_SUPPORT=ON -DCMAKE_INSTALL_PREFIX="C:\Program Files (x86)\Steam\steamapps\common\Half-Life"

Then call msbuild as described above.

Choosing Visual Studio version

You can explicitly choose a Visual Studio version on the configuration step by specifying cmake generator:

cmake -G "Visual Studio 16 2019" -A Win32 -B build -DGOLDSOURCE_SUPPORT=ON -DCMAKE_INSTALL_PREFIX="dist"

Editing code in Visual Studio

After the configuration step, HLSDK-XASH3D.sln should appear in the build directory. You can open this solution in Visual Studio and continue developing there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment