Homec4science

CMake: use threads if allowed and found, not just if found.

Authored by Roman Lebedev <lebedev.ri@gmail.com> on Dec 30 2016, 08:46.

Description

CMake: use threads if allowed and found, not just if found.

If the user's cmakelists.txt first look for threads using
find_package(Threads), then set(gtest_disable_pthreads ON),
and then include googletest. GoogleTest will not look for
threads. But since they have already been found before in
user's cmakelists, it will use them regardless.

This helped me fix build issue in darktable-org/rawspeed
on windows/MSYS2, even though there are threads, and they
are usable, googletest build was failing with issues
about AutoHandle. I was first looking for threads, and only
then including googletest, so no matter the value of
gtest_disable_pthreads, it failed.

The other obvious solution is for user to first include
googletest, and only then look for threads by himself.

Details

Committed
Roman Lebedev <lebedev.ri@gmail.com>Sep 1 2017, 20:02
Pushed
trottetDec 4 2019, 13:52
Parents
R9484:e4f6c0b358a4: Merge pull request #1011 from zeitounator/wrong-version-reported
Branches
Unknown
Tags
Unknown

Event Timeline

Roman Lebedev <lebedev.ri@gmail.com> committed R9484:1a62d1b08806: CMake: use threads if allowed and found, not just if found. (authored by Roman Lebedev <lebedev.ri@gmail.com>).Sep 1 2017, 20:02