Skip to content

Commit

Permalink
馃挌 Jail Google Benchmark and Catch2
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePhD committed Oct 7, 2022
1 parent 9cc5713 commit 6dc980d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 30 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,11 @@ if (ZTD_TEXT_EXAMPLES OR ZTD_TEXT_BENCHMARKS)
set(BUILD_TESTING OFF)
FetchContent_Declare(
simdutf
GIT_REPOSITORY https://github.com/ThePhD/simdutf
GIT_REPOSITORY https://github.com/simdutf/simdutf
GIT_SHALLOW ON
GIT_TAG master)
FetchContent_MakeAvailable(simdutf)
set_property(DIRECTORY "${simdutf_SOURCE_DIR}" PROPERTY EXCLUDE_FROM_ALL YES)
endfunction()
simdutf_dependency_jail()

Expand All @@ -226,6 +227,7 @@ if (ZTD_TEXT_EXAMPLES OR ZTD_TEXT_BENCHMARKS)
GIT_SHALLOW ON
GIT_TAG master)
FetchContent_MakeAvailable(boost.text)
set_property(DIRECTORY "${boost.text_SOURCE_DIR}" PROPERTY EXCLUDE_FROM_ALL YES)
endfunction()
if (ZTD_TEXT_BOOST.TEXT)
boost_text_dependency_jail()
Expand Down
45 changes: 25 additions & 20 deletions benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,35 @@ include(FetchContent)
include(GraphBenchmarks)

# # Fetch dependencies
# Google Benchmark
function(googlebenchmark_dependency_jail)
# google benchmark
function (google_benchmark_dependency_jail)
FetchContent_Declare(
googlebenchmark
google_benchmark
GIT_REPOSITORY https://github.com/google/benchmark.git
GIT_SHALLOW ON
GIT_TAG main)
FetchContent_GetProperties(googlebenchmark)

if(NOT googlebenchmark_POPULATED)
FetchContent_Populate(googlebenchmark)
set(BENCHMARK_ENABLE_INSTALL OFF)
set(BENCHMARK_ENABLE_TESTING OFF)
set(BENCHMARK_ENABLE_GTEST_TESTS OFF)
set(BENCHMARK_ENABLE_WERROR OFF)
set(BENCHMARK_FORCE_WERROR OFF)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND WIN32)
# google benchmark is broken, so we need to force HAVE_STD_REGEX to be on for this.
set(HAVE_STD_REGEX ON)
endif()
add_subdirectory(${googlebenchmark_SOURCE_DIR} ${googlebenchmark_BINARY_DIR})
GIT_TAG main
)
# Benchmark variables, internal setup
set(BENCHMARK_ENABLE_EXCEPTIONS ON)
set(BENCHMARK_ENABLE_TESTING OFF)
set(BENCHMARK_DOWNLOAD_DEPENDENCIES OFF)
set(BENCHMARK_ENABLE_GTEST_TESTS OFF)
set(BENCHMARK_ENABLE_GTEST_TESTS OFF)
set(BENCHMARK_ENABLE_WERROR OFF)
set(BENCHMARK_FORCE_WERROR OFF)
set(BENCHMARK_ENABLE_INSTALL OFF)
set(BENCHMARK_ENABLE_TESTING OFF)
set(BENCHMARK_ENABLE_GTEST_TESTS OFF)
set(BENCHMARK_ENABLE_WERROR OFF)
set(BENCHMARK_FORCE_WERROR OFF)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND WIN32)
# google benchmark is broken, so we need to force HAVE_STD_REGEX to be on for this.
set(HAVE_STD_REGEX ON)
endif()
FetchContent_MakeAvailable(google_benchmark)
set_property(DIRECTORY "${google_benchmark_SOURCE_DIR}" PROPERTY EXCLUDE_FROM_ALL YES)
endfunction()
googlebenchmark_dependency_jail()
google_benchmark_dependency_jail()


function (utf8cpp_dependency_jail)
FetchContent_Declare(
Expand Down
2 changes: 1 addition & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

add_subdirectory(basic)
add_subdirectory(documentation)
add_subdirectory(shift_jis)
if (ZTD_TEXT_BOOST.TEXT)
add_subdirectory(boost.text)
endif()
add_subdirectory(shift_jis)
15 changes: 7 additions & 8 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@

# # Fetch dependencies
# Catch2
if (NOT TARGET Catch2::Catch2)
FetchContent_Declare(
catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_SHALLOW ON
GIT_TAG devel)
FetchContent_MakeAvailable(catch2)
endif()
FetchContent_Declare(
catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_SHALLOW ON
GIT_TAG devel)
FetchContent_MakeAvailable(catch2)
set_property(DIRECTORY "${catch2_SOURCE_DIR}" PROPERTY EXCLUDE_FROM_ALL YES)

# # Test Subdirectories
add_subdirectory(inclusion)
Expand Down

0 comments on commit 6dc980d

Please sign in to comment.