GLFW-Skia C++ Template - build the sample project
Introduction
This project uses CMake (the CMakeLists.txt file) to configuring the build process for both Windows and Linux while using the same project source location, the WSL will use the mount to compile and build the Linux version on the Windows disk.
Build Sample project for Windows
This section describes the methods to build the sample template project under Windows. There are 3 method to choice from, building With Visual Studio 2022/2026, Building by using a script and building by using Visual Studio code. They will all be described here.
Get the Visual Studio Runtime variables
This stack supports Visual Studio 2022 and Visual Studio 2026. We need a reference to the batch file to add to our build system. Depending on which batch file is chosen, the system will build under VS-2022 or VS-2026. The procedure below will discover the version(s) you have installed and ensure that the environment variables are added to the CMake system:
- To find the location of this batch file, you can use the following PowerShell command:
& "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" ` -products * ` -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 ` -find **\VC\Auxiliary\Build\vcvars64.bat - Add the path to vcvars64.bat to the file: ${PROJECT_SOURCE_DIR}/cmake/CMakeLists_Init-env.bat
Build using Visual Studio (any edition)
This section describes building with Visual Studio 2022/2026 (including the Community Edition) It configures the build environment for Microsoft’s own make utility: NMake and uses the CMakePresets.json to read the configuration.
- In a Power-Shell CLI open the root folder of the project.
- In the root folder execute theses commands once:
-
cmd /c "call cmake\CMakeLists_Init-env.bat nul && cmake --preset=windows-nmake-debug"
-
cmd /c "call cmake\CMakeLists_Init-env.bat nul && cmake --preset=windows-nmake-release"
-
This will create the dedicated output folders:
- build-win-vs\debug
- build-win-vs\release
- Warning: Make sure to copy the glfw3.dll to these folder ( using none static library)
3. Open VS 2022 or VS 2026. And use the command File ➜ Open ➜ Folder option to open the project root folder (this creates a .vs folder in the root)
4. At the top of Visual Studio, locate the Startup Item drop-down near the “Start” (▶️) button
5. Select glfw_sample_[].exe this will set it as startup projects
6. In the build combo-box you should have the options:
- PRJ-build(Debug)
- PRJ-build(Release)
7. Use the normal Visual Studio method to debug and run the program
8. The output from Visual Studio can be found in the sub folder: ./build-win-vs
Build using Terminal (NMake)
- Open the root folder in a Power-Shell terminal
- Run the command: ./build.ps1
- Note: you can switch the Debug and release build in the ./build.ps1 script at the top
- The output from Visual Studio can be found in the sub folder: ./build-win
The build.ps1 script will:
- Setup the Visual Studio build environment variables.
- Run the CMake command to configure the makefile for NMake: sh cmake .. -G “NMake Makefiles”
- Runs the NMake command to build the project based on the above generated makefile.
Build using Visual Studio Code
To Build/develop in Visual Studio Code:
- Open the root folder of the project in Visual Studio Code
- Then use: Terminal -> Run Build Tasks… and choose Build Windows App. This will use the same script as described in the “Using Terminal (NMake)” section
- The output can be found in the sub folder: ./build-win
- You may need to adjust the ./.vscode/launch.json file to ensure it points to the correct executable
Build for Linux (NEEDS check, Next)
This section describes building the program using the GNU Make tool. It assumes that the source code is located under a Windows mount point (typically /mnt/c or /mnt/d). While this approach is slower for Linux compilation (2 to 5 times), it works fine for small projects. For large projects, you may consider syncing the mounted folder to the Linux filesystem first.
- From the project folder (
/mnt/d/myproject) execute:./build.sh
That’s all! You can also use Visual Studio Code and build it as described above in the Visual Studio Code section.
<div class=”nje-br1> </div>
License
This file is part of: GLFW-Skia C++ Template Stack Copyright (c) 2025-2026 Nico Jan Eelhart.This repository is MIT licensed and free to use. For optional commercial support, customization, training, or long-term maintenance, see COMMERCIAL.md.
─── ✦ ───