New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed cmake 3.16.0 incompatibility. #9117
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above
# | ||
IF(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16.0") | ||
LIST(TRANSFORM CMAKE_THREAD_LIBS_INIT PREPEND "-l") | ||
ENDIF() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind changing this to REGEX_REPLACE
a match ^pthreads$
with -lpthreads
? That way you don't need the version check and we avoid accidentally producing -l-lpthreads
the moment something changes in a future CMake version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mhm What about you just check for your expectation then?
IF("${CMAKE_THREAD_LIBS_INIT}" MATCHES "^pthread$")
STRING(PREPEND CMAKE_THREAD_LIBS_INIT "-l")
ENDIF()
b2fe16d
to
d4f4124
Compare
I understand your concerns and like your suggestion. Adapted changes correspondingly. |
But on the other hand, |
Unfortunately, negative lookahead is not available in You may decide which one we should prefer and which one we should drop :) |
7ede4d7
to
31b72e0
Compare
/rebuild |
Somewhat in line with https://gitlab.kitware.com/cmake/cmake/issues/19823, it seems that |
31b72e0
to
3363199
Compare
Added a check for emptiness for that particular variable. Hopefully |
Sorry for letting you jump through so many hoops. Would you mind testing my suggestion to simply check for |
Testers are happy! @tamiko I gave your proposal a try on my machine as well and it did what expected. However, since |
As a general remark: We are currently using |
Exactly, we should hand |
Fixes #9116.
I chose with the most pragmatic way of resolving this issue: By simply imitating what
CMake
did in previous versions.There may be other ways of fixing this, e.g. by considering
pthreads
at theTARGET_LINK_LIBRARIES
stage viaHowever right now, we just add a linker flag, and I didn't want to overhaul the whole process without being able to assess the consequences.