Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
run: ctest -C ${{ matrix.build_type }} -VV

msvc:
name: ${{ matrix.os }}.${{ matrix.build_type }}.${{ matrix.lib }}.${{ matrix.msvc }}
name: ${{ matrix.os }}.${{ matrix.build_type }}.${{ matrix.lib }}.${{ matrix.crt }}.${{ matrix.msvc }}
runs-on: ${{ matrix.os }}
defaults:
run:
Expand All @@ -73,7 +73,18 @@ jobs:
lib:
- shared
- static
crt:
- MD
- MT
exclude:
# a DLL with its own static CRT can't safely share CRT objects with the exe
- lib: shared
crt: MT
include:
- crt: MD
runtime: 'MultiThreaded$<$<CONFIG:Debug>:Debug>DLL'
- crt: MT
runtime: 'MultiThreaded$<$<CONFIG:Debug>:Debug>'
- msvc: VS-18-2025
os: windows-2025
generator: 'Visual Studio 18 2026'
Expand All @@ -94,6 +105,7 @@ jobs:
-G "${{ matrix.generator }}"
-DBENCHMARK_DOWNLOAD_DEPENDENCIES=ON
-DBUILD_SHARED_LIBS=${{ matrix.lib == 'shared' }}
'-DCMAKE_MSVC_RUNTIME_LIBRARY=${{ matrix.runtime }}'
env:
RUNNER_WORKSPACE: ${{ runner.workspace }}

Expand Down
8 changes: 8 additions & 0 deletions docs/platform_specific_build_instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ The `shlwapi` library (`-lshlwapi`) is required to support a call to `CPUInfo` w

When using the static library, make sure to add `BENCHMARK_STATIC_DEFINE` under `[Configuration Properties > C/C++ > Preprocessor > Preprocessor Definitions]`

By default the library links against the DLL C runtime (`/MD`, `/MDd`). To use the static C runtime (`/MT`, `/MTd`) instead, set CMake's [`CMAKE_MSVC_RUNTIME_LIBRARY`](https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html) (CMake 3.15 or newer) when configuring. It applies to `benchmark`, `benchmark_main` and the downloaded GoogleTest alike:

```
cmake -S . -B build -DBENCHMARK_DOWNLOAD_DEPENDENCIES=ON -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$<CONFIG:Debug>:Debug>"
```

Combine it with the static library (`BUILD_SHARED_LIBS=OFF`), since a DLL with its own static C runtime can't safely share C runtime objects with the executable.

Can also use the graphical version of CMake:
* Open `CMake GUI`.
* Under `Where to build the binaries`, same path as source plus `build`.
Expand Down
Loading