f077d68292c3c4aa8056b57c898dc40325c7a796
[staging/windowmanager.git] / src / 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 wlproto(IVI_CON ivi-controller)
18
19 include(FindPkgConfig)
20 pkg_check_modules(AFB REQUIRED afb-daemon)
21 pkg_check_modules(SD REQUIRED libsystemd>=222)
22
23 # We do not want a prefix for our module
24 set(CMAKE_SHARED_MODULE_PREFIX "")
25
26 add_custom_command(
27    OUTPUT afb_binding_api.hpp afb_binding_glue.inl
28    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../generate-binding-glue.py
29    COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/../generate-binding-glue.py)
30
31 add_library(winman MODULE
32    main.cpp
33    wayland.cpp
34    wayland.hpp
35    util.cpp
36    util.hpp
37    layout.cpp
38    layout.hpp
39    ${IVI_CON_PROTO}
40    json_helper.cpp
41    json_helper.hpp
42    app.hpp app.cpp
43    afb_binding_api.cpp
44    result.hpp
45    afb_binding_api.hpp
46    afb_binding_glue.inl
47    layers.cpp
48    layers.hpp
49    controller_hooks.hpp
50    config.cpp
51    config.hpp
52    policy.hpp)
53
54 add_executable(redraw_fixer
55         redraw_fixer.cpp
56         ${IVI_CON_PROTO}
57         wayland.cpp
58         wayland.hpp
59         controller_hooks.hpp
60         util.cpp
61         util.hpp)
62
63 target_include_directories(winman
64     PRIVATE
65         ${AFB_INCLUDE_DIRS}
66         ${SD_INCLUDE_DIRS}
67         ../include
68         ../src)
69
70 target_link_libraries(redraw_fixer
71         PRIVATE
72         ${WLC_LIBRARIES})
73
74 target_link_libraries(winman
75     PRIVATE
76         ${AFB_LIBRARIES}
77         ${WLC_LIBRARIES}
78         ${SD_LIBRARIES})
79
80 target_compile_definitions(winman
81     PRIVATE
82         AFB_BINDING_VERSION=2
83         # We do not want source location of messages
84         AFB_BINDING_PRAGMA_NO_VERBOSE_DETAILS
85         WINMAN_VERSION_STRING="${PACKAGE_VERSION}"
86         _GNU_SOURCE)  # XXX should I define this here?!
87
88 target_compile_definitions(redraw_fixer
89         PRIVATE
90         DO_NOT_USE_AFB   # override log* AFB macros
91         _GNU_SOURCE)
92
93 if(NOT ${CMAKE_BUILD_TYPE} STREQUAL "Release")
94    target_compile_definitions(winman
95        PRIVATE
96            _GLIBCXX_DEBUG)
97    target_compile_definitions(redraw_fixer
98            PRIVATE
99            _GLIBCXX_DEBUG)
100 endif()
101
102 target_compile_options(winman
103     PRIVATE
104         -Wall -Wextra -Wno-unused-parameter -Wno-comment)
105
106 set_target_properties(winman
107     PROPERTIES
108     # INTERPROCEDURAL_OPTIMIZATION ON
109
110         CXX_EXTENSIONS OFF
111         CXX_STANDARD 14
112         CXX_STANDARD_REQUIRED ON
113
114         C_EXTENSIONS OFF
115         C_STANDARD 99
116         C_STANDARD_REQUIRED ON
117
118         LINK_FLAGS "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../export.map")
119
120 if (LINK_LIBCXX)
121    set_target_properties(winman
122            PROPERTIES
123            LINK_FLAGS "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../export.map -lc++")
124    set_target_properties(redraw_fixer
125            PROPERTIES
126            LINK_FLAGS "-lc++")
127 endif()
128
129 if (NOT ${SANITIZER_MODE} STREQUAL "none" AND NOT ${SANITIZER_MODE} STREQUAL "")
130    target_compile_options(winman
131       PRIVATE
132          -fsanitize=${SANITIZER_MODE} -g -fno-omit-frame-pointer)
133    set_target_properties(winman
134       PROPERTIES
135          LINK_FLAGS "-fsanitize=${SANITIZER_MODE} -g")
136 endif()