Fixes compile problem for freebsd because of missing crypt.h
Needs ReviewPublic

Authored by usta on Sun, Jun 7, 4:13 AM.

Details

Reviewers
bcooksley
ngraham
adridg
Group Reviewers
Plasma
FreeBSD
Summary

Freebsd compile is not working last 17 days because of missing crypt.h
crypt method is in unistd.h for freebsd so we dont need it
and also I am not sure whether freebsd has crypt.h or not.

can somebody with freebsd try this patch ?

Diff Detail

Repository
R119 Plasma Desktop
Lint
Lint Skipped
Unit
Unit Tests Skipped
usta created this revision.Sun, Jun 7, 4:13 AM
Restricted Application added a project: Plasma. · View Herald TranscriptSun, Jun 7, 4:13 AM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
usta requested review of this revision.Sun, Jun 7, 4:13 AM
usta added a reviewer: ngraham.Sun, Jun 7, 4:39 AM
ngraham added a subscriber: adridg.

Adding @adridg as a reviewer.

Note that we have moved to Gitlab, so future contributions should be submitted at invent.kde.org. Thanks! You can find the documentation at https://community.kde.org/Infrastructure/GitLab.

tcberner added inline comments.
kcms/users/src/user.cpp
23

wouldn't it be a bit more portable to check for the header file in cmake? (OpenBSD also has the same issue, I would assume from [1])

[1] https://www.freebsd.org/cgi/man.cgi?query=crypt&apropos=0&sektion=3&manpath=OpenBSD+6.7&arch=default&format=html

usta added inline comments.Sun, Jun 7, 9:06 AM
kcms/users/src/user.cpp
23

I never think about openbsd , yes you are right about it. So how about if we use something like :
#if !defined(Q_OS_UNIX) && !defined(Q_OS_BSD4) && !defined(Q_OS_FREEBSD) && !defined(Q_OS_FREEBSD) && !defined(Q_OS_NETBSD) && !defined(Q_OS_OPENBSD)

usta added a comment.Sun, Jun 7, 9:08 AM

Sorry i have written one of them twice , so is this aproach wrong ?
#if !defined(Q_OS_UNIX) && !defined(Q_OS_BSD4) && !defined(Q_OS_FREEBSD) && !defined(Q_OS_NETBSD) && !defined(Q_OS_OPENBSD)

usta updated this revision to Diff 83237.Sun, Jun 7, 9:10 AM
usta added a project: FreeBSD.
usta added a comment.Sun, Jun 7, 9:12 AM

or if this is just for linux think we can make it just directly
if defined(Q_OS_LINUX)

adridg added a comment.Sun, Jun 7, 9:22 AM

https://invent.kde.org/adridg/plasma-desktop/-/tree/normalize-includes

There's already a CMake-time check for <crypt.h>, it's just not used. (HAVE_CRYPT_H)

usta added a comment.Sun, Jun 7, 9:47 AM

https://invent.kde.org/adridg/plasma-desktop/-/tree/normalize-includes

There's already a CMake-time check for <crypt.h>, it's just not used. (HAVE_CRYPT_H)

@adridg having or not having crypt_h I think won't solve this problem because it looks like Linux needs it on the other hand BSD system doesn't have it and use unistd.h
instead of crypt.h so doesn't we still need to check if the system is linux or not ? I have almost 0 knowledge about bsd systems so i think anyone who has knowledge
on this topic might be more suitable for this patch request. ( at first, I have just think about freebsd and now i can see there are other alternatives (net,open,... bsd has similar issue ) )

meven added a subscriber: meven.Mon, Jun 15, 11:34 AM
In D29847#674811, @usta wrote:

https://invent.kde.org/adridg/plasma-desktop/-/tree/normalize-includes

There's already a CMake-time check for <crypt.h>, it's just not used. (HAVE_CRYPT_H)

@adridg having or not having crypt_h I think won't solve this problem because it looks like Linux needs it on the other hand BSD system doesn't have it and use unistd.h
instead of crypt.h so doesn't we still need to check if the system is linux or not ? I have almost 0 knowledge about bsd systems so i think anyone who has knowledge
on this topic might be more suitable for this patch request. ( at first, I have just think about freebsd and now i can see there are other alternatives (net,open,... bsd has similar issue ) )

Linux will have HAVE_CRYPT_H set and *BSD won't, so this simply solves the issue :

#ifdef HAVE_CRYPT_H
#include <crypt.h>
#endif

It is used in kscreenlocker/kcheckpass/kcheckpass.h for instance.

kscreenlocker defines HAVE_CRYPT_H as :

set(CRYPT_LIBRARIES)
check_library_exists(crypt crypt "" HAVE_CRYPT)
if (HAVE_CRYPT)
    set(CRYPT_LIBRARIES crypt)
    check_include_files(crypt.h HAVE_CRYPT_H)
endif (HAVE_CRYPT)

You will need to add it to plasma-desktop cmake file in the appropriate section.

This review should be closed: a change landed via invent that makes it unnecessary (<crypt.h> is no longer used in the users kcm).