~andreas-strasser/lask/trunk

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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#
# CMakeLists.txt
# Copyright (C) 2012, 2013, Valama development team
#
# Valama is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Valama is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program.  If not, see <http://www.gnu.org/licenses/>.
#

cmake_minimum_required(VERSION "2.8.4")

include("${CMAKE_SOURCE_DIR}/cmake/project.cmake")
include("${CMAKE_SOURCE_DIR}/cmake/Common.cmake")
include("${CMAKE_SOURCE_DIR}/cmake/Gettext.cmake")

if(CMAKE_MAJOR_VERSION GREATER "2")
  cmake_policy(SET CMP0048 NEW)
  project("${project_name}" VERSION "${${project_name}_VERSION}" LANGUAGES "C")
else()
  project("${project_name}" "C")
endif()
string(TOLOWER "${project_name}" project_name_lower)

set(bindir "bin")
set(datarootdir "share")
set(libdir "lib")
set(includedir "include")
set(datadir "${datarootdir}/${project_name_lower}")
set(uidir "${datadir}/ui")
set(localedir "${datarootdir}/locale")
set(appdir "${datarootdir}/applications")
set(gsettingsdir "${datarootdir}/glib-2.0/schemas")
set(pixrootdir "${datarootdir}/pixmaps")
set(pixdir "${pixrootdir}/${project_name_lower}")
set(docdir "${datadir}/doc")
set(mandir "${datarootdir}/man")
set(mimedir "${datarootdir}/mime/packages")
if(CMAKE_INSTALL_PREFIX)
  set(install_prefix "${CMAKE_INSTALL_PREFIX}/")
else()
  set(install_prefix)
endif()

list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/vala")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
add_subdirectory(po)

find_package(Vala "0.20" REQUIRED)

# Custom library version checks.
set(definitions)
set(vapidirs)
find_package(PkgConfig)
# glib-2.0
pkg_check_modules(GLIB2.0 REQUIRED "glib-2.0")

# generate a source file containing build parameters a so our executable can find installed resources
list(REMOVE_ITEM required_pkgs "config {nocheck,nolink}")
set (CONFIG_FILE ${CMAKE_SOURCE_DIR}/src/config.vala)
configure_file (src/config.vala.cmake ${CONFIG_FILE})

set(default_vala_flags
  "--thread"
  "--target-glib" "${GLIB2.0_VERSION}"
  #"--enable-experimental"
  #"--fatal-warnings"
  "-D" "${CMAKE_SYSTEM_NAME}"
  "--vapidir" "../vapi"
)
link_libraries(${DEPS_LIBRARIES} -lm)
include(ValaPkgs)
vala_pkgs(VALA_C
  PACKAGES
    ${required_pkgs}
  DEFINITIONS
    ${definitions}
  OPTIONAL
    ${optional_pkgs}
  SRCFILES
    ${srcfiles}
  VAPIS
    ${vapifiles}
  OPTIONS
    ${default_vala_flags}
    ${vapidirs}
)


# Set common C-macros.
add_definitions(-DPACKAGE_NAME="${project_name}")
add_definitions(-DPACKAGE_VERSION="${${project_name}_VERSION}")
add_definitions(-DGETTEXT_PACKAGE="lask")
add_definitions(-DPACKAGE_DATA_DIR="${install_prefix}${datadir}")
add_definitions(-DPACKAGE_UI_DIR="${install_prefix}${uidir}")
add_definitions(-DLOCALE_DIR="${install_prefix}${localedir}")
add_definitions(-DPIXMAP_DIR="${install_prefix}${pixdir}")
add_definitions(-DVALA_VERSION="${VALA_SHORTVER}")

add_executable("${project_name_lower}" ${VALA_C})
target_link_libraries("${project_name_lower}"
  ${PROJECT_LDFLAGS}
)
add_definitions(
  ${PROJECT_C_FLAGS}
)
install(TARGETS ${project_name_lower} DESTINATION "${bindir}")

