client-lib: link against libafbwsc
[staging/windowmanager.git] / client-lib / CMakeLists.txt
1 #
2 # Copyright (C) 2017 Mentor Graphics Development (Deutschland) GmbH
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #      http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 #
16
17 include(FindPkgConfig)
18
19 pkg_check_modules(AFB REQUIRED libafbwsc)
20 pkg_check_modules(SD REQUIRED libsystemd>=222)
21
22 add_library(afbclient SHARED
23    AFBClient.cpp
24    AFBClient.h)
25
26 target_include_directories(afbclient
27     PRIVATE
28         ${AFB_INCLUDE_DIRS}
29         ${SD_INCLUDE_DIRS})
30
31 target_link_libraries(afbclient
32    PUBLIC
33         ${AFB_LIBRARIES}
34         ${SD_LIBRARIES})
35
36 target_compile_definitions(afbclient
37     PRIVATE
38         _GNU_SOURCE)  # XXX should I define this here?!
39
40 if(NOT ${CMAKE_BUILD_TYPE} STREQUAL "Release")
41    target_compile_definitions(afbclient
42            PRIVATE
43            _GLIBCXX_DEBUG)
44 endif()
45
46 target_compile_options(afbclient
47     PRIVATE
48         -Wall -Wextra -Wno-unused-parameter -Wno-comment)
49
50 set_target_properties(afbclient
51     PROPERTIES
52     # INTERPROCEDURAL_OPTIMIZATION ON
53         CXX_EXTENSIONS OFF
54         CXX_STANDARD 14
55         CXX_STANDARD_REQUIRED ON)
56
57 if (LINK_LIBCXX)
58    set_target_properties(afbclient
59            PROPERTIES
60            LINK_FLAGS "-lc++")
61 endif()
62
63 if (NOT ${SANITIZER_MODE} STREQUAL "none" AND NOT ${SANITIZER_MODE} STREQUAL "")
64    target_compile_options(afbclient
65       PRIVATE
66          -fsanitize=${SANITIZER_MODE} -g -fno-omit-frame-pointer)
67    set_target_properties(afbclient
68       PROPERTIES
69          LINK_FLAGS "-fsanitize=${SANITIZER_MODE} -g")
70 endif()
71
72 install(
73    TARGETS afbclient
74    DESTINATION ${CMAKE_INSTALL_LIBDIR}
75    COMPONENT "runtime")
76
77 install(
78    FILES AFBClient.h
79    DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
80    COMPONENT "development")
81
82 add_subdirectory(doc)