~sircmpwn/xrgears

ref: 04a78fdd25967ed8f104e5c0b1e0589588d6c776 xrgears/CMakeLists.txt -rw-r--r-- 3.9 KiB
04a78fdd — Lubosz Sarnecki overlay: fix validation warnings. 4 years ago
                                                                                
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
cmake_minimum_required(VERSION 3.8)
project(xrgears)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/")


function(add_cxxflag FLAG)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAG}" PARENT_SCOPE)
endfunction(add_cxxflag)

add_definitions(-DVK_USE_PLATFORM_WAYLAND_KHR)
add_definitions(-DVK_USE_PLATFORM_XCB_KHR)

add_cxxflag("-std=c++14")

# warnings
# add_cxxflag("-Werror")

add_cxxflag("-Wall")
add_cxxflag("-Wcast-qual")
add_cxxflag("-Wformat=2")
add_cxxflag("-Winline")
add_cxxflag("-Wlogical-op")
add_cxxflag("-Wmissing-declarations")
add_cxxflag("-Wno-cast-qual")
add_cxxflag("-Wno-delete-non-virtual-dtor")
add_cxxflag("-Wno-sign-compare")
add_cxxflag("-Wno-switch")
add_cxxflag("-Wno-unused-parameter")
add_cxxflag("-Woverflow")
add_cxxflag("-Woverloaded-virtual")
add_cxxflag("-Wpointer-arith")
add_cxxflag("-Wredundant-decls")
add_cxxflag("-Wsuggest-attribute=const")
add_cxxflag("-Wundef")
add_cxxflag("-Wuninitialized")
add_cxxflag("-Wunreachable-code")

# not fixed
#add_cxxflag("-Wconversion")
#add_cxxflag("-Weffc++")
#add_cxxflag("-Wextra")
#add_cxxflag("-Wold-style-cast")
#add_cxxflag("-Wsign-conversion")

# gcc coverage stats
#add_cxxflag("--coverage")


find_package(PkgConfig REQUIRED)

pkg_search_module(VULKAN REQUIRED vulkan)
pkg_search_module(OPENHMD REQUIRED openhmd)
pkg_search_module(ASSIMP REQUIRED assimp)
pkg_search_module(XCB REQUIRED xcb)
pkg_search_module(XCB_KEY REQUIRED xcb-keysyms)
pkg_search_module(XCB_RANDR REQUIRED xcb-randr)
pkg_search_module(WAYLAND REQUIRED wayland-client)
pkg_search_module(GBM REQUIRED gbm)
pkg_search_module(DRM REQUIRED libdrm)

file(GLOB VITAMINK_SRC vitamin-k/*.hpp)
file(GLOB XDG_SRC xdg-shell/*.c)

add_library(xdg-shell ${XDG_SRC})

include_directories(
    ${CMAKE_SOURCE_DIR}/vitamin-k
    ${CMAKE_SOURCE_DIR}/xdg-shell
    ${OPENHMD_INCLUDE_DIRS}
    ${DRM_INCLUDE_DIRS})

# glslc -o gears.vert.spv gears.vert

file(GLOB_RECURSE SHADER_GLOB
    ${CMAKE_SOURCE_DIR}/data/shaders/*.vert
    ${CMAKE_SOURCE_DIR}/data/shaders/*.frag
    ${CMAKE_SOURCE_DIR}/data/shaders/*.geom)

# build shaders
foreach(SHADER ${SHADER_GLOB})
    message("Compiling SPV shader for ${SHADER}")
    execute_process(
	WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/data/shaders
	COMMAND glslc -o ${SHADER}.spv ${SHADER}
	)
endforeach(SHADER)

file(GLOB_RECURSE VITAMINK_SRC vitamin-k/*.hpp)
add_library(vitamin-k ${VITAMINK_SRC})
SET_TARGET_PROPERTIES(vitamin-k  PROPERTIES LINKER_LANGUAGE CXX)
set(LINT_SOURCES ${VITAMINK_SRC})

pkg_search_module(VULKAN REQUIRED vulkan)
pkg_search_module(OPENHMD REQUIRED openhmd)
pkg_search_module(ASSIMP REQUIRED assimp)
pkg_search_module(XCB REQUIRED xcb-keysyms)
pkg_search_module(WAYLAND REQUIRED wayland-client)
pkg_search_module(GBM REQUIRED gbm)
pkg_search_module(DRM REQUIRED libdrm)

set(EXAMPLE_LIBS
    ${VULKAN_LIBRARIES}
    ${OPENHMD_LIBRARIES}
    ${ASSIMP_LIBRARIES}
    ${XCB_LIBRARIES}
    ${XCB_KEY_LIBRARIES}
    ${WAYLAND_LIBRARIES}
    xdg-shell
    ${GBM_LIBRARIES}
    ${XCB_RANDR_LIBRARIES}
    ${DRM_LIBRARIES})

# Function for building single example
function(buildExample EXAMPLE_NAME)
    file(GLOB EXAMPLE_SRC examples/${EXAMPLE_NAME}/*.cpp)
    add_executable(${EXAMPLE_NAME} ${EXAMPLE_SRC})
    set(LINT_SOURCES ${LINT_SOURCES} ${EXAMPLE_SRC} PARENT_SCOPE)
    target_link_libraries(${EXAMPLE_NAME} ${EXAMPLE_LIBS})
endfunction(buildExample)

# build examples
FILE(GLOB EXAMPLE_DIRS RELATIVE
    ${CMAKE_SOURCE_DIR}/examples
    ${CMAKE_SOURCE_DIR}/examples/*)

# Build all examples
foreach(EXAMPLE ${EXAMPLE_DIRS})
    if (EXAMPLE STREQUAL "glfw-test")
	message("skipping glfw test for now.")
    else()
	buildExample(${EXAMPLE})
    endif()
endforeach(EXAMPLE)

set(IGNORE
    "-build/c++11,"
    "-build/header_guard,"
    "-readability/casting,"
    "-whitespace/line_length,"
    "-whitespace/parens")

add_custom_target(style COMMAND
    python2 ${CMAKE_SOURCE_DIR}/scripts/cpplint.py --headers=hpp --filter="${IGNORE}" ${LINT_SOURCES})