具体可以参考:

如何安装文档中已经说的很清楚了:

这里,展示本系列使用的安装过程,感兴趣者可以举一反三,从中获得一些感性认识。

1、进入d盘只能装目录:

cd d:\work\google_work\

Windows PowerShell
版权所有(C) Microsoft Corporation。保留所有权利。

安装最新的 PowerShell,了解新功能和改进!https://aka.ms/PSWindows

PS C:\Users\eric> cd d:\work\google_work\
PS D:\work\google_work> git clone https://github.com/google/benchmark.git
Cloning into 'benchmark'...
remote: Enumerating objects: 7074, done.
remote: Counting objects: 100% (1566/1566), done.
remote: Compressing objects: 100% (263/263), done.
remote: Total 7074 (delta 1424), reused 1308 (delta 1302), pack-reused 5508
Receiving objects: 100% (7074/7074), 2.15 MiB | 3.20 MiB/s, done.
Resolving deltas: 100% (4754/4754), done.

3、ls

PS D:\work\google_work> ls


    目录: D:\work\google_work


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----          2022/4/3     19:21                benchmark

4、cd .\benchmark

PS D:\work\google_work> cd .\benchmark

5、ls

PS D:\work\google_work\benchmark> ls


    目录: D:\work\google_work\benchmark


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----          2022/4/3     19:21                .github
d-----          2022/4/3     19:21                bindings
d-----          2022/4/3     19:21                cmake
d-----          2022/4/3     19:21                config
d-----          2022/4/3     19:21                docs
d-----          2022/4/3     19:21                include
d-----          2022/4/3     19:21                src
d-----          2022/4/3     19:21                test
d-----          2022/4/3     19:21                tools
-a----          2022/4/3     19:21             79 .clang-format
-a----          2022/4/3     19:21            257 .clang-tidy
-a----          2022/4/3     19:21            830 .gitignore
-a----          2022/4/3     19:21           7059 .travis.yml
-a----          2022/4/3     19:21           3755 .ycm_extra_conf.py
-a----          2022/4/3     19:21           1316 appveyor.yml
-a----          2022/4/3     19:21           2437 AUTHORS
-a----          2022/4/3     19:21           1828 BUILD.bazel
-a----          2022/4/3     19:21          14124 CMakeLists.txt
-a----          2022/4/3     19:21           2543 CONTRIBUTING.md
-a----          2022/4/3     19:21           3661 CONTRIBUTORS
-a----          2022/4/3     19:21          13200 LICENSE
-a----          2022/4/3     19:21           7663 README.md
-a----          2022/4/3     19:21             48 requirements.txt
-a----          2022/4/3     19:21           5248 setup.py
-a----          2022/4/3     19:21           1471 WORKSPACE
-a----          2022/4/3     19:21             45 _config.yml

6、cmake -E make_directory "build"

PS D:\work\google_work\benchmark> cmake -E make_directory "build"

7、ls

PS D:\work\google_work\benchmark> ls


    目录: D:\work\google_work\benchmark


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----          2022/4/3     19:21                .github
d-----          2022/4/3     19:21                bindings
d-----          2022/4/3     19:39                build
d-----          2022/4/3     19:21                cmake
d-----          2022/4/3     19:21                config
d-----          2022/4/3     19:21                docs
d-----          2022/4/3     19:21                include
d-----          2022/4/3     19:21                src
d-----          2022/4/3     19:21                test
d-----          2022/4/3     19:21                tools
-a----          2022/4/3     19:21             79 .clang-format
-a----          2022/4/3     19:21            257 .clang-tidy
-a----          2022/4/3     19:21            830 .gitignore
-a----          2022/4/3     19:21           7059 .travis.yml
-a----          2022/4/3     19:21           3755 .ycm_extra_conf.py
-a----          2022/4/3     19:21           1316 appveyor.yml
-a----          2022/4/3     19:21           2437 AUTHORS
-a----          2022/4/3     19:21           1828 BUILD.bazel
-a----          2022/4/3     19:21          14124 CMakeLists.txt
-a----          2022/4/3     19:21           2543 CONTRIBUTING.md
-a----          2022/4/3     19:21           3661 CONTRIBUTORS
-a----          2022/4/3     19:21          13200 LICENSE
-a----          2022/4/3     19:21           7663 README.md
-a----          2022/4/3     19:21             48 requirements.txt
-a----          2022/4/3     19:21           5248 setup.py
-a----          2022/4/3     19:21           1471 WORKSPACE
-a----          2022/4/3     19:21             45 _config.yml