# Install user interface files if used and copy them to build directory.
set(uifiles_build)
foreach(uifile ${uifiles})
  add_custom_command(
    OUTPUT
      "${CMAKE_CURRENT_BINARY_DIR}/${uifile}"
    COMMAND
      "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/${uifile}" "${CMAKE_CURRENT_BINARY_DIR}/${uifile}"
    DEPENDS
      "${CMAKE_CURRENT_SOURCE_DIR}/${uifile}"
    COMMENT ""
  )
  list(APPEND uifiles_build "${CMAKE_CURRENT_BINARY_DIR}/${uifile}")
  install(FILES ${uifile} DESTINATION "${uidir}")
endforeach()
add_custom_target("ui_copy_${project_name_lower}" DEPENDS ${uifiles_build})
add_dependencies("${project_name_lower}" "ui_copy_${project_name_lower}")
# Install other stuff
install (FILES Musterbetrieb.lask   DESTINATION "${CMAKE_INSTALL_PREFIX}/share/lask")
install (FILES changelog            DESTINATION "${CMAKE_INSTALL_PREFIX}/share/lask")
install (FILES README               DESTINATION "${CMAKE_INSTALL_PREFIX}/share/lask")
install (FILES lask.svg             DESTINATION "${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/apps")
install (FILES lask.desktop         DESTINATION "${CMAKE_INSTALL_PREFIX}/share/applications")
install (FILES lask.1               DESTINATION "${CMAKE_INSTALL_PREFIX}/share/man/de/man1")

# Uninstall target
add_custom_target(uninstall
  COMMAND
    "${CMAKE_COMMAND}" -D "CUSTOM_SOURCE_DIR:FILEPATH=${CMAKE_SOURCE_DIR}"
                       -D "POSTREMOVE_HOOK:BOOL=${POSTINSTALL_HOOK}"
                       -D "GSETTINGSDIR:FILEPATH=${install_prefix}${gsettingsdir}"
                       -P "${CMAKE_SOURCE_DIR}/cmake/SimpleUninstall.cmake"
)


# Print some information about build.
datestring(current_date "%F %T")
message("")
message("---------------------------------------------")
message("                          ${current_date}")
message("${project_name} ${${project_name}_VERSION}")
message("")
if(CMAKE_BUILD_TYPE)
  message("Build type: ${CMAKE_BUILD_TYPE}")
  string(TOUPPER "${CMAKE_BUILD_TYPE}" release_upper)
  set(c_flags "${CMAKE_C_FLAGS_${release_upper}}")
else()
  message("Build type: Default")
  set(c_flags "${CMAKE_C_FLAGS}")
endif()
message("")
message("Installation prefix:    ${CMAKE_INSTALL_PREFIX}")
foreach(def ${definitions})
  list(APPEND default_vala_flags "-D;${def}")
endforeach()
base_list_to_delimited_string(vala_flags
  DELIM " "
  BASE_LIST "${default_vala_flags}"
)
message("C compiler:             ${CMAKE_C_COMPILER}")
message("C compiler version      ${CMAKE_C_COMPILER_VERSION}")
if("${c_flags}" STREQUAL "")
  set(c_flags "(none)")
endif()
message("C flags:                ${c_flags}")
message("Vala compiler:          ${VALA_EXECUTABLE}")
message("Vala compiler version:  ${VALA_VERSION}")
if("${vala_flags}" STREQUAL "")
  set(vala_flags "(none)")
endif()
message("Vala flags:             ${vala_flags}")
message("GLib version:           ${GLIB2.0_VERSION}")
message("")
  if(GETTEXT_PACKAGE_VERSION)
    message("Gettext package:        ${GETTEXT_PACKAGE_NAME} (${GETTEXT_PACKAGE_VERSION})")
  else()
    message("Gettext package:        ${GETTEXT_PACKAGE_NAME}")
  endif()
if(CMAKE_VERBOSE_MAKEFILE)
  message("Verbose build:          yes")
else()
  message("Verbose build:          no")
endif()
message("")
message("---------------------------------------------")
message("")

# vim: set ai ts=2 sts=2 et sw=2