Skip to content

Build VMC from source

The repository provides build scripts for Linux/macOS shells and Windows PowerShell. This page uses the shell scripts and must be followed from the VMC repository root, where CMakeLists.txt and config.cfg are located.

The build configuration requires:

  • CMake 3.24 or newer. CMakeLists.txt enforces 3.24, even though the current README says 3.20.
  • A compiler with C++23 support.
  • Git when configuring the test build for the first time, because CMake fetches Catch2 from GitHub.
  • A CUDA compiler and toolkit only for a CUDA build.

OpenMP is optional. When CMake finds it, the project uses it for SIMD pragmas; otherwise CMake checks for the compiler’s -fopenmp-simd support.

From the repository root, run:

Terminal window
./scripts/build.sh

The script selects a Release, double-precision, CPU-only build and writes the executable to build/vmc.

The command was run in the documentation workspace. This is its complete output:

-- The CXX compiler identification is GNU 13.3.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- OpenMP found (CXX 4.5); using it for '#pragma omp simd'.
-- Configuring done (2.2s)
-- Generating done (0.0s)
-- Build files have been written to: /home/member/docs/Variational-Monte-Carlo/build
[ 5%] Building CXX object CMakeFiles/vmc_lib.dir/src/blocking_analysis/blocking_analysis.cpp.o
...
[ 88%] Linking CXX static library libvmc_lib.a
[ 88%] Built target vmc_lib
[ 94%] Building CXX object CMakeFiles/vmc.dir/src/main.cpp.o
[100%] Linking CXX executable vmc
[100%] Built target vmc

build.sh accepts one positional build type plus three flags:

CommandResult
./scripts/build.shCPU, Release, FP64; produces build/vmc
./scripts/build.sh DebugCPU, Debug, FP64; produces build/vmc
./scripts/build.sh --fp32CPU, Release, FP32; produces build/vmc
./scripts/build.sh --vmc-fast-mathCPU, Release, FP32 with the project’s fast-math option enabled
./scripts/build.sh --cudaCUDA, Release, FP64; produces build-cuda/vmc
./scripts/build.sh --cuda --fp32CUDA, Release, FP32; produces build-cuda/vmc

--vmc-fast-math forces FP32 even if FP64 would otherwise be selected. The shell script explicitly disables CUDA unless --cuda is present.

The default script is equivalent to configuring the important project options and then building the vmc target:

Terminal window
cmake -S . -B build \
-DVMC_ENABLE_CUDA=OFF \
-DFP_64=ON \
-DVMC_FAST_MATH=OFF \
-DBUILD_TESTING=OFF \
-DCMAKE_BUILD_TYPE=Release
cmake --build build --target vmc

Use the scripts unless another tool needs a custom CMake build directory or generator. Continue with Test VMC before running a production calculation.

The behavior documented here comes from CMakeLists.txt, scripts/build.sh, and the observed ./scripts/build.sh run.