8、cmake -E chdir "build" cmake -DBENCHMARK_DOWNLOAD_DEPENDENCIES=on -DCMAKE_BUILD_TYPE=Release ../

PS D:\work\google_work\benchmark> cmake -E chdir "build" cmake -DBENCHMARK_DOWNLOAD_DEPENDENCIES=on -DCMAKE_BUILD_TYPE=Release ../
-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.22000.
-- The CXX compiler identification is MSVC 19.31.31104.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.31.31103/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Git: C:/Program Files/Git/cmd/git.exe (found version "2.33.0.windows.1")
-- git version: v1.6.1-38-g60b16f11 normalized to 1.6.1.38
-- Version: 1.6.1.38
-- Looking for shm_open in rt
-- Looking for shm_open in rt - not found
-- Performing Test HAVE_STD_REGEX
-- Performing Test HAVE_STD_REGEX
-- Performing Test HAVE_STD_REGEX -- success
-- Performing Test HAVE_GNU_POSIX_REGEX
-- Performing Test HAVE_GNU_POSIX_REGEX
-- Performing Test HAVE_GNU_POSIX_REGEX -- failed to compile
-- Performing Test HAVE_POSIX_REGEX
-- Performing Test HAVE_POSIX_REGEX
-- Performing Test HAVE_POSIX_REGEX -- failed to compile
-- Performing Test HAVE_STEADY_CLOCK
-- Performing Test HAVE_STEADY_CLOCK
-- Performing Test HAVE_STEADY_CLOCK -- success
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - not found
-- Found Threads: TRUE
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Failed
-- Performing Test COMPILER_HAS_DEPRECATED
-- Performing Test COMPILER_HAS_DEPRECATED - Success
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.22000.
-- Looking for Google Test sources
-- Looking for Google Test sources in D:/work/google_work/benchmark/googletest
CMake Warning at CMakeLists.txt:37 (message):
  Did not find Google Test sources! Fetching from web...


-- Configuring done
-- Generating done
-- Build files have been written to: D:/work/google_work/benchmark/build/third_party/googletest
用于 .NET Framework 的 Microsoft (R) 生成引擎版本 17.1.0+ae57d105c
版权所有(C) Microsoft Corporation。保留所有权利。

  Checking Build System
  Creating directories for 'googletest'
  Building Custom Rule D:/work/google_work/benchmark/build/third_party/googletest/CMakeLists.txt
  Performing download step (git clone) for 'googletest'
  Cloning into 'src'...
  HEAD is now at e2239ee6 Googletest export
  Performing update step for 'googletest'
  No patch step for 'googletest'
  No configure step for 'googletest'
  No build step for 'googletest'
  No install step for 'googletest'
  No test step for 'googletest'
  Completed 'googletest'
  Building Custom Rule D:/work/google_work/benchmark/build/third_party/googletest/CMakeLists.txt
