-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
It is not necessary to run cxx_feature_check for HAVE_GNU_POSIX_REGEX, HAVE_POSIX_REGEX, HAVE_STEADY_CLOCK or HAVE_PTHREAD_AFFINITY on every cmake re-config.
E.g. log on cmake config:
-- Google Benchmark version: v1.9.4, normalized to 1.9.4
-- Performing Test HAVE_GNU_POSIX_REGEX -- failed to compile
-- Performing Test HAVE_POSIX_REGEX -- failed to compile
-- Performing Test HAVE_STEADY_CLOCK -- success
-- Performing Test HAVE_PTHREAD_AFFINITY -- failed to compile
No compiler tests should be performed on a re-config as it is tied to the C/CXX compiler.
The issue is because of the following code:
cxx_feature_check(STD_REGEX)
cxx_feature_check(GNU_POSIX_REGEX)
cxx_feature_check(POSIX_REGEX)
if(NOT HAVE_STD_REGEX AND NOT HAVE_GNU_POSIX_REGEX AND NOT HAVE_POSIX_REGEX)
message(FATAL_ERROR "Failed to determine the source files for the regular expression backend")
endif()
This is not necessary. A suggestion to solve this is to change cxx_feature_check such that it sets the necessary feature variables in the cache instead of a normal variable. On config re-run, CMake will see that the variable is already set and not run the tests again.
To reproduce, run this twice and inspect the log:
cmake -B build -G Ninja -DBENCHMARK_DOWNLOAD_DEPENDENCIES=1
Expected behaviour: the second call to cmake should be a no-op and run no compiler tests, and print nothing to the console.