Re: How to build and link in windows with cmake

Skip to first unread message

Dominic Hamon

Mar 28, 2019, 5:57:47 AM3/28/19
to, benchmark-discuss
You might want to consider "installing" the libraries and linking them from a standard place, unless there's a reason you're building from head.

There are users who have successfully used the project on Windows (and Mac, and Android, etc), but unfortunately I'm not one of them. Perhaps one of them can share their project?

Dominic Hamon | Google
There are no bad ideas; only good ideas that go horribly wrong.

On Wed, Mar 27, 2019 at 3:48 PM <> wrote:
I have run the benchmark tests and in both cases, they run succesfully

On Wednesday, March 27, 2019 at 9:17:01 PM UTC+5:30, wrote:
I have been trying to search for documentation on windows build for benchmark for the last few months to no avail. I now understand why good programmers always document their code.
Anyways, I have this CMakeLists.txt this works well in linux but for some reason, it doesn't in windows. and more over it build(both in linux and windows) the library files inside the src folder not in the release folders!

here is my CMakeLists.txt

cmake_minimum_required (VERSION 3.14)

# setting cxx standard

# project name
project (benchmark)

# set version numbers
set (benchmark_VERSION_MAJOR 0)
set (benchmark_VERSION_MINOR 1)
set (benchmark_VERSION_PATCH 0)

  GIT_TAG           master
  PREFIX            googlebenchmark
  BUILD_COMMAND     ${CMAKE_COMMAND} --build . --config Release 
  TEST_COMMAND      ${CMAKE_CTEST_COMMAND} --build-config Release 

ExternalProject_Get_Property (googlebenchmark SOURCE_DIR)
ExternalProject_Get_Property (googlebenchmark BINARY_DIR)
find_library (googlebenchmark_LIBRARIES NAMES benchmark HINTS ${BINARY_DIR}/src/Release)
message("library ${googlebenchmark_LIBRARIES}")
include_directories (googlebenchmark ${SOURCE_DIR}/include)
add_executable (benchmark try.cpp)
target_link_libraries (benchmark ${googlebenchmark_LIBRARIES})
#target_link_libraries (benchmark ${BINARY_DIR}/src/libbenchmark.a)
target_link_libraries (benchmark shlwapi)
add_dependencies (benchmark googlebenchmark)

in my Linux machine, I replaced shlwapi with pthread and it worked great, now for the windows machine I read the readme file and used the shlwapi library,

I can't seem to point to the weird place where the benchmark libraries are being built inside the src folder!

Any ideas would be helpful.(FOR WINDOWS PLEASE)

thanking everyone in advance,

You received this message because you are subscribed to the Google Groups "benchmark-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
For more options, visit
Reply all
Reply to author
0 new messages