~ter0/+junk/reader

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
# project name
project (reader)

# the oldest stable cmake version we support
cmake_minimum_required (VERSION 2.8)

# tell cmake where its modules can be found in our project directory
list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)

# where we install data directory (if we have any)
set (DATADIR "${CMAKE_INSTALL_PREFIX}/share")

# what to call that directory where we install data too
set (PKGDATADIR "${DATADIR}/reader")

set (RELEASE_NAME "reader")
set (VERSION "0.0")
set (VERSION_INFO "")

# configure
configure_file (${CMAKE_SOURCE_DIR}/src/Config.vala.cmake ${CMAKE_SOURCE_DIR}/src/config.vala)

# install some data to a specific place
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/reader.css DESTINATION ${DATADIR}/reader/)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/reader.desktop DESTINATION ${DATADIR}/applications/)

# we're about to use pkgconfig to make sure dependencies are installed so let's find pkgconfig first
find_package(PkgConfig)

# now let's actually check for the required dependencies
pkg_check_modules(DEPS REQUIRED gtk+-3.0 granite)

add_definitions(${DEPS_CFLAGS})
link_directories(${DEPS_LIBRARY_DIRS})

# make sure we have vala
find_package(Vala REQUIRED)
# make sure we use vala
include(ValaVersion)
# make sure it's the desired version of vala
ensure_vala_version("0.16.1" MINIMUM)

# start files we want to compile
include(ValaPrecompile)
vala_precompile(VALA_C reader
    src/config.vala
    src/main.vala
    src/Reader.vala
# tell what libraries to use when compiling
PACKAGES
    gtk+-3.0
    granite
)

# tell cmake what to call the executable we just made (not 100% sure about this)
add_executable(reader ${VALA_C})

#We need to link the libraries with our Executable.
target_link_libraries(reader ${DEPS_LIBRARIES})

# install our binaries we just made
install (TARGETS reader RUNTIME DESTINATION bin)