- Make sure you have the correct tools ready.
- For example on Windows: Make sure you install the "Desktop development with C++" workload from the latest Visual Studio Community Installer, install the latest CMake, and install Visual Studio Code.
- Create a new repository from ths template. You do not use the GitHub fork button unless you're contributing.
- Clone your new repository.
- Make sure to initialize the
vcpkg
submodule. If thevcpkg
folder is empty or missing then the build process will fail.- The command to do this is:
git submodule update --init
- The command to do this is:
mkdir build
cd build
- Init the project from the terminal using
cmake ../
cd ../
- from the terminal run
cmake --build . --config Debug --target all -j 12 # to build the project
- Load this project in VS Code and install any recommended plugins. Most importantly: C/C++, C++ Intellisense, and CMake Tools.
- Using the CMake Tools plugin you can now build and run this project. Dependencies will automatically be installed via Vcpkg.
- On Windows, when CMake Tools asks for a toolkit you should select
Visual Studio Community ... - amd64
. - When CMake Tools asks for a project select
libtcod-vcpkg-template
.
- On Windows, when CMake Tools asks for a toolkit you should select
- The project will now build and run with F5.
Actions which pass without fail will provide archived executables to test with, these are temporary and are downloaded from the passing action under automated-builds.
You should edit the
CMakeLists.txt
script as needed to expand your project.
Now that you know the template works you'll want to take care the following:
- Make sure you have the correct tools ready.
- For example on Windows: You'll need to add these libraries to CMakeLists.txt to link them.
- Change
libtcod-vcpkg-template
in CMakeLists.txt and .github/workflows/cmake.yml to the name of your game. You may want to edit other parts of the CMake script as well, such as the included source files.
- Create a new repository from ths template. You do not use the GitHub fork button unless you're contributing.
- Clone your new repository.
- Make sure to initialize the
vcpkg
submodule. If thevcpkg
folder is empty or missing then the build process will fail.- The command to do this is:
git submodule update --init
- The command to do this is:
- Init the project from the terminal using
cmake . - Load this project in VS Code and install any recommended plugins. Most importantly: C/C++, C++ Intellisense, and CMake Tools.
- Using the CMake Tools plugin you can now build and run this project. Dependencies will automatically be installed via Vcpkg.
- On Windows, when CMake Tools asks for a toolkit you should select
Visual Studio Community ... - amd64
. - When CMake Tools asks for a project select
libtcod-vcpkg-template
.
- On Windows, when CMake Tools asks for a toolkit you should select
- The project will now build and run with F5.
Install emsdk
by following the official instructions
Generate the cmake build with the following command:
emcmake cmake -S . -B build_web -G Ninja \
-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE="${EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake" \
-DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake \
-DVCPKG_TARGET_TRIPLET=wasm32-emscripten \
-DCMAKE_BUILD_TYPE="production"
If the command fails with emcmake not found then you probably forgot to source the emsdk_end.sh
file.
Run cmake --build build_web
To launch a web server run npx serve ./build_web/bin
This will launch a server where you will be able to play the game.