CMakeLists.txt 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. # FetchContent added in cmake v3.11
  2. # https://cmake.org/cmake/help/v3.11/module/FetchContent.html
  3. # this file is behind a feature flag (XLNT_MICROBENCH_ENABLED) so the primary build is not affected
  4. cmake_minimum_required(VERSION 3.11)
  5. project(xlnt_ubench)
  6. # acquire google benchmark dependency
  7. # disable generation of the various test projects
  8. set(BENCHMARK_ENABLE_TESTING OFF)
  9. # gtest not required
  10. set(BENCHMARK_ENABLE_GTEST_TESTS OFF)
  11. include(FetchContent)
  12. FetchContent_Declare(
  13. googlebenchmark
  14. GIT_REPOSITORY https://github.com/google/benchmark
  15. GIT_TAG v1.5.0
  16. )
  17. # download if not already present
  18. FetchContent_GetProperties(googlebenchmark)
  19. if(NOT googlebenchmark_POPULATED)
  20. FetchContent_Populate(googlebenchmark)
  21. add_subdirectory(${googlebenchmark_SOURCE_DIR} ${googlebenchmark_BINARY_DIR})
  22. endif()
  23. # equivalent of add_subdirectory, now available for use
  24. FetchContent_MakeAvailable(googlebenchmark)
  25. add_executable(xlnt_ubench)
  26. target_sources(xlnt_ubench
  27. PRIVATE
  28. string_to_double.cpp
  29. double_to_string.cpp
  30. )
  31. target_link_libraries(xlnt_ubench benchmark_main xlnt)
  32. target_compile_features(xlnt_ubench PRIVATE cxx_std_17)