464af6fcdbaf697986d0632bac863f769bc1b942
[staging/windowmanager.git] / 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 cmake_minimum_required(VERSION 2.8)
18
19 project(WindowManagerTMC)
20
21 set(PACKAGE_VERSION_MAJOR 0)
22 set(PACKAGE_VERSION_MINOR 0)
23 set(PACKAGE_VERSION_REVISION 1)
24 set(PACKAGE_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_REVISION}")
25
26 find_package(PkgConfig REQUIRED)
27 include(GNUInstallDirs)
28
29 pkg_check_modules(WLC wayland-client>=1.11.0 REQUIRED)
30
31 macro(wlproto var_basename proto_xml_basename)
32    if("${WLSCAN}" STREQUAL "")
33       find_program(WLSCAN NAMES wayland-scanner)
34    endif()
35
36    if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/protocol)
37       set(proto_dir "${CMAKE_CURRENT_SOURCE_DIR}/protocol")
38    elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../protocol)
39       set(proto_dir "${CMAKE_CURRENT_SOURCE_DIR}/../protocol")
40    else()
41       message(FATAL_ERROR "Could not find ${CMAKE_CURRENT_SOURCE_DIR}/protocol or ${CMAKE_CURRENT_SOURCE_DIR}/../protocol")
42    endif()
43
44    add_custom_command(
45       OUTPUT
46          ${proto_xml_basename}-protocol.c
47          #${proto_xml_basename}-server-protocol.h
48          ${proto_xml_basename}-client-protocol.h
49       MAIN_DEPENDENCY ${proto_dir}/${proto_xml_basename}.xml
50       COMMAND ${WLSCAN} code <          ${proto_dir}/${proto_xml_basename}.xml > ${proto_xml_basename}-protocol.c
51       #COMMAND ${WLSCAN} server-header < ${proto_dir}/${proto_xml_basename}.xml > ${proto_xml_basename}-server-protocol.h
52       COMMAND ${WLSCAN} client-header < ${proto_dir}/${proto_xml_basename}.xml > ${proto_xml_basename}-client-protocol.h
53    )
54
55    set(${var_basename}_PROTO ${CMAKE_CURRENT_BINARY_DIR}/${proto_xml_basename}-protocol.c)
56    set(${var_basename}_CLIENT ${CMAKE_CURRENT_BINARY_DIR}/${proto_xml_basename}-client-protocol.h)
57    #set(${var_basename}_SERVER ${CMAKE_CURRENT_BINARY_DIR}/${proto_xml_basename}-server-protocol.h)
58
59    include_directories(${CMAKE_CURRENT_BINARY_DIR})
60 endmacro()
61
62 # Should modernize the following somehow...
63 set(ENABLE_DEBUG_OUTPUT OFF CACHE BOOL "Enable debug logging")
64 if(ENABLE_DEBUG_OUTPUT)
65    add_definitions(-DDEBUG_OUTPUT)
66 else()
67    remove_definitions(-DDEBUG_OUTPUT)
68 endif()
69
70 # Should modernize the following somehow...
71 set(ENABLE_SCOPE_TRACING OFF CACHE BOOL "Enable scope enter/leave messages for certain parts of the code.")
72 if(ENABLE_SCOPE_TRACING)
73    add_definitions(-DSCOPE_TRACING)
74 else()
75    remove_definitions(-DSCOPE_TRACING)
76 endif()
77
78 set(SANITIZER_MODE "none" CACHE STRING "Build using a specific sanitizer (e.g. 'address', 'thread', 'leak', 'undefined'), depends on compiler; default none")
79
80 set(LINK_LIBCXX OFF CACHE BOOL "Link against LLVMs libc++")
81
82 add_subdirectory(client-lib)
83 add_subdirectory(src)
84 add_subdirectory(doc)
85
86 install(
87    FILES layers.json
88    DESTINATION /etc
89    COMPONENT "runtime")