FindThreads: If THREADS_PREFER_PTHREAD_FLAG is false, the module specifies the thread library in -l<library_basename> form which is not transformed by CMake language support
The -pthreads linker option is understood by the gcc suite of compilers and the D compiler gdc, but it is not understood by ld or the D compilers dmd and ldc2 (and likely other compilers as well). So sometimes it is necessary to specify THREADS_PREFER_PTHREAD_FLAG as false before executing find_package(Threads). But in this case the FindThreads module returns the thread library using "-lpthread" which is a linker option which target_link_libraries passes through to the compiler used for linking with no further language-dependent transformations. So, for example, that untransformed option is not understood by the D compilers dmd and ldc2.
There is a simple solution to this issue (see attached FindThreads.patch.gz) which is that for THREADS_PREFER_PTHREAD_FLAG false, the FindThreads module should return the threads library in <library_basename> form rather than -l<library_basename> form, i.e., pthread rather than -lpthread.
The target_link_libraries command does transform the <library_basename> form of library specification via language-dependent transformations controlled, e.g., by CMAKE_D_LINK_LIBRARY_FLAG (or CMAKE_LINK_LIBRARY_FLAG if the language-dependent variable is not set). Therefore, for CMake version 3.15.20190829-g3ec986ce that I built on Linux (Debian Buster) and patched with the attached patch and for a test I made for the PLplot project (with its own D language support), "pthread" was transformed to the correct form in all cases (e.g., "-lpthread" for the gcc C compiler and the gdc D compiler and "-L-lpthread" for the dmd and ldc2 D compilers).