Merge lp:~xapantu/slingshot/cmake into lp:~elementary-pantheon/slingshot/slingshot
- cmake
- Merge into slingshot
Proposed by
xapantu
Status: | Merged |
---|---|
Merge reported by: | Giulio Collura |
Merged at revision: | not available |
Proposed branch: | lp:~xapantu/slingshot/cmake |
Merge into: | lp:~elementary-pantheon/slingshot/slingshot |
Diff against target: |
691 lines (+632/-7) 10 files modified
.bzrignore (+1/-0) CMakeLists.txt (+53/-0) INSTALL (+30/-0) README (+3/-0) build_run (+0/-7) cmake/Vala_CMake/README.rst (+173/-0) cmake/vala/FindVala.cmake (+65/-0) cmake/vala/ParseArguments.cmake (+36/-0) cmake/vala/ValaPrecompile.cmake (+175/-0) cmake/vala/ValaVersion.cmake (+96/-0) |
To merge this branch: | bzr merge lp:~xapantu/slingshot/cmake |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Giulio Collura (community) | Approve | ||
Review via email: mp+50905@code.launchpad.net |
Commit message
Description of the change
I have just added a proper build system (with cmake), all is explained in README.
mkdir build
cd build
cmake ..
make
./slingshot
And you can also use:
make install
slingshot
To post a comment you must log in.
Revision history for this message
Giulio Collura (gcollura) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added file '.bzrignore' |
2 | --- .bzrignore 1970-01-01 00:00:00 +0000 |
3 | +++ .bzrignore 2011-02-23 11:26:02 +0000 |
4 | @@ -0,0 +1,1 @@ |
5 | +build |
6 | |
7 | === added file 'CMakeLists.txt' |
8 | --- CMakeLists.txt 1970-01-01 00:00:00 +0000 |
9 | +++ CMakeLists.txt 2011-02-23 11:26:02 +0000 |
10 | @@ -0,0 +1,53 @@ |
11 | +# The name of our project is "HELLO". CMakeLists files in this project can |
12 | +# refer to the root source directory of the project as ${HELLO_SOURCE_DIR} and |
13 | +# to the root binary directory of the project as ${HELLO_BINARY_DIR}. |
14 | +cmake_minimum_required (VERSION 2.6) |
15 | +project (Slingshot) |
16 | + |
17 | +list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/vala ) |
18 | +# Recurse into the "Hello" and "Demo" subdirectories. This does not actually |
19 | +# cause another cmake executable to run. The same process will walk through |
20 | +# the project's entire directory structure. |
21 | + |
22 | +#add_subdirectory (src) |
23 | + |
24 | +find_package(PkgConfig) |
25 | +pkg_check_modules(DEPS REQUIRED unique-1.0 gtk+-2.0 gee-1.0 gio-unix-2.0 libgnome-menu libwnck-1.0) |
26 | + |
27 | +add_definitions(${DEPS_CFLAGS}) |
28 | + |
29 | +link_libraries(${DEPS_LIBRARIES}) |
30 | + |
31 | +link_directories(${DEPS_LIBRARY_DIRS}) |
32 | + |
33 | +find_package(Vala REQUIRED) |
34 | +include(ValaVersion) |
35 | +ensure_vala_version("0.10.0" MINIMUM) |
36 | + |
37 | +include(ValaPrecompile) |
38 | +vala_precompile(VALA_C |
39 | + slingshot.vala |
40 | + frontend/widgets/AppItem.vala |
41 | + frontend/widgets/CompositedWindow.vala |
42 | + frontend/widgets/Grid.vala |
43 | + frontend/widgets/Indicators.vala |
44 | + frontend/widgets/Searchbar.vala |
45 | + frontend/Utilities.vala |
46 | + frontend/Color.vala |
47 | + backend/GMenuEntries.vala |
48 | +PACKAGES |
49 | + gtk+-2.0 |
50 | + gee-1.0 |
51 | + gio-unix-2.0 |
52 | + libgnome-menu |
53 | + libwnck-1.0 |
54 | + unique-1.0 |
55 | +OPTIONS |
56 | + --thread |
57 | + ) |
58 | + |
59 | +add_definitions(${CFLAGS} -Wall -Winit-self -Wwrite-strings -Wunreachable-code |
60 | + -Wstrict-prototypes -DGMENU_I_KNOW_THIS_IS_UNSTABLE -DWNCK_I_KNOW_THIS_IS_UNSTABLE ) |
61 | +add_executable(slingshot ${VALA_C}) |
62 | + |
63 | +install(TARGETS slingshot RUNTIME DESTINATION bin) |
64 | |
65 | === added file 'INSTALL' |
66 | --- INSTALL 1970-01-01 00:00:00 +0000 |
67 | +++ INSTALL 2011-02-23 11:26:02 +0000 |
68 | @@ -0,0 +1,30 @@ |
69 | +To install Slingshot from the source, you need to compile it. |
70 | + |
71 | +== Compilation == |
72 | + |
73 | +- First, we need a build directory: |
74 | + mkdir build |
75 | + cd build |
76 | +- Then, configure CMake: |
77 | + cmake .. |
78 | + Here, you can get some errors if you don't have all the dependencies. |
79 | +- Compile it: |
80 | + make |
81 | + You can also use make -j3 if you have a dual core. (it will be much faster) |
82 | + |
83 | +== Launch Slingshot == |
84 | + |
85 | +- Just run slingshot: |
86 | + ./slingshot |
87 | + |
88 | +== Install Slingshot == |
89 | + |
90 | +- With the administrator rights, use: |
91 | + make install |
92 | + Or: |
93 | + sudo make install |
94 | + |
95 | +- You can now launch Slingshot using: |
96 | + slingshot |
97 | + Or: |
98 | + /usr/local/bin/slingshot |
99 | |
100 | === added file 'README' |
101 | --- README 1970-01-01 00:00:00 +0000 |
102 | +++ README 2011-02-23 11:26:02 +0000 |
103 | @@ -0,0 +1,3 @@ |
104 | +Slingshot is a lightweight app launcher for Elementary, written in Vala and utilizing GTK+ and Cairo. |
105 | + |
106 | +Under GNU GPL v3 |
107 | |
108 | === removed file 'build_run' |
109 | --- build_run 2011-02-12 12:16:02 +0000 |
110 | +++ build_run 1970-01-01 00:00:00 +0000 |
111 | @@ -1,7 +0,0 @@ |
112 | -#!/bin/sh |
113 | - |
114 | -valac --pkg gtk+-2.0 --pkg unique-1.0 --pkg gee-1.0 --pkg gio-unix-2.0 --pkg libgnome-menu --Xcc='-DGMENU_I_KNOW_THIS_IS_UNSTABLE' --pkg libwnck-1.0 --Xcc='-DWNCK_I_KNOW_THIS_IS_UNSTABLE' slingshot.vala frontend/widgets/*.vala frontend/*.vala backend/*.vala |
115 | - |
116 | -sudo mv slingshot /usr/bin |
117 | - |
118 | -slingshot |
119 | |
120 | === added directory 'cmake' |
121 | === added directory 'cmake/Vala_CMake' |
122 | === added file 'cmake/Vala_CMake/README.rst' |
123 | --- cmake/Vala_CMake/README.rst 1970-01-01 00:00:00 +0000 |
124 | +++ cmake/Vala_CMake/README.rst 2011-02-23 11:26:02 +0000 |
125 | @@ -0,0 +1,173 @@ |
126 | +========== |
127 | +Vala CMake |
128 | +========== |
129 | +:Author: |
130 | + Jakob Westhoff |
131 | +:Version: |
132 | + Draft |
133 | + |
134 | + |
135 | +Overview |
136 | +======== |
137 | + |
138 | +Vala CMake is a collection of macros for the CMake_ build system to allow the |
139 | +creation and management of projects developed using the Vala_ programming |
140 | +language or its "Genie" flavor (less tested). |
141 | + |
142 | + |
143 | +Installation |
144 | +============ |
145 | + |
146 | +To use the Vala macros in your own project you need to copy the macro files to |
147 | +an arbitrary folder in your projects directory and reference them in your |
148 | +``CMakeLists.txt`` file. |
149 | + |
150 | +Assuming the macros are stored under ``cmake/vala`` in your projects folder you |
151 | +need to add the following information to your base ``CMakeLists.txt``:: |
152 | + |
153 | + list(APPEND CMAKE_MODULE_PATH |
154 | + ${CMAKE_SOURCE_DIR}/cmake/vala |
155 | + ) |
156 | + |
157 | +After the new module path as been added you can simply include the provided |
158 | +modules or use the provided find routines. |
159 | + |
160 | + |
161 | +Finding Vala |
162 | +============ |
163 | + |
164 | +The find module for vala works like any other Find module in CMake. |
165 | +You can use it by simply calling the usual ``find_package`` function. Default |
166 | +parameters like ``REQUIRED`` and ``QUIETLY`` are supported. |
167 | + |
168 | +:: |
169 | + |
170 | + find_package(Vala REQUIRED) |
171 | + |
172 | +After a successful call to the find_package function the following variables |
173 | +will be set: |
174 | + |
175 | +VALA_FOUND |
176 | + Whether the vala compiler has been found or not |
177 | + |
178 | +VALA_EXECUTABLE |
179 | + Full path to the valac executable if it has been found |
180 | + |
181 | +VALA_VERSION |
182 | + Version number of the available valac |
183 | + |
184 | + |
185 | +Precompiling Vala sources |
186 | +========================= |
187 | + |
188 | +CMake is mainly supposed to handle c or c++ based projects. Luckily every vala |
189 | +program is translated into plain c code using the vala compiler, followed by |
190 | +normal compilation of the generated c program using gcc. |
191 | + |
192 | +The macro ``vala_precompile`` uses that fact to create c files from your .vala |
193 | +sources for further CMake processing. |
194 | + |
195 | +The first parameter provided is a variable, which will be filled with a list of |
196 | +c files outputted by the vala compiler. This list can than be used in |
197 | +conjunction with functions like ``add_executable`` or others to create the |
198 | +necessary compile rules with CMake. |
199 | + |
200 | +The initial variable is followed by a list of .vala files to be compiled. |
201 | +Please take care to add every vala file belonging to the currently compiled |
202 | +project or library as Vala will otherwise not be able to resolve all |
203 | +dependencies. |
204 | + |
205 | +The following sections may be specified afterwards to provide certain options |
206 | +to the vala compiler: |
207 | + |
208 | +PACKAGES |
209 | + A list of vala packages/libraries to be used during the compile cycle. The |
210 | + package names are exactly the same, as they would be passed to the valac |
211 | + "--pkg=" option. |
212 | + |
213 | +OPTIONS |
214 | + A list of optional options to be passed to the valac executable. This can be |
215 | + used to pass "--thread" for example to enable multi-threading support. |
216 | + |
217 | +DIRECTORY |
218 | + Specify the directory where the output source files will be stored. If |
219 | + ommitted, the source files will be stored in CMAKE_CURRENT_BINARY_DIR. |
220 | + |
221 | +CUSTOM_VAPIS |
222 | + A list of custom vapi files to be included for compilation. This can be |
223 | + useful to include freshly created vala libraries without having to install |
224 | + them in the system. |
225 | + |
226 | +GENERATE_VAPI |
227 | + Pass all the needed flags to the compiler to create an internal vapi for |
228 | + the compiled library. The provided name will be used for this and a |
229 | + <provided_name>.vapi file will be created. |
230 | + |
231 | +GENERATE_HEADER |
232 | + Let the compiler generate a header file for the compiled code. There will |
233 | + be a header file as well as an internal header file being generated called |
234 | + <provided_name>.h and <provided_name>_internal.h |
235 | + |
236 | +The following call is a simple example to the vala_precompile macro showing an |
237 | +example to every of the optional sections:: |
238 | + |
239 | + vala_precompile(VALA_C |
240 | + source1.vala |
241 | + source2.vala |
242 | + source3.vala |
243 | + PACKAGES |
244 | + gtk+-2.0 |
245 | + gio-1.0 |
246 | + posix |
247 | + OPTIONS |
248 | + --thread |
249 | + CUSTOM_VAPIS |
250 | + some_vapi.vapi |
251 | + GENERATE_VAPI |
252 | + myvapi |
253 | + GENERATE_HEADER |
254 | + myheader |
255 | + ) |
256 | + |
257 | +Most important is the variable VALA_C which will contain all the generated c |
258 | +file names after the call. The easiest way to use this information is to tell |
259 | +CMake to create an executable out of it. |
260 | + |
261 | +:: |
262 | + |
263 | + add_executable(myexecutable ${VALA_C}) |
264 | + |
265 | + |
266 | +Further reading |
267 | +=============== |
268 | + |
269 | +The `Pdf Presenter Console`__ , which is a vala based project of mine, makes |
270 | +heavy usage of the here described macros. To look at a real world example of |
271 | +these macros the mentioned project is the right place to take a look. The svn |
272 | +trunk of it can be found at:: |
273 | + |
274 | + svn://pureenergy.cc/pdf_presenter_console/trunk |
275 | + |
276 | + |
277 | +__ http://westhoffswelt.de/projects/pdf_presenter_console.html |
278 | + |
279 | + |
280 | +Acknowledgments |
281 | +=============== |
282 | + |
283 | +Thanks go out to Florian Sowade, a fellow local PHP-Usergroupie, who helped me |
284 | +a lot with the initial version of this macros and always answered my mostly |
285 | +dumb CMake questions. |
286 | + |
287 | +.. _CMake: http://cmake.org |
288 | +.. _Vala: http://live.gnome.org/Vala |
289 | +.. _Genie: http://live.gnome.org/Genie |
290 | + |
291 | + |
292 | + |
293 | |
294 | +.. |
295 | + Local Variables: |
296 | + mode: rst |
297 | + fill-column: 79 |
298 | + End: |
299 | + vim: et syn=rst tw=79 |
300 | |
301 | === added directory 'cmake/vala' |
302 | === added file 'cmake/vala/FindVala.cmake' |
303 | --- cmake/vala/FindVala.cmake 1970-01-01 00:00:00 +0000 |
304 | +++ cmake/vala/FindVala.cmake 2011-02-23 11:26:02 +0000 |
305 | @@ -0,0 +1,65 @@ |
306 | +## |
307 | +# Copyright 2009-2010 Jakob Westhoff. All rights reserved. |
308 | +# |
309 | +# Redistribution and use in source and binary forms, with or without |
310 | +# modification, are permitted provided that the following conditions are met: |
311 | +# |
312 | +# 1. Redistributions of source code must retain the above copyright notice, |
313 | +# this list of conditions and the following disclaimer. |
314 | +# |
315 | +# 2. Redistributions in binary form must reproduce the above copyright notice, |
316 | +# this list of conditions and the following disclaimer in the documentation |
317 | +# and/or other materials provided with the distribution. |
318 | +# |
319 | +# THIS SOFTWARE IS PROVIDED BY JAKOB WESTHOFF ``AS IS'' AND ANY EXPRESS OR |
320 | +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
321 | +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
322 | +# EVENT SHALL JAKOB WESTHOFF OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
323 | +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
324 | +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
325 | +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
326 | +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
327 | +# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
328 | +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
329 | +# |
330 | +# The views and conclusions contained in the software and documentation are those |
331 | +# of the authors and should not be interpreted as representing official policies, |
332 | +# either expressed or implied, of Jakob Westhoff |
333 | +## |
334 | + |
335 | +## |
336 | +# Find module for the Vala compiler (valac) |
337 | +# |
338 | +# This module determines wheter a Vala compiler is installed on the current |
339 | +# system and where its executable is. |
340 | +# |
341 | +# Call the module using "find_package(Vala) from within your CMakeLists.txt. |
342 | +# |
343 | +# The following variables will be set after an invocation: |
344 | +# |
345 | +# VALA_FOUND Whether the vala compiler has been found or not |
346 | +# VALA_EXECUTABLE Full path to the valac executable if it has been found |
347 | +# VALA_VERSION Version number of the available valac |
348 | +## |
349 | + |
350 | + |
351 | +# Search for the valac executable in the usual system paths. |
352 | +find_program(VALA_EXECUTABLE |
353 | + NAMES valac) |
354 | + |
355 | +# Handle the QUIETLY and REQUIRED arguments, which may be given to the find call. |
356 | +# Furthermore set VALA_FOUND to TRUE if Vala has been found (aka. |
357 | +# VALA_EXECUTABLE is set) |
358 | + |
359 | +include(FindPackageHandleStandardArgs) |
360 | +find_package_handle_standard_args(Vala DEFAULT_MSG VALA_EXECUTABLE) |
361 | + |
362 | +mark_as_advanced(VALA_EXECUTABLE) |
363 | + |
364 | +# Determine the valac version |
365 | +if(VALA_FOUND) |
366 | + execute_process(COMMAND ${VALA_EXECUTABLE} "--version" |
367 | + OUTPUT_VARIABLE "VALA_VERSION") |
368 | + string(REPLACE "Vala" "" "VALA_VERSION" ${VALA_VERSION}) |
369 | + string(STRIP ${VALA_VERSION} "VALA_VERSION") |
370 | +endif(VALA_FOUND) |
371 | |
372 | === added file 'cmake/vala/ParseArguments.cmake' |
373 | --- cmake/vala/ParseArguments.cmake 1970-01-01 00:00:00 +0000 |
374 | +++ cmake/vala/ParseArguments.cmake 2011-02-23 11:26:02 +0000 |
375 | @@ -0,0 +1,36 @@ |
376 | +## |
377 | +# This is a helper Macro to parse optional arguments in Macros/Functions |
378 | +# It has been taken from the public CMake wiki. |
379 | +# See http://www.cmake.org/Wiki/CMakeMacroParseArguments for documentation and |
380 | +# licensing. |
381 | +## |
382 | +macro(parse_arguments prefix arg_names option_names) |
383 | + set(DEFAULT_ARGS) |
384 | + foreach(arg_name ${arg_names}) |
385 | + set(${prefix}_${arg_name}) |
386 | + endforeach(arg_name) |
387 | + foreach(option ${option_names}) |
388 | + set(${prefix}_${option} FALSE) |
389 | + endforeach(option) |
390 | + |
391 | + set(current_arg_name DEFAULT_ARGS) |
392 | + set(current_arg_list) |
393 | + foreach(arg ${ARGN}) |
394 | + set(larg_names ${arg_names}) |
395 | + list(FIND larg_names "${arg}" is_arg_name) |
396 | + if(is_arg_name GREATER -1) |
397 | + set(${prefix}_${current_arg_name} ${current_arg_list}) |
398 | + set(current_arg_name ${arg}) |
399 | + set(current_arg_list) |
400 | + else(is_arg_name GREATER -1) |
401 | + set(loption_names ${option_names}) |
402 | + list(FIND loption_names "${arg}" is_option) |
403 | + if(is_option GREATER -1) |
404 | + set(${prefix}_${arg} TRUE) |
405 | + else(is_option GREATER -1) |
406 | + set(current_arg_list ${current_arg_list} ${arg}) |
407 | + endif(is_option GREATER -1) |
408 | + endif(is_arg_name GREATER -1) |
409 | + endforeach(arg) |
410 | + set(${prefix}_${current_arg_name} ${current_arg_list}) |
411 | +endmacro(parse_arguments) |
412 | |
413 | === added file 'cmake/vala/ValaPrecompile.cmake' |
414 | --- cmake/vala/ValaPrecompile.cmake 1970-01-01 00:00:00 +0000 |
415 | +++ cmake/vala/ValaPrecompile.cmake 2011-02-23 11:26:02 +0000 |
416 | @@ -0,0 +1,175 @@ |
417 | +## |
418 | +# Copyright 2009-2010 Jakob Westhoff. All rights reserved. |
419 | +# |
420 | +# Redistribution and use in source and binary forms, with or without |
421 | +# modification, are permitted provided that the following conditions are met: |
422 | +# |
423 | +# 1. Redistributions of source code must retain the above copyright notice, |
424 | +# this list of conditions and the following disclaimer. |
425 | +# |
426 | +# 2. Redistributions in binary form must reproduce the above copyright notice, |
427 | +# this list of conditions and the following disclaimer in the documentation |
428 | +# and/or other materials provided with the distribution. |
429 | +# |
430 | +# THIS SOFTWARE IS PROVIDED BY JAKOB WESTHOFF ``AS IS'' AND ANY EXPRESS OR |
431 | +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
432 | +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
433 | +# EVENT SHALL JAKOB WESTHOFF OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
434 | +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
435 | +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
436 | +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
437 | +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
438 | +# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
439 | +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
440 | +# |
441 | +# The views and conclusions contained in the software and documentation are those |
442 | +# of the authors and should not be interpreted as representing official policies, |
443 | +# either expressed or implied, of Jakob Westhoff |
444 | +## |
445 | + |
446 | +include(ParseArguments) |
447 | +find_package(Vala REQUIRED) |
448 | + |
449 | +## |
450 | +# Compile vala files to their c equivalents for further processing. |
451 | +# |
452 | +# The "vala_precompile" macro takes care of calling the valac executable on the |
453 | +# given source to produce c files which can then be processed further using |
454 | +# default cmake functions. |
455 | +# |
456 | +# The first parameter provided is a variable, which will be filled with a list |
457 | +# of c files outputted by the vala compiler. This list can than be used in |
458 | +# conjuction with functions like "add_executable" or others to create the |
459 | +# neccessary compile rules with CMake. |
460 | +# |
461 | +# The initial variable is followed by a list of .vala files to be compiled. |
462 | +# Please take care to add every vala file belonging to the currently compiled |
463 | +# project or library as Vala will otherwise not be able to resolve all |
464 | +# dependencies. |
465 | +# |
466 | +# The following sections may be specified afterwards to provide certain options |
467 | +# to the vala compiler: |
468 | +# |
469 | +# PACKAGES |
470 | +# A list of vala packages/libraries to be used during the compile cycle. The |
471 | +# package names are exactly the same, as they would be passed to the valac |
472 | +# "--pkg=" option. |
473 | +# |
474 | +# OPTIONS |
475 | +# A list of optional options to be passed to the valac executable. This can be |
476 | +# used to pass "--thread" for example to enable multi-threading support. |
477 | +# |
478 | +# CUSTOM_VAPIS |
479 | +# A list of custom vapi files to be included for compilation. This can be |
480 | +# useful to include freshly created vala libraries without having to install |
481 | +# them in the system. |
482 | +# |
483 | +# GENERATE_VAPI |
484 | +# Pass all the needed flags to the compiler to create an internal vapi for |
485 | +# the compiled library. The provided name will be used for this and a |
486 | +# <provided_name>.vapi file will be created. |
487 | +# |
488 | +# GENERATE_HEADER |
489 | +# Let the compiler generate a header file for the compiled code. There will |
490 | +# be a header file as well as an internal header file being generated called |
491 | +# <provided_name>.h and <provided_name>_internal.h |
492 | +# |
493 | +# The following call is a simple example to the vala_precompile macro showing |
494 | +# an example to every of the optional sections: |
495 | +# |
496 | +# vala_precompile(VALA_C |
497 | +# source1.vala |
498 | +# source2.vala |
499 | +# source3.vala |
500 | +# PACKAGES |
501 | +# gtk+-2.0 |
502 | +# gio-1.0 |
503 | +# posix |
504 | +# DIRECTORY |
505 | +# gen |
506 | +# OPTIONS |
507 | +# --thread |
508 | +# CUSTOM_VAPIS |
509 | +# some_vapi.vapi |
510 | +# GENERATE_VAPI |
511 | +# myvapi |
512 | +# GENERATE_HEADER |
513 | +# myheader |
514 | +# ) |
515 | +# |
516 | +# Most important is the variable VALA_C which will contain all the generated c |
517 | +# file names after the call. |
518 | +## |
519 | + |
520 | +macro(vala_precompile output) |
521 | + parse_arguments(ARGS "PACKAGES;OPTIONS;DIRECTORY;GENERATE_HEADER;GENERATE_VAPI;CUSTOM_VAPIS" "" ${ARGN}) |
522 | + if(ARGS_DIRECTORY) |
523 | + set(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${ARGS_DIRECTORY}) |
524 | + else(ARGS_DIRECTORY) |
525 | + set(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) |
526 | + endif(ARGS_DIRECTORY) |
527 | + include_directories(${DIRECTORY}) |
528 | + set(vala_pkg_opts "") |
529 | + foreach(pkg ${ARGS_PACKAGES}) |
530 | + list(APPEND vala_pkg_opts "--pkg=${pkg}") |
531 | + endforeach(pkg ${ARGS_PACKAGES}) |
532 | + set(in_files "") |
533 | + set(out_files "") |
534 | + set(${output} "") |
535 | + foreach(src ${ARGS_DEFAULT_ARGS}) |
536 | + list(APPEND in_files "${CMAKE_CURRENT_SOURCE_DIR}/${src}") |
537 | + string(REPLACE ".vala" ".c" src ${src}) |
538 | + string(REPLACE ".gs" ".c" src ${src}) |
539 | + set(out_file "${DIRECTORY}/${src}") |
540 | + list(APPEND out_files "${DIRECTORY}/${src}") |
541 | + list(APPEND ${output} ${out_file}) |
542 | + endforeach(src ${ARGS_DEFAULT_ARGS}) |
543 | + |
544 | + set(custom_vapi_arguments "") |
545 | + if(ARGS_CUSTOM_VAPIS) |
546 | + foreach(vapi ${ARGS_CUSTOM_VAPIS}) |
547 | + if(${vapi} MATCHES ${CMAKE_SOURCE_DIR} OR ${vapi} MATCHES ${CMAKE_BINARY_DIR}) |
548 | + list(APPEND custom_vapi_arguments ${vapi}) |
549 | + else (${vapi} MATCHES ${CMAKE_SOURCE_DIR} OR ${vapi} MATCHES ${CMAKE_BINARY_DIR}) |
550 | + list(APPEND custom_vapi_arguments ${CMAKE_CURRENT_SOURCE_DIR}/${vapi}) |
551 | + endif(${vapi} MATCHES ${CMAKE_SOURCE_DIR} OR ${vapi} MATCHES ${CMAKE_BINARY_DIR}) |
552 | + endforeach(vapi ${ARGS_CUSTOM_VAPIS}) |
553 | + endif(ARGS_CUSTOM_VAPIS) |
554 | + |
555 | + set(vapi_arguments "") |
556 | + if(ARGS_GENERATE_VAPI) |
557 | + list(APPEND out_files "${DIRECTORY}/${ARGS_GENERATE_VAPI}.vapi") |
558 | + set(vapi_arguments "--internal-vapi=${ARGS_GENERATE_VAPI}.vapi") |
559 | + |
560 | + # Header and internal header is needed to generate internal vapi |
561 | + if (NOT ARGS_GENERATE_HEADER) |
562 | + set(ARGS_GENERATE_HEADER ${ARGS_GENERATE_VAPI}) |
563 | + endif(NOT ARGS_GENERATE_HEADER) |
564 | + endif(ARGS_GENERATE_VAPI) |
565 | + |
566 | + set(header_arguments "") |
567 | + if(ARGS_GENERATE_HEADER) |
568 | + list(APPEND out_files "${DIRECTORY}/${ARGS_GENERATE_HEADER}.h") |
569 | + list(APPEND out_files "${DIRECTORY}/${ARGS_GENERATE_HEADER}_internal.h") |
570 | + list(APPEND header_arguments "--header=${DIRECTORY}/${ARGS_GENERATE_HEADER}.h") |
571 | + list(APPEND header_arguments "--internal-header=${DIRECTORY}/${ARGS_GENERATE_HEADER}_internal.h") |
572 | + endif(ARGS_GENERATE_HEADER) |
573 | + |
574 | + add_custom_command(OUTPUT ${out_files} |
575 | + COMMAND |
576 | + ${VALA_EXECUTABLE} |
577 | + ARGS |
578 | + "-C" |
579 | + ${header_arguments} |
580 | + ${vapi_arguments} |
581 | + "-b" ${CMAKE_CURRENT_SOURCE_DIR} |
582 | + "-d" ${DIRECTORY} |
583 | + ${vala_pkg_opts} |
584 | + ${ARGS_OPTIONS} |
585 | + ${in_files} |
586 | + ${custom_vapi_arguments} |
587 | + DEPENDS |
588 | + ${in_files} |
589 | + ${ARGS_CUSTOM_VAPIS} |
590 | + ) |
591 | +endmacro(vala_precompile) |
592 | |
593 | === added file 'cmake/vala/ValaVersion.cmake' |
594 | --- cmake/vala/ValaVersion.cmake 1970-01-01 00:00:00 +0000 |
595 | +++ cmake/vala/ValaVersion.cmake 2011-02-23 11:26:02 +0000 |
596 | @@ -0,0 +1,96 @@ |
597 | +## |
598 | +# Copyright 2009-2010 Jakob Westhoff. All rights reserved. |
599 | +# |
600 | +# Redistribution and use in source and binary forms, with or without |
601 | +# modification, are permitted provided that the following conditions are met: |
602 | +# |
603 | +# 1. Redistributions of source code must retain the above copyright notice, |
604 | +# this list of conditions and the following disclaimer. |
605 | +# |
606 | +# 2. Redistributions in binary form must reproduce the above copyright notice, |
607 | +# this list of conditions and the following disclaimer in the documentation |
608 | +# and/or other materials provided with the distribution. |
609 | +# |
610 | +# THIS SOFTWARE IS PROVIDED BY JAKOB WESTHOFF ``AS IS'' AND ANY EXPRESS OR |
611 | +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
612 | +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
613 | +# EVENT SHALL JAKOB WESTHOFF OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
614 | +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
615 | +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
616 | +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
617 | +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
618 | +# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
619 | +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
620 | +# |
621 | +# The views and conclusions contained in the software and documentation are those |
622 | +# of the authors and should not be interpreted as representing official policies, |
623 | +# either expressed or implied, of Jakob Westhoff |
624 | +## |
625 | + |
626 | +include(ParseArguments) |
627 | +find_package(Vala REQUIRED) |
628 | + |
629 | +## |
630 | +# Ensure a certain valac version is available |
631 | +# |
632 | +# The initial argument is the version to check for |
633 | +# |
634 | +# It may be followed by a optional parameter to specifiy a version range. The |
635 | +# following options are valid: |
636 | +# |
637 | +# EXACT |
638 | +# Vala needs to be available in the exact version given |
639 | +# |
640 | +# MINIMUM |
641 | +# The provided version is the minimum version. Therefore Vala needs to be |
642 | +# available in the given version or any higher version |
643 | +# |
644 | +# MAXIMUM |
645 | +# The provided version is the maximum. Therefore Vala needs to be available |
646 | +# in the given version or any version older than this |
647 | +# |
648 | +# If no option is specified the version will be treated as a minimal version. |
649 | +## |
650 | +macro(ensure_vala_version version) |
651 | + parse_arguments(ARGS "" "MINIMUM;MAXIMUM;EXACT" ${ARGN}) |
652 | + set(compare_message "") |
653 | + set(error_message "") |
654 | + if(ARGS_MINIMUM) |
655 | + set(compare_message "a minimum ") |
656 | + set(error_message "or greater ") |
657 | + elseif(ARGS_MAXIMUM) |
658 | + set(compare_message "a maximum ") |
659 | + set(error_message "or less ") |
660 | + endif(ARGS_MINIMUM) |
661 | + |
662 | + message(STATUS |
663 | + "checking for ${compare_message}Vala version of ${version}" |
664 | + ) |
665 | + |
666 | + unset(version_accepted) |
667 | + |
668 | + # MINIMUM is the default if no option is specified |
669 | + if(ARGS_EXACT) |
670 | + if(${VALA_VERSION} VERSION_EQUAL ${version} ) |
671 | + set(version_accepted TRUE) |
672 | + endif(${VALA_VERSION} VERSION_EQUAL ${version}) |
673 | + elseif(ARGS_MAXIMUM) |
674 | + if(${VALA_VERSION} VERSION_LESS ${version} OR ${VALA_VERSION} VERSION_EQUAL ${version}) |
675 | + set(version_accepted TRUE) |
676 | + endif(${VALA_VERSION} VERSION_LESS ${version} OR ${VALA_VERSION} VERSION_EQUAL ${version}) |
677 | + else(ARGS_MAXIMUM) |
678 | + if(${VALA_VERSION} VERSION_GREATER ${version} OR ${VALA_VERSION} VERSION_EQUAL ${version}) |
679 | + set(version_accepted TRUE) |
680 | + endif(${VALA_VERSION} VERSION_GREATER ${version} OR ${VALA_VERSION} VERSION_EQUAL ${version}) |
681 | + endif(ARGS_EXACT) |
682 | + |
683 | + if (NOT version_accepted) |
684 | + message(FATAL_ERROR |
685 | + "Vala version ${version} ${error_message}is required." |
686 | + ) |
687 | + endif(NOT version_accepted) |
688 | + |
689 | + message(STATUS |
690 | + " found Vala, version ${VALA_VERSION}" |
691 | + ) |
692 | +endmacro(ensure_vala_version) |