I'm newbie with CMake. I tested it on Linux for a program I am making. This program uses (POSIX Threads lib), so in my CMakeList, I added :
find_package(Threads)
It works on Linux distribs (Arch, Mint, Ubuntu, ...), but now, I'm trying it in Windows32 (Visual Studio 9 2008), and I get this message during generation :
-- Looking for include file pthread.h - not found
(and when I compile output project file, pthread.h is indeed not found).
On Windows, considering "C:\pthread" as my pthread directory, I defined in path :
But I still get the same error (even after deleted cache). I know I could "manually" add Pthread in my Project, or define some constants in CMakeList.txt, but I thinks it's not the principle of CMake : I could use the SAME "CMakeList.txt" on all systems, right ? So how can I tell to CMake "Hey ! Looks here ! Pthread is in this directory !". Maybe Cmake doesn't look in PATH, but in another environment variable, but I didn't find this information.
Thank you for reading.
EDIT : I don't know if it makes a difference, but my project is a C++ project (not C)
Windows does not support the pthreads standard natively, therefore the Pthreads4w project seeks to provide a portable and open-source wrapper implementation. It can also be used to port Unix software (which uses pthreads) with little or no modification to the Windows platform.
The pthread. h header file contains function declarations and mappings for threading interfaces and defines a number of constants used by those functions. The header includes the sched. h header.
What I did, I edited the cmake file:
option(CMAKE_USE_WIN32_THREADS_INIT "using WIN32 threads" ON)
and
option(gtest_disable_pthreads "Disable uses of pthreads in gtest." ON)
(I am using google test)
As far as i know, Pthreads is not natively supported on windows platform. Unless you use some thing like
win services for unix
Windows only has win32 threads.
However, this is a project which provides pthreads on windows
pthreads on win32
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With