I am porting a C library from autotools to cmake. The library depends on pthreads, which with autotools is detected using an AX_PTHREAD
macro from an ax_pthread.m4
file. This macro sets PTHREAD_LIBS
and PTHREAD_CFLAGS
appropriately for the target platform.
In cmake, I am replacing this with a find_package(Threads REQUIRED)
and target_link_libraries( ... Threads::Threads)
.
One thing I can’t figure out how to do however is this: my library has a .pc file for pkg-config which is generated (currently by autotools) from a .pc.in file which relies on PTHREAD_LIBS
and PTHREAD_CFLAGS
to know what cflags and libs pkg-config should return. I am replacing the generation of this .pc file with cmake’s configure_file (...)
, but I don’t know how to get the equivalent of PTHREAD_LIBS
and PTHREAD_CFLAGS
from the Threads::Threads
target. How can I do that?