Skip to content

daniebker/cpprl

Repository files navigation

How to setup

  • Make sure you have the correct tools ready.
  • 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 the vcpkg folder is empty or missing then the build process will fail.
    • The command to do this is: git submodule update --init
  • 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.
  • 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.
  • 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 the vcpkg folder is empty or missing then the build process will fail.
    • The command to do this is: git submodule update --init
  • 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.
  • The project will now build and run with F5.

Building Web Locally

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.

Resources