cmake-basis / BASIS

CMake BASIS makes it easy to create sharable software and libraries that work together. This is accomplished by combining and documenting some of the best practices and utilities available. This project supplies a fully integrated suite of functionality to make the whole process seamless!
https://cmake-basis.github.io
Other
48 stars 10 forks source link

MSVC Pthread issue #632

Closed Foadsf closed 4 years ago

Foadsf commented 4 years ago

Following this SO question, running the CMake command:

cmake -DCMAKE_INSTALL_PREFIX:PATH=/home/foobar/local -DBUILD_APPLICATIONS:BOOL=ON -DBUILD_EXAMPLE:BOOL=ON .. -G "Visual Studio 15 2017 Win64"

leads to:

-- Looking for pthread.h - not found

I tried copy-pasting files FindThreads.cmake, FindPackageHandleStandardArgs.cmake, and FindPackageMessage.cmake from here with no avail. Though the compiling-installing command

cmake --build . --config release --target install

seems to be working:

schuhschuh commented 4 years ago

The pthreads library is for Unix systems only. You wouldn't use it on Windows for multithreading. Hence, the "not found" message is likely just an FYI, not an error. As you say compilation succeeds, and presumably executables work as expected, would you say this is still an actual issue requiring some fix?

Foadsf commented 4 years ago

@schuhschuh how about using:

#ifdef _WIN32
#include <windows.h>
#else
#include <pthread.h>
#endif
schuhschuh commented 4 years ago

Given that compllation succeeds, this should be the case in code. Note that the status message is from CMake's Find module, simply reporting what it has or hasn't found installed on your system. It's not a C++ compiler message.

On Sun, 22 Mar 2020, 23:19 Foad Sojoodi Farimani, notifications@github.com wrote:

@schuhschuh https://github.com/schuhschuh how about using:

ifdef _WIN32

include

else

include

endif

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cmake-basis/BASIS/issues/632#issuecomment-602292859, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHOEWYRNGQUXJKKEVTOMUDRI2MIPANCNFSM4LO5O4WQ .

Foadsf commented 4 years ago

@schuhschuh Then I think we should modify the CMake scripts to do not check pthread if on Windows or MSVC. can we do that?

schuhschuh commented 4 years ago

Note that BASIS itself does not check for pthreads itself, but a "Threads" library (also a valid query on Windows). It is CMake's official FindThreads.cmake module which emits this informational message. You may want to discuss this with the CMake developers themselves if you believe the behavior of FindThreads should be modified. IMHO This is normal behavior.

What can be done is to modify the CMake command find_package(Threads) in config/Settings.cmake to use QUIET flat. This will silence messages from FindThreads with the downside of course that there is no feedback on whether or not a threading library was found.