From 977f66d29bbadf4eb67af34323b83669e940d174 Mon Sep 17 00:00:00 2001 From: miyanyan <1138989048@qq.com> Date: Fri, 25 Jul 2025 12:46:53 +0800 Subject: [PATCH 1/2] set CMAKE_TOOLCHAIN_FILE for vcpkg --- .gitignore | 1 + CMakeLists.txt | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/.gitignore b/.gitignore index 2d34b3d..31194bb 100644 --- a/.gitignore +++ b/.gitignore @@ -34,6 +34,7 @@ # Build directories build* !buildtools +.cache # Emacs auto-save files *~ diff --git a/CMakeLists.txt b/CMakeLists.txt index 7da0582..82cbce6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,11 @@ cmake_minimum_required(VERSION 3.14) + +# --- vcpkg +if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE) + message(STATUS "VCPKG_ROOT: $ENV{VCPKG_ROOT}") + set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "") +endif() + project(mathplot) # Note that the project version is encoded in mplot/version.h and not in this CMakeLists.txt From 00dd72314fb3fb5669640e500107bf731886a033 Mon Sep 17 00:00:00 2001 From: miyanyan <1138989048@qq.com> Date: Fri, 25 Jul 2025 12:47:07 +0800 Subject: [PATCH 2/2] Update README.build.windows.md --- README.build.windows.md | 55 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 4 deletions(-) diff --git a/README.build.windows.md b/README.build.windows.md index 088b1c4..6e327db 100644 --- a/README.build.windows.md +++ b/README.build.windows.md @@ -1,10 +1,57 @@ -# Building with Visual Studio +# Building with Visual Studio/VSCode -It is possible to build the examples and test programs using Visual Studio. +It is possible to build the examples and test programs using Visual Studio/VSCode. -You first have to install vcpkg. +## *Required*: Install dependencies -You open the cmake folder from Visual Studio, and make use of [vcpkg](https://github.com/microsoft/vcpkg) to get dependencies in place. There is a vcpkg.json file in the repository at [vcpkg/vcpkg.json](https://github.com/sebsjames/mathplot/blob/main/vcpkg/vcpkg.json). +### Install vcpkg +vcpkg is a package manager for C++ libraries. It can be used to download and install the required dependencies for the examples and test programs. + +To install vcpkg, follow the instructions at [vcpkg](https://github.com/microsoft/vcpkg). + +After vcpkg is installed, you need to set the environment variable `VCPKG_ROOT` to the path where vcpkg is installed, then set the `CMAKE_TOOLCHAIN_FILE` variable to the path of the vcpkg toolchain file. + +In Visual Studio, you can follow [Customize CMake build settings](https://learn.microsoft.com/en-us/cpp/build/customize-cmake-settings?view=msvc-170) to set `CMAKE_TOOLCHAIN_FILE`. + +In VSCode, you can set these variables in the `settings.json`: +```json +{ + "cmake.configureSettings": { + "CMAKE_TOOLCHAIN_FILE": "${env:VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" + }, +} +``` + +### Install dependencies with vcpkg + +#### Mainfest mode(recommended) + +When `vcpkg.json` is in the root directory of the project, vcpkg will automatically install the required dependencies when you run the CMake configuration step. + +#### Classic mode + +To install the required dependencies, run the following command in the terminal: + +``` +vcpkg install armadillo freetype glfw3 hdf5 nlohmann-json opengl rapidxml +``` + +### Install Qt5 + +To use Qt, you need to install the Qt SDK using the [official installer](https://download.qt.io/official_releases/online_installers/). + +Then add the Qt bin directory to the system PATH environment variable, and set the environment variable `QT5_DIR` to the Qt installation directory. + +### Build the examples and test programs + +You can build the examples and test programs using the Visual Studio/VSCode(with cmake plugins). + +Or you can build in terminal: + +``` cmake +cmake -B build +cmake --build build --config Release +``` # Building on Windows Subsystem for Linux