-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
109 lines (90 loc) · 3.82 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.5)
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "Release" CACHE
STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel."
FORCE)
ENDIF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_PROJECT_NAME "LibWSM")
INCLUDE(CheckIncludeFiles)
INCLUDE(CheckLibraryExists)
INCLUDE(CheckFunctionExists)
INCLUDE(FindPkgConfig)
INCLUDE(FeatureSummary)
INCLUDE(GNUInstallDirs)
INCLUDE_DIRECTORIES("include/" ${CMAKE_SOURCE_DIR}/src)
LINK_DIRECTORIES(${CMAKE_BINARY_DIR})
ADD_DEFINITIONS("-Wall -D_GNU_SOURCE")
OPTION(WSM_LIB "Wayland Security Modules library" ON)
OPTION(WSM_BUILD_BACKENDS "Build the integrated WSM backends" ON)
OPTION(WSM_BE_DEFAULT "Example backend" ON)
IF(NOT WSM_BUILD_BACKENDS)
SET(WSM_BE_EXAMPLE OFF)
ENDIF(NOT WSM_BUILD_BACKENDS)
#Tell libWSM where to find the backends
IF(NOT WSM_BACKEND_DIRECTORY)
SET(WSM_BACKEND_DIRECTORY ${CMAKE_INSTALL_LIBDIR}/wsm)
ENDIF(NOT WSM_BACKEND_DIRECTORY)
ADD_DEFINITIONS(-DWSM_BACKEND_DIRECTORY="${WSM_BACKEND_DIRECTORY}")
IF(NOT WSM_DEFAULT_POLICY_PREFIX)
SET(WSM_DEFAULT_POLICY_PREFIX ${CMAKE_INSTALL_DATAROOTDIR}/security)
ENDIF(NOT WSM_DEFAULT_POLICY_PREFIX)
ADD_DEFINITIONS(-DWSM_DEFAULT_POLICY_PREFIX="${WSM_DEFAULT_POLICY_PREFIX}")
# dependencies
PKG_CHECK_MODULES(WAYLAND_SERVER wayland-server)
IF(WAYLAND_SERVER_FOUND)
INCLUDE_DIRECTORIES(${WAYLAND_SERVER_INCLUDE_DIRS})
LINK_DIRECTORIES(${WAYLAND_SERVER_LIBRARY_DIRS})
ELSE(WAYLAND_SERVER_FOUND)
SET(WSM_LIB "OFF")
ENDIF(WAYLAND_SERVER_FOUND)
# libWSM library
IF(WSM_LIB)
FILE(GLOB_RECURSE wsm_include_SOURCES RELATIVE ${CMAKE_SOURCE_DIR} "include/*.h")
FILE(GLOB_RECURSE wsm_SOURCES RELATIVE ${CMAKE_SOURCE_DIR} "src/*.[ch]")
ADD_LIBRARY(wsm SHARED ${wsm_SOURCES} ${wsm_include_SOURCES})
SET_PROPERTY(TARGET wsm PROPERTY VERSION 0.1.0)
SET_PROPERTY(TARGET wsm PROPERTY SOVERSION 1)
TARGET_LINK_LIBRARIES(wsm ${WAYLAND_SERVER_LIBRARIES} dl)
INSTALL(TARGETS wsm DESTINATION ${CMAKE_INSTALL_LIBDIR})
INSTALL(FILES "${CMAKE_SOURCE_DIR}/include/libwsm.h" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
INSTALL(DIRECTORY "${CMAKE_SOURCE_DIR}/include/wsm" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
ENDIF(WSM_LIB)
# default backend
IF(WSM_BE_DEFAULT)
FILE(GLOB wsm_be_default_SOURCES RELATIVE ${CMAKE_SOURCE_DIR} "backends/default/*.[ch]")
ADD_LIBRARY(wsm_default MODULE ${wsm_be_default_SOURCES})
TARGET_LINK_LIBRARIES(wsm_default wsm)
INSTALL(TARGETS wsm_default DESTINATION ${WSM_BACKEND_DIRECTORY})
INSTALL(DIRECTORY "${CMAKE_SOURCE_DIR}/data/security/wsm" DESTINATION "${WSM_DEFAULT_POLICY_PREFIX}")
ENDIF(WSM_BE_DEFAULT)
#PKG-CONFIG
set(LIBWSM_VERSION "0.1")
configure_file(libwsm.pc.in libwsm.pc @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libwsm.pc" DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
# Test
add_executable(test_base "tests/base.c" "tests/unix_socket.c" "tests/unix_socket.h")
target_link_libraries(test_base wsm)
#Final summary
MESSAGE("")
MESSAGE("")
MESSAGE(" -------------------")
MESSAGE("| Summary |")
MESSAGE(" -------------------")
MESSAGE("")
MESSAGE("Library : ${WSM_LIB} (-DWSM_LIB=OFF to deactivate)")
MESSAGE("")
MESSAGE("Backends : ${WSM_BUILD_BACKENDS} (-DWSM_BUILD_BACKENDS=OFF to deactivate)")
MESSAGE("Default : ${WSM_BE_DEFAULT} (-DWSM_BE_DEFAULT=OFF to deactivate)")
MESSAGE("")
MESSAGE("Options :")
MESSAGE(" Build type : ${CMAKE_BUILD_TYPE} (-DCMAKE_BUILD_TYPE=Debug to debug)")
MESSAGE(" Prefix : '${CMAKE_INSTALL_PREFIX}' (-DCMAKE_INSTALL_PREFIX=/your/prefix)")
MESSAGE(" Backends dir : '${WSM_BACKEND_DIRECTORY}' (-DWSM_BACKEND_DIRECTORY=/your/prefix)")
MESSAGE(" More dirs : See CMake's GNUInstallDirs")
MESSAGE("")
IF(WSM_BE_DEFAULT)
MESSAGE("Default backend :")
MESSAGE(" Policy dir : '${WSM_DEFAULT_POLICY_PREFIX}' (-DWSM_DEFAULT_POLICY_PREFIX=/your/prefix)")
MESSAGE("")
ENDIF(WSM_BE_DEFAULT)
MESSAGE("")