-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
112 lines (91 loc) · 2.28 KB
/
CMakeLists.txt
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
project(valagl C)
cmake_minimum_required(VERSION 3.10)
# Change version number on release
set(PROJECT_VERSION "0.1.0")
set(COMMON_DATA_DIR ${CMAKE_INSTALL_PREFIX}/share)
set(PROJECT_DATA_DIR ${CMAKE_INSTALL_PREFIX}/share/${CMAKE_PROJECT_NAME})
list(APPEND CMAKE_MODULE_PATH
${CMAKE_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/cmake
)
option(BUILD_VALADOC "Build API documentation if Valadoc is available" ON)
set(VALA_REQUIRED_VERSION 0.48)
set(GLIB_REQUIRED_VERSION 2.30.0)
set(GTK_REQUIRED_VERSION 3.0.0)
# Use GLVND, the modern OpenGL ABI
set(OpenGL_GL_PREFERENCE GLVND)
find_package(PkgConfig REQUIRED)
find_package(Vala REQUIRED)
find_package(GLib REQUIRED)
find_package(SDL2 REQUIRED)
find_package(OpenGL REQUIRED)
pkg_check_modules(EPOXY REQUIRED epoxy)
set(HAVE_VALADOC OFF)
if(BUILD_VALADOC)
find_package(Valadoc)
if(VALADOC_FOUND)
set(HAVE_VALADOC ON)
include(Valadoc)
else()
message("Valadoc not found, will not build documentation")
endif()
endif()
include(ValaVersion)
include(ValaPrecompile)
include(sources)
ensure_vala_version(${VALA_REQUIRED_VERSION} MINIMUM)
file (READ ${CMAKE_SOURCE_DIR}/AUTHORS PROJECT_AUTHORS)
string (REPLACE "\n" "\\n\\\n" PROJECT_AUTHORS ${PROJECT_AUTHORS})
configure_file(${CMAKE_SOURCE_DIR}/cmake/config.h.in ${CMAKE_BINARY_DIR}/config.h @ONLY)
set(CUSTOM_VAPIS
# VAPI containing install definitions, mapping from cmake generated config.h
${CMAKE_SOURCE_DIR}/vapi/AppConfig.vapi
# Order is important! GLEW must come before GL and GLU.
${CMAKE_SOURCE_DIR}/vapi/gl.vapi
${CMAKE_SOURCE_DIR}/vapi/glu.vapi
${CMAKE_SOURCE_DIR}/vapi/sdl2.vapi
)
set(VALA_PACKAGES
gio-2.0
glib-2.0
)
vala_precompile(VALA_C
${APP_SOURCES}
CUSTOM_VAPIS
${CUSTOM_VAPIS}
PACKAGES
${VALA_PACKAGES}
OPTIONS
-g
)
include_directories(
${GLIB_ALL_INCLUDES}
${SDL2_INCLUDE_DIR}
${EPOXY_INCLUDE_PATH}
${OPENGL_INCLUDE_DIR}
${CMAKE_BINARY_DIR}
)
add_definitions(
${GLIB_ALL_CFLAGS}
${EPOXY_CFLAGS_OTHER}
-DNO_SDL_GLEXT
)
add_executable(${CMAKE_PROJECT_NAME} ${VALA_C})
target_link_libraries(${CMAKE_PROJECT_NAME}
${GLIB_ALL_LIBS}
${EPOXY_LIBRARIES}
${SDL2_LIBRARIES}
${OPENGL_LIBRARIES}
-lm
)
if(HAVE_VALADOC)
valadoc(${CMAKE_PROJECT_NAME}
${CMAKE_BINARY_DIR}/valadoc
${APP_SOURCES}
CUSTOM_VAPIS
${CUSTOM_VAPIS}
PACKAGES
${VALA_PACKAGES}
)
endif()
include(install)