google / google/benchmark

Build Error w/ msvc-141 while targeting Universal Windows Platform

Open
#661 5 comments 0 reactions 0 assignees View on GitHub
enhancement help wanted os:windows
Dominant language
C++
Stars
10.4k
Forks
1.8k
Avg merge
2d 4h
Merged PRs (30d)
8

Description

### Summary
While attempting to build google/benchmark with cmake for a Windows UWP (Universal Windows Platform) target the following errors can be observed.

![error](https://user-images.githubusercontent.com/42657589/44603055-1ba56000-a7a7-11e8-942d-d8af25c96b90.PNG)

These symbols are disabled/undefined by `VersionHelper.h:18 -- #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)`
Yet required in the `sysinfo.cc:526 -- #elif defined BENCHMARK_OS_WINDOWS` block.

### Steps to reproduce

The above can be reproduced (so long as you have VS2017 or can compile with the MSVC v141 toolchain) with the following steps:

```bash
$ git clone https://github.com/google/benchmark.git
$ cd benchmark
$ mkdir -p build && cd build
$ cmake -G "Visual Studio 15" -DBENCHMARK_ENABLE_GTEST_TESTS=OFF -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0 ..

```
*Note: the CMAKE_SYSTEM_NAME/VERSION settings drive the cmake config step for UWP apps*

Then open the .sln in build/ and run a build.

### Fix

* The issue:
![bug](https://user-images.githubusercontent.com/42657589/44603059-24963180-a7a7-11e8-852b-4d4c2df84a75.PNG)

* The fix:
![fix](https://user-images.githubusercontent.com/42657589/44603078-3546a780-a7a7-11e8-8205-976d7109197a.PNG)

### Alternative

The frequency estimation in the block in question is sampling/inferring the MHz of the system (presumably for performance measures). As this particular block is platform(Windows Specific) wouldn't usage of the [`QueryPerformanceFreq()` API (windows.h)](https://msdn.microsoft.com/en-us/library/windows/desktop/ms644905(v=vs.85).aspx) be more appropriate/accurate ?

Happy to try and submit a PR for this if our thinking on this is correct and acceptable.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.