CMakeLists.txt 2.38 KB
Newer Older
1
project(pam_kwallet)
2
cmake_minimum_required(VERSION 3.16)
3
set(KF5_MIN_VERSION "5.82")
4
set(PROJECT_VERSION "5.21.80")
Jonathan Esk-Riddell's avatar
Jonathan Esk-Riddell committed
5
6
set(PROJECT_VERSION_MAJOR 5)

Laurent Montel's avatar
Laurent Montel committed
7
find_package (ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)
8
9
set (CMAKE_MODULE_PATH ${ECM_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" )

10
include(CheckFunctionExists)
11
include(KDEInstallDirs)
12
include(KDEClangFormat)
13
14

find_package(PAM REQUIRED)
15
find_package(LibGcrypt 1.5.0 REQUIRED)
16
17
18
19
20
21

find_program(SOCAT_EXECUTABLE socat)

if (SOCAT_EXECUTABLE)
  message (STATUS "Found socat executable: ${SOCAT_EXECUTABLE}")
else ()
22
  message (WARNING "socat is required for pam_kwallet to work")
23
endif ()
24
25
26
27
28

include_directories (
   ${PAM_INCLUDE_DIR}
   ${CMAKE_BINARY_DIR}
   ${CMAKE_CURRENT_BINARY_DIR}
Samuel Gaist's avatar
Samuel Gaist committed
29
   ${LIBGCRYPT_INCLUDE_DIR}
30
)
31
32
33

add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050c00)
add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x054200)
34

35
set(library_name "pam_kwallet5")
Martin Klapetek's avatar
Martin Klapetek committed
36

37
38
39
40
set(pam_kwallet_SRCS
   pam_kwallet.c
)

41
set(KF5_MIN_VERSION "5.82")
42
43
44
45
46
47
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
    Wallet
)

add_definitions(-DKWALLETD_BIN_PATH="${KWALLETD_BIN_PATH}")

48
49
50
51
52
53
if (APPLE)
LIST(APPEND pam_kwallet_SRCS
   pam_darwin.c
)
endif()

54
55
56
57
58
59
60
61
62
63
64
65
66
# Handle different PAM header styles:
#  - "Linux style" has pam_ext.h
#  - "BSD style" has pam_appl.h
#
find_file(PAM_EXT_PATH security/pam_ext.h)
find_file(PAM_APPL_PATH security/pam_appl.h)
if (PAM_EXT_PATH)
    add_definitions(-DHAVE_PAM_EXT)
endif()
if (PAM_APPL_PATH)
    add_definitions(-DHAVE_PAM_APPL)
endif()

67
68
69
70
71
72
73
74
set(CMAKE_REQUIRED_INCLUDES "string.h")
check_function_exists(explicit_bzero HAVE_EXPLICIT_BZERO)
set(CMAKE_REQUIRED_INCLUDES)

if (HAVE_EXPLICIT_BZERO)
    add_definitions(-DHAVE_EXPLICIT_BZERO)
endif()

Martin Klapetek's avatar
Martin Klapetek committed
75
76
77
add_library (${library_name} SHARED ${pam_kwallet_SRCS})
set_target_properties (${library_name} PROPERTIES PREFIX "")
target_link_libraries (${library_name}
78
79
   ${PAM_LIBRARIES}
   ${LIBGCRYPT_LIBRARIES}
80
)
Rohan Garg's avatar
Rohan Garg committed
81

82
83
84
85
# add clang-format target for all our real source files
file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h)
kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES})

86
install(TARGETS ${library_name} DESTINATION ${KDE_INSTALL_LIBDIR}/security)
87
88
89

configure_file(pam_kwallet_init.desktop.cmake ${CMAKE_BINARY_DIR}/pam_kwallet_init.desktop)

90
install(PROGRAMS pam_kwallet_init DESTINATION ${KDE_INSTALL_LIBEXECDIR})
91

92
install(FILES ${CMAKE_BINARY_DIR}/pam_kwallet_init.desktop DESTINATION ${KDE_INSTALL_AUTOSTARTDIR})