~sircmpwn/xrgears

ref: 092efb2c3987349e08b648475f03ec429883c597 xrgears/CMakeLists.txt -rw-r--r-- 3.8 KiB
092efb2c — Lubosz Sarnecki add new class for text overlay renderer. 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
cmake_minimum_required(VERSION 3.8)
project(xrgears)

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

# use XCB

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

#add_cxxflag("-Wconversion")
#add_cxxflag("-Wsign-conversion")
#add_cxxflag("-Winline")
#add_cxxflag("-Weffc++")
#add_cxxflag("-Wsuggest-attribute=const")
#support ISO C++ standard (remove GNU extensions)
#add_cxxflag("-ansi")
#warnings for strict ISO C and ISO C++
#add_cxxflag("-pedantic")

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

add_definitions(-DVK_USE_PLATFORM_WAYLAND_KHR)

INCLUDE_DIRECTORIES(/usr/include/libdrm/)

function(add_verbose_warnings)
    add_cxxflag("-Werror")
    add_cxxflag("-Wall")
    add_cxxflag("-Wextra")
    add_cxxflag("-Wuninitialized")
    #add_cxxflag("-Wold-style-cast")
    add_cxxflag("-Woverloaded-virtual")
    add_cxxflag("-Wformat=2")
    add_cxxflag("-Wundef")
    add_cxxflag("-Wpointer-arith")
    add_cxxflag("-Wcast-qual")
    add_cxxflag("-Wlogical-op")
    add_cxxflag("-Woverflow")
    add_cxxflag("-Wmissing-declarations")
    add_cxxflag("-Wredundant-decls")
    add_cxxflag("-Wno-sign-compare")
    add_cxxflag("-Wno-unused-parameter")
    add_cxxflag("-Wno-delete-non-virtual-dtor")
    add_cxxflag("-Wno-cast-qual")
    add_cxxflag("-Wno-switch")
    add_cxxflag("-Wunreachable-code")
endfunction(add_verbose_warnings)

#    add_cxxflag("--coverage")

add_cxxflag("-fPIC")

# find_package(XCB REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVK_USE_PLATFORM_XCB_KHR")

file(GLOB VKS_SRC vks/*.cpp vks/*.h vks/*.hpp)
file(GLOB VITAMINK_SRC vitamin-k/*.hpp)
file(GLOB VKC_SRC vkc/*.cpp vkc/*.h vkc/*.hpp)

file(GLOB XDG_SRC xdg-shell/*.c)

add_library(xdg-shell ${XDG_SRC})

include_directories(vks)
include_directories(vkc)
include_directories(vitamin-k)
include_directories(xdg-shell)

INCLUDE_DIRECTORIES(/usr/include/openhmd/)

# 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)

set(LINT_SOURCES ${VITAMINK_SRC} ${VKS_SRC})

# Function for building single example
function(buildExample EXAMPLE_NAME)

    file(GLOB EXAMPLE_SRC examples/${EXAMPLE_NAME}/*.cpp)
    add_executable(${EXAMPLE_NAME} ${EXAMPLE_SRC})

    if (EXAMPLE_NAME STREQUAL "vkcube")
	target_link_libraries(${EXAMPLE_NAME} vulkan m wayland-client png drm
	    gbm xcb vulkan xcb xcb-keysyms assimp wayland-client gbm drm m stdc++ xdg-shell)
    else()
	set(LINT_SOURCES ${LINT_SOURCES} ${EXAMPLE_SRC})
	target_link_libraries(${EXAMPLE_NAME}
	    ${Vulkan_LIBRARY} ${ASSIMP_LIBRARIES} ${WAYLAND_CLIENT_LIBRARIES}
	    ${CMAKE_THREAD_LIBS_INIT} ${XCB_LIBRARIES} dl glfw openhmd
	    vulkan xcb xcb-keysyms assimp wayland-client gbm drm m stdc++ xdg-shell)
    endif()

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)

#add_custom_target(shaders
#        #clean and compile with 1 thread per core
#	COMMAND glslc -o gears.vert.spv gears.vert
#)


#set(IGNORE "-build/header_guard,-readability/streams,-readability/casting,-whitespace/line_length")
set(IGNORE "-build/header_guard,-build/c++11,-readability/casting")
add_custom_target(style
    COMMAND python2 ${CMAKE_SOURCE_DIR}/scripts/cpplint.py --headers=hpp --filter=${IGNORE} ${LINT_SOURCES}
    )