-- The C compiler identification is MSVC 19.31.31104.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.31.31103/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Found Python: C:/Users/eric/AppData/Local/Programs/Python/Python39/python.exe (found version "3.9.6") found components: Interpreter
-- Performing Test BENCHMARK_HAS_O3_FLAG
-- Performing Test BENCHMARK_HAS_O3_FLAG - Failed
-- Configuring done
-- Generating done
-- Build files have been written to: D:/work/google_work/benchmark/build
PS D:\work\google_work\benchmark> cmake --build "build" --config Release --target install
用于 .NET Framework 的 Microsoft (R) 生成引擎版本 17.1.0+ae57d105c
版权所有(C) Microsoft Corporation。保留所有权利。

  Checking Build System
  Building Custom Rule D:/work/google_work/benchmark/src/CMakeLists.txt
  benchmark.cc
  benchmark_api_internal.cc
  benchmark_name.cc
  benchmark_register.cc
  benchmark_runner.cc
  check.cc
  colorprint.cc
  commandlineflags.cc
  complexity.cc
  console_reporter.cc
  counter.cc
  csv_reporter.cc
  json_reporter.cc
  perf_counters.cc
  reporter.cc
  sleep.cc
  statistics.cc
  string_util.cc
  sysinfo.cc
  timers.cc
  正在生成代码...
  benchmark.vcxproj -> D:\work\google_work\benchmark\build\src\Release\benchmark.lib
  Building Custom Rule D:/work/google_work/benchmark/src/CMakeLists.txt
  benchmark_main.cc
  benchmark_main.vcxproj -> D:\work\google_work\benchmark\build\src\Release\benchmark_main.lib
  Building Custom Rule D:/work/google_work/benchmark/test/CMakeLists.txt
  args_product_test.cc
  args_product_test.vcxproj -> D:\work\google_work\benchmark\build\test\Release\args_product_test.exe
  Building Custom Rule D:/work/google_work/benchmark/test/CMakeLists.txt
  basic_test.cc
  basic_test.vcxproj -> D:\work\google_work\benchmark\build\test\Release\basic_test.exe
  Building Custom Rule D:/work/google_work/benchmark/build/third_party/googletest/src/googlemock/CMakeLists.txt
  gtest-all.cc
  gmock-all.cc
  gmock_main.cc
  正在生成代码...
  gmock_main.vcxproj -> D:\work\google_work\benchmark\build\lib\Release\gmock_main.lib
  Building Custom Rule D:/work/google_work/benchmark/test/CMakeLists.txt
  benchmark_gtest.cc
  benchmark_gtest.vcxproj -> D:\work\google_work\benchmark\build\test\Release\benchmark_gtest.exe
  Building Custom Rule D:/work/google_work/benchmark/test/CMakeLists.txt
  benchmark_name_gtest.cc
  benchmark_name_gtest.vcxproj -> D:\work\google_work\benchmark\build\test\Release\benchmark_name_gtest.exe
  Building Custom Rule D:/work/google_work/benchmark/test/CMakeLists.txt
  benchmark_random_interleaving_gtest.cc
  benchmark_random_interleaving_gtest.vcxproj -> D:\work\google_work\benchmark\build\test\Release\benchmark_random_inte
  rleaving_gtest.exe
  Building Custom Rule D:/work/google_work/benchmark/test/CMakeLists.txt
  benchmark_setup_teardown_test.cc
  benchmark_setup_teardown_test.vcxproj -> D:\work\google_work\benchmark\build\test\Release\benchmark_setup_teardown_te
  st.exe
  Building Custom Rule D:/work/google_work/benchmark/test/CMakeLists.txt
  benchmark_test.cc
  benchmark_test.vcxproj -> D:\work\google_work\benchmark\build\test\Release\benchmark_test.exe
  Building Custom Rule D:/work/google_work/benchmark/test/CMakeLists.txt
  commandlineflags_gtest.cc
  commandlineflags_gtest.vcxproj -> D:\work\google_work\benchmark\build\test\Release\commandlineflags_gtest.exe
  Building Custom Rule D:/work/google_work/benchmark/test/CMakeLists.txt
  output_test_helper.cc
  output_test_helper.vcxproj -> D:\work\google_work\benchmark\build\test\Release\output_test_helper.lib
  Building Custom Rule D:/work/google_work/benchmark/test/CMakeLists.txt
  complexity_test.cc
  complexity_test.vcxproj -> D:\work\google_work\benchmark\build\test\Release\complexity_test.exe
  Building Custom Rule D:/work/google_work/benchmark/test/CMakeLists.txt
  diagnostics_test.cc
  diagnostics_test.vcxproj -> D:\work\google_work\benchmark\build\test\Release\diagnostics_test.exe
  Building Custom Rule D:/work/google_work/benchmark/test/CMakeLists.txt
  display_aggregates_only_test.cc
  display_aggregates_only_test.vcxproj -> D:\work\google_work\benchmark\build\test\Release\display_aggregates_only_test
  .exe
  Building Custom Rule D:/work/google_work/benchmark/test/CMakeLists.txt
  donotoptimize_test.cc
  donotoptimize_test.vcxproj -> D:\work\google_work\benchmark\build\test\Release\donotoptimize_test.exe
  Building Custom Rule D:/work/google_work/benchmark/test/CMakeLists.txt
  filter_test.cc
  filter_test.vcxproj -> D:\work\google_work\benchmark\build\test\Release\filter_test.exe
  Building Custom Rule D:/work/google_work/benchmark/test/CMakeLists.txt
  fixture_test.cc
  fixture_test.vcxproj -> D:\work\google_work\benchmark\build\test\Release\fixture_test.exe
  Building Custom Rule D:/work/google_work/benchmark/test/CMakeLists.txt
  internal_threading_test.cc
  internal_threading_test.vcxproj -> D:\work\google_work\benchmark\build\test\Release\internal_threading_test.exe
  Building Custom Rule D:/work/google_work/benchmark/test/CMakeLists.txt
  link_main_test.cc
  link_main_test.vcxproj -> D:\work\google_work\benchmark\build\test\Release\link_main_test.exe
  Building Custom Rule D:/work/google_work/benchmark/test/CMakeLists.txt
  map_test.cc
  map_test.vcxproj -> D:\work\google_work\benchmark\build\test\Release\map_test.exe
  Building Custom Rule D:/work/google_work/benchmark/test/CMakeLists.txt
  memory_manager_test.cc
  memory_manager_test.vcxproj -> D:\work\google_work\benchmark\build\test\Release\memory_manager_test.exe
  Building Custom Rule D:/work/google_work/benchmark/test/CMakeLists.txt
  multiple_ranges_test.cc
  multiple_ranges_test.vcxproj -> D:\work\google_work\benchmark\build\test\Release\multiple_ranges_test.exe
  Building Custom Rule D:/work/google_work/benchmark/test/CMakeLists.txt
  options_test.cc
  options_test.vcxproj -> D:\work\google_work\benchmark\build\test\Release\options_test.exe
  Building Custom Rule D:/work/google_work/benchmark/test/CMakeLists.txt
  perf_counters_gtest.cc
  perf_counters_gtest.vcxproj -> D:\work\google_work\benchmark\build\test\Release\perf_counters_gtest.exe
  Building Custom Rule D:/work/google_work/benchmark/test/CMakeLists.txt
  perf_counters_test.cc
  perf_counters_test.vcxproj -> D:\work\google_work\benchmark\build\test\Release\perf_counters_test.exe
  Building Custom Rule D:/work/google_work/benchmark/test/CMakeLists.txt
  register_benchmark_test.cc
  register_benchmark_test.vcxproj -> D:\work\google_work\benchmark\build\test\Release\register_benchmark_test.exe
  Building Custom Rule D:/work/google_work/benchmark/test/CMakeLists.txt
  repetitions_test.cc
  repetitions_test.vcxproj -> D:\work\google_work\benchmark\build\test\Release\repetitions_test.exe
  Building Custom Rule D:/work/google_work/benchmark/test/CMakeLists.txt
  report_aggregates_only_test.cc
  report_aggregates_only_test.vcxproj -> D:\work\google_work\benchmark\build\test\Release\report_aggregates_only_test.e
  xe
  Building Custom Rule D:/work/google_work/benchmark/test/CMakeLists.txt
  reporter_output_test.cc
  reporter_output_test.vcxproj -> D:\work\google_work\benchmark\build\test\Release\reporter_output_test.exe
  Building Custom Rule D:/work/google_work/benchmark/test/CMakeLists.txt
  skip_with_error_test.cc
  skip_with_error_test.vcxproj -> D:\work\google_work\benchmark\build\test\Release\skip_with_error_test.exe
  Building Custom Rule D:/work/google_work/benchmark/test/CMakeLists.txt
  spec_arg_test.cc
  spec_arg_test.vcxproj -> D:\work\google_work\benchmark\build\test\Release\spec_arg_test.exe
  Building Custom Rule D:/work/google_work/benchmark/test/CMakeLists.txt
  statistics_gtest.cc
  statistics_gtest.vcxproj -> D:\work\google_work\benchmark\build\test\Release\statistics_gtest.exe
  Building Custom Rule D:/work/google_work/benchmark/test/CMakeLists.txt
  string_util_gtest.cc
D:\work\google_work\benchmark\test\string_util_gtest.cc(66,5): warning C4834: 放弃具有 "nodiscard" 属性的函数的返回值 [D:\work\googl
e_work\benchmark\build\test\string_util_gtest.vcxproj]
D:\work\google_work\benchmark\test\string_util_gtest.cc(110,3): warning C4834: 放弃具有 "nodiscard" 属性的函数的返回值 [D:\work\goog
le_work\benchmark\build\test\string_util_gtest.vcxproj]
D:\work\google_work\benchmark\test\string_util_gtest.cc(140,3): warning C4834: 放弃具有 "nodiscard" 属性的函数的返回值 [D:\work\goog
le_work\benchmark\build\test\string_util_gtest.vcxproj]
  string_util_gtest.vcxproj -> D:\work\google_work\benchmark\build\test\Release\string_util_gtest.exe
  Building Custom Rule D:/work/google_work/benchmark/test/CMakeLists.txt
  templated_fixture_test.cc
  templated_fixture_test.vcxproj -> D:\work\google_work\benchmark\build\test\Release\templated_fixture_test.exe
  Building Custom Rule D:/work/google_work/benchmark/test/CMakeLists.txt
  time_unit_gtest.cc
  time_unit_gtest.vcxproj -> D:\work\google_work\benchmark\build\test\Release\time_unit_gtest.exe
  Building Custom Rule D:/work/google_work/benchmark/test/CMakeLists.txt
  user_counters_tabular_test.cc
  user_counters_tabular_test.vcxproj -> D:\work\google_work\benchmark\build\test\Release\user_counters_tabular_test.exe
  Building Custom Rule D:/work/google_work/benchmark/test/CMakeLists.txt
  user_counters_test.cc
  user_counters_test.vcxproj -> D:\work\google_work\benchmark\build\test\Release\user_counters_test.exe
  Building Custom Rule D:/work/google_work/benchmark/test/CMakeLists.txt
  user_counters_thousands_test.cc
  user_counters_thousands_test.vcxproj -> D:\work\google_work\benchmark\build\test\Release\user_counters_thousands_test
  .exe
  Building Custom Rule D:/work/google_work/benchmark/CMakeLists.txt
  -- Install configuration: "Release"
  -- Installing: C:/Program Files (x86)/benchmark/lib/benchmark.lib
  -- Installing: C:/Program Files (x86)/benchmark/lib/benchmark_main.lib
  -- Installing: C:/Program Files (x86)/benchmark/include/benchmark
  -- Installing: C:/Program Files (x86)/benchmark/include/benchmark/benchmark.h
  -- Up-to-date: C:/Program Files (x86)/benchmark/include/benchmark
  -- Installing: C:/Program Files (x86)/benchmark/include/benchmark/export.h
  -- Installing: C:/Program Files (x86)/benchmark/lib/cmake/benchmark/benchmarkConfig.cmake
  -- Installing: C:/Program Files (x86)/benchmark/lib/cmake/benchmark/benchmarkConfigVersion.cmake
  -- Installing: C:/Program Files (x86)/benchmark/lib/pkgconfig/benchmark.pc
  -- Installing: C:/Program Files (x86)/benchmark/lib/cmake/benchmark/benchmarkTargets.cmake
  -- Installing: C:/Program Files (x86)/benchmark/lib/cmake/benchmark/benchmarkTargets-release.cmake
  -- Installing: C:/Program Files (x86)/benchmark/share/doc/benchmark
  -- Installing: C:/Program Files (x86)/benchmark/share/doc/benchmark/AssemblyTests.md
  -- Installing: C:/Program Files (x86)/benchmark/share/doc/benchmark/dependencies.md
  -- Installing: C:/Program Files (x86)/benchmark/share/doc/benchmark/index.md
  -- Installing: C:/Program Files (x86)/benchmark/share/doc/benchmark/perf_counters.md
  -- Installing: C:/Program Files (x86)/benchmark/share/doc/benchmark/platform_specific_build_instructions.md
  -- Installing: C:/Program Files (x86)/benchmark/share/doc/benchmark/random_interleaving.md
  -- Installing: C:/Program Files (x86)/benchmark/share/doc/benchmark/releasing.md
  -- Installing: C:/Program Files (x86)/benchmark/share/doc/benchmark/tools.md
  -- Installing: C:/Program Files (x86)/benchmark/share/doc/benchmark/user_guide.md
  -- Installing: C:/Program Files (x86)/benchmark/share/doc/benchmark/_config.yml

这样就在win11下源码编译安装完毕。

具体,有:

为便于检索,文章收录于: