aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake')
-rw-r--r--cmake/BuildTargetScript.cmake57
-rw-r--r--cmake/CompileGResources.cmake221
-rw-r--r--cmake/FindGPGME.cmake27
-rw-r--r--cmake/FindLIBUUID.cmake42
-rw-r--r--cmake/FindVala.cmake70
-rw-r--r--cmake/GenerateGXML.cmake124
-rw-r--r--cmake/GlibCompileResourcesSupport.cmake11
-rw-r--r--cmake/UseVala.cmake271
8 files changed, 823 insertions, 0 deletions
diff --git a/cmake/BuildTargetScript.cmake b/cmake/BuildTargetScript.cmake
new file mode 100644
index 00000000..72434498
--- /dev/null
+++ b/cmake/BuildTargetScript.cmake
@@ -0,0 +1,57 @@
+# This file is used to be invoked at build time. It generates the needed
+# resource XML file.
+
+# Input variables that need to provided when invoking this script:
+# GXML_OUTPUT The output file path where to save the XML file.
+# GXML_COMPRESS_ALL Sets all COMPRESS flags in all resources in resource
+# list.
+# GXML_NO_COMPRESS_ALL Removes all COMPRESS flags in all resources in
+# resource list.
+# GXML_STRIPBLANKS_ALL Sets all STRIPBLANKS flags in all resources in
+# resource list.
+# GXML_NO_STRIPBLANKS_ALL Removes all STRIPBLANKS flags in all resources in
+# resource list.
+# GXML_TOPIXDATA_ALL Sets all TOPIXDATA flags i nall resources in resource
+# list.
+# GXML_NO_TOPIXDATA_ALL Removes all TOPIXDATA flags in all resources in
+# resource list.
+# GXML_PREFIX Overrides the resource prefix that is prepended to
+# each relative name in registered resources.
+# GXML_RESOURCES The list of resource files. Whether absolute or
+# relative path is equal.
+
+# Include the GENERATE_GXML() function.
+include(${CMAKE_CURRENT_LIST_DIR}/GenerateGXML.cmake)
+
+# Set flags to actual invocation flags.
+if(GXML_COMPRESS_ALL)
+ set(GXML_COMPRESS_ALL COMPRESS_ALL)
+endif()
+if(GXML_NO_COMPRESS_ALL)
+ set(GXML_NO_COMPRESS_ALL NO_COMPRESS_ALL)
+endif()
+if(GXML_STRIPBLANKS_ALL)
+ set(GXML_STRIPBLANKS_ALL STRIPBLANKS_ALL)
+endif()
+if(GXML_NO_STRIPBLANKS_ALL)
+ set(GXML_NO_STRIPBLANKS_ALL NO_STRIPBLANKS_ALL)
+endif()
+if(GXML_TOPIXDATA_ALL)
+ set(GXML_TOPIXDATA_ALL TOPIXDATA_ALL)
+endif()
+if(GXML_NO_TOPIXDATA_ALL)
+ set(GXML_NO_TOPIXDATA_ALL NO_TOPIXDATA_ALL)
+endif()
+
+# Replace " " with ";" to import the list over the command line. Otherwise
+# CMake would interprete the passed resources as a whole string.
+string(REPLACE " " ";" GXML_RESOURCES ${GXML_RESOURCES})
+
+# Invoke the gresource XML generation function.
+generate_gxml(${GXML_OUTPUT}
+ ${GXML_COMPRESS_ALL} ${GXML_NO_COMPRESS_ALL}
+ ${GXML_STRIPBLANKS_ALL} ${GXML_NO_STRIPBLANKS_ALL}
+ ${GXML_TOPIXDATA_ALL} ${GXML_NO_TOPIXDATA_ALL}
+ PREFIX ${GXML_PREFIX}
+ RESOURCES ${GXML_RESOURCES})
+
diff --git a/cmake/CompileGResources.cmake b/cmake/CompileGResources.cmake
new file mode 100644
index 00000000..e9a8d179
--- /dev/null
+++ b/cmake/CompileGResources.cmake
@@ -0,0 +1,221 @@
+include(CMakeParseArguments)
+
+# Path to this file.
+set(GCR_CMAKE_MACRO_DIR ${CMAKE_CURRENT_LIST_DIR})
+
+# Compiles a gresource resource file from given resource files. Automatically
+# creates the XML controlling file.
+# The type of resource to generate (header, c-file or bundle) is automatically
+# determined from TARGET file ending, if no TYPE is explicitly specified.
+# The output file is stored in the provided variable "output".
+# "xml_out" contains the variable where to output the XML path. Can be used to
+# create custom targets or doing postprocessing.
+# If you want to use preprocessing, you need to manually check the existence
+# of the tools you use. This function doesn't check this for you, it just
+# generates the XML file. glib-compile-resources will then throw a
+# warning/error.
+function(COMPILE_GRESOURCES output xml_out)
+ # Available options:
+ # COMPRESS_ALL, NO_COMPRESS_ALL Overrides the COMPRESS flag in all
+ # registered resources.
+ # STRIPBLANKS_ALL, NO_STRIPBLANKS_ALL Overrides the STRIPBLANKS flag in all
+ # registered resources.
+ # TOPIXDATA_ALL, NO_TOPIXDATA_ALL Overrides the TOPIXDATA flag in all
+ # registered resources.
+ set(CG_OPTIONS COMPRESS_ALL NO_COMPRESS_ALL
+ STRIPBLANKS_ALL NO_STRIPBLANKS_ALL
+ TOPIXDATA_ALL NO_TOPIXDATA_ALL)
+
+ # Available one value options:
+ # TYPE Type of resource to create. Valid options are:
+ # EMBED_C: A C-file that can be compiled with your project.
+ # EMBED_H: A header that can be included into your project.
+ # BUNDLE: Generates a resource bundle file that can be loaded
+ # at runtime.
+ # AUTO: Determine from target file ending. Need to specify
+ # target argument.
+ # PREFIX Overrides the resource prefix that is prepended to each
+ # relative file name in registered resources.
+ # SOURCE_DIR Overrides the resources base directory to search for resources.
+ # Normally this is set to the source directory with that CMake
+ # was invoked (CMAKE_SOURCE_DIR).
+ # TARGET Overrides the name of the output file/-s. Normally the output
+ # names from glib-compile-resources tool is taken.
+ set(CG_ONEVALUEARGS TYPE PREFIX SOURCE_DIR TARGET)
+
+ # Available multi-value options:
+ # RESOURCES The list of resource files. Whether absolute or relative path is
+ # equal, absolute paths are stripped down to relative ones. If the
+ # absolute path is not inside the given base directory SOURCE_DIR
+ # or CMAKE_SOURCE_DIR (if SOURCE_DIR is not overriden), this
+ # function aborts.
+ # OPTIONS Extra command line options passed to glib-compile-resources.
+ set(CG_MULTIVALUEARGS RESOURCES OPTIONS)
+
+ # Parse the arguments.
+ cmake_parse_arguments(CG_ARG
+ "${CG_OPTIONS}"
+ "${CG_ONEVALUEARGS}"
+ "${CG_MULTIVALUEARGS}"
+ "${ARGN}")
+
+ # Variable to store the double-quote (") string. Since escaping
+ # double-quotes in strings is not possible we need a helper variable that
+ # does this job for us.
+ set(Q \")
+
+ # Check invocation validity with the <prefix>_UNPARSED_ARGUMENTS variable.
+ # If other not recognized parameters were passed, throw error.
+ if (CG_ARG_UNPARSED_ARGUMENTS)
+ set(CG_WARNMSG "Invocation of COMPILE_GRESOURCES with unrecognized")
+ set(CG_WARNMSG "${CG_WARNMSG} parameters. Parameters are:")
+ set(CG_WARNMSG "${CG_WARNMSG} ${CG_ARG_UNPARSED_ARGUMENTS}.")
+ message(WARNING ${CG_WARNMSG})
+ endif()
+
+ # Check invocation validity depending on generation mode (EMBED_C, EMBED_H
+ # or BUNDLE).
+ if ("${CG_ARG_TYPE}" STREQUAL "EMBED_C")
+ # EMBED_C mode, output compilable C-file.
+ set(CG_GENERATE_COMMAND_LINE "--generate-source")
+ set(CG_TARGET_FILE_ENDING "c")
+ elseif ("${CG_ARG_TYPE}" STREQUAL "EMBED_H")
+ # EMBED_H mode, output includable header file.
+ set(CG_GENERATE_COMMAND_LINE "--generate-header")
+ set(CG_TARGET_FILE_ENDING "h")
+ elseif ("${CG_ARG_TYPE}" STREQUAL "BUNDLE")
+ # BUNDLE mode, output resource bundle. Don't do anything since
+ # glib-compile-resources outputs a bundle when not specifying
+ # something else.
+ set(CG_TARGET_FILE_ENDING "gresource")
+ else()
+ # Everything else is AUTO mode, determine from target file ending.
+ if (CG_ARG_TARGET)
+ set(CG_GENERATE_COMMAND_LINE "--generate")
+ else()
+ set(CG_ERRMSG "AUTO mode given, but no target specified. Can't")
+ set(CG_ERRMSG "${CG_ERRMSG} determine output type. In function")
+ set(CG_ERRMSG "${CG_ERRMSG} COMPILE_GRESOURCES.")
+ message(FATAL_ERROR ${CG_ERRMSG})
+ endif()
+ endif()
+
+ # Check flag validity.
+ if (CG_ARG_COMPRESS_ALL AND CG_ARG_NO_COMPRESS_ALL)
+ set(CG_ERRMSG "COMPRESS_ALL and NO_COMPRESS_ALL simultaneously set. In")
+ set(CG_ERRMSG "${CG_ERRMSG} function COMPILE_GRESOURCES.")
+ message(FATAL_ERROR ${CG_ERRMSG})
+ endif()
+ if (CG_ARG_STRIPBLANKS_ALL AND CG_ARG_NO_STRIPBLANKS_ALL)
+ set(CG_ERRMSG "STRIPBLANKS_ALL and NO_STRIPBLANKS_ALL simultaneously")
+ set(CG_ERRMSG "${CG_ERRMSG} set. In function COMPILE_GRESOURCES.")
+ message(FATAL_ERROR ${CG_ERRMSG})
+ endif()
+ if (CG_ARG_TOPIXDATA_ALL AND CG_ARG_NO_TOPIXDATA_ALL)
+ set(CG_ERRMSG "TOPIXDATA_ALL and NO_TOPIXDATA_ALL simultaneously set.")
+ set(CG_ERRMSG "${CG_ERRMSG} In function COMPILE_GRESOURCES.")
+ message(FATAL_ERROR ${CG_ERRMSG})
+ endif()
+
+ # Check if there are any resources.
+ if (NOT CG_ARG_RESOURCES)
+ set(CG_ERRMSG "No resource files to process. In function")
+ set(CG_ERRMSG "${CG_ERRMSG} COMPILE_GRESOURCES.")
+ message(FATAL_ERROR ${CG_ERRMSG})
+ endif()
+
+ # Extract all dependencies for targets from resource list.
+ foreach(res ${CG_ARG_RESOURCES})
+ if (NOT(("${res}" STREQUAL "COMPRESS") OR
+ ("${res}" STREQUAL "STRIPBLANKS") OR
+ ("${res}" STREQUAL "TOPIXDATA")))
+
+ add_custom_command(
+ OUTPUT "${CMAKE_BINARY_DIR}/resources/${res}"
+ COMMAND ${CMAKE_COMMAND} -E copy "${CG_ARG_SOURCE_DIR}/${res}" "${CMAKE_BINARY_DIR}/resources/${res}"
+ MAIN_DEPENDENCY "${CG_ARG_SOURCE_DIR}/${res}")
+ list(APPEND CG_RESOURCES_DEPENDENCIES "${CMAKE_BINARY_DIR}/resources/${res}")
+ endif()
+ endforeach()
+
+
+ # Construct .gresource.xml path.
+ set(CG_XML_FILE_PATH "${CMAKE_BINARY_DIR}/resources/.gresource.xml")
+
+ # Generate gresources XML target.
+ list(APPEND CG_CMAKE_SCRIPT_ARGS "-D")
+ list(APPEND CG_CMAKE_SCRIPT_ARGS "GXML_OUTPUT=${Q}${CG_XML_FILE_PATH}${Q}")
+ if(CG_ARG_COMPRESS_ALL)
+ list(APPEND CG_CMAKE_SCRIPT_ARGS "-D")
+ list(APPEND CG_CMAKE_SCRIPT_ARGS "GXML_COMPRESS_ALL")
+ endif()
+ if(CG_ARG_NO_COMPRESS_ALL)
+ list(APPEND CG_CMAKE_SCRIPT_ARGS "-D")
+ list(APPEND CG_CMAKE_SCRIPT_ARGS "GXML_NO_COMPRESS_ALL")
+ endif()
+ if(CG_ARG_STRPIBLANKS_ALL)
+ list(APPEND CG_CMAKE_SCRIPT_ARGS "-D")
+ list(APPEND CG_CMAKE_SCRIPT_ARGS "GXML_STRIPBLANKS_ALL")
+ endif()
+ if(CG_ARG_NO_STRIPBLANKS_ALL)
+ list(APPEND CG_CMAKE_SCRIPT_ARGS "-D")
+ list(APPEND CG_CMAKE_SCRIPT_ARGS "GXML_NO_STRIPBLANKS_ALL")
+ endif()
+ if(CG_ARG_TOPIXDATA_ALL)
+ list(APPEND CG_CMAKE_SCRIPT_ARGS "-D")
+ list(APPEND CG_CMAKE_SCRIPT_ARGS "GXML_TOPIXDATA_ALL")
+ endif()
+ if(CG_ARG_NO_TOPIXDATA_ALL)
+ list(APPEND CG_CMAKE_SCRIPT_ARGS "-D")
+ list(APPEND CG_CMAKE_SCRIPT_ARGS "GXML_NO_TOPIXDATA_ALL")
+ endif()
+ list(APPEND CG_CMAKE_SCRIPT_ARGS "-D")
+ list(APPEND CG_CMAKE_SCRIPT_ARGS "GXML_PREFIX=${Q}${CG_ARG_PREFIX}${Q}")
+ list(APPEND CG_CMAKE_SCRIPT_ARGS "-D")
+ list(APPEND CG_CMAKE_SCRIPT_ARGS
+ "GXML_RESOURCES=${Q}${CG_ARG_RESOURCES}${Q}")
+ list(APPEND CG_CMAKE_SCRIPT_ARGS "-P")
+ list(APPEND CG_CMAKE_SCRIPT_ARGS
+ "${Q}${GCR_CMAKE_MACRO_DIR}/BuildTargetScript.cmake${Q}")
+
+ get_filename_component(CG_XML_FILE_PATH_ONLY_NAME
+ "${CG_XML_FILE_PATH}" NAME)
+ set(CG_XML_CUSTOM_COMMAND_COMMENT
+ "Creating gresources XML file (${CG_XML_FILE_PATH_ONLY_NAME})")
+ add_custom_command(OUTPUT ${CG_XML_FILE_PATH}
+ COMMAND ${CMAKE_COMMAND}
+ ARGS ${CG_CMAKE_SCRIPT_ARGS}
+ DEPENDS ${CG_RESOURCES_DEPENDENCIES}
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+ COMMENT ${CG_XML_CUSTOM_COMMAND_COMMENT})
+
+ # Create target manually if not set (to make sure glib-compile-resources
+ # doesn't change behaviour with it's naming standards).
+ if (NOT CG_ARG_TARGET)
+ set(CG_ARG_TARGET "${CMAKE_BINARY_DIR}/resources")
+ set(CG_ARG_TARGET "${CG_ARG_TARGET}.${CG_TARGET_FILE_ENDING}")
+ endif()
+
+ # Create source directory automatically if not set.
+ if (NOT CG_ARG_SOURCE_DIR)
+ set(CG_ARG_SOURCE_DIR "${CMAKE_SOURCE_DIR}")
+ endif()
+
+ # Add compilation target for resources.
+ add_custom_command(OUTPUT ${CG_ARG_TARGET}
+ COMMAND ${GLIB_COMPILE_RESOURCES_EXECUTABLE}
+ ARGS
+ ${OPTIONS}
+ "--target=${Q}${CG_ARG_TARGET}${Q}"
+ "--sourcedir=${Q}${CG_ARG_SOURCE_DIR}${Q}"
+ ${CG_GENERATE_COMMAND_LINE}
+ ${CG_XML_FILE_PATH}
+ MAIN_DEPENDENCY ${CG_XML_FILE_PATH}
+ DEPENDS ${CG_RESOURCES_DEPENDENCIES}
+ WORKING_DIRECTORY ${CMAKE_BUILD_DIR})
+
+ # Set output and XML_OUT to parent scope.
+ set(${xml_out} ${CG_XML_FILE_PATH} PARENT_SCOPE)
+ set(${output} ${CG_ARG_TARGET} PARENT_SCOPE)
+
+endfunction()
diff --git a/cmake/FindGPGME.cmake b/cmake/FindGPGME.cmake
new file mode 100644
index 00000000..fd096363
--- /dev/null
+++ b/cmake/FindGPGME.cmake
@@ -0,0 +1,27 @@
+# TODO: Windows related stuff
+
+find_program(GPGME_CONFIG_EXECUTABLE NAMES gpgme-config)
+mark_as_advanced(GPGME_CONFIG_EXECUTABLE)
+
+if(GPGME_CONFIG_EXECUTABLE)
+ execute_process(COMMAND ${GPGME_CONFIG_EXECUTABLE} --version
+ OUTPUT_VARIABLE GPGME_VERSION
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ execute_process(COMMAND ${GPGME_CONFIG_EXECUTABLE} --api-version
+ OUTPUT_VARIABLE GPGME_API_VERSION
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ execute_process(COMMAND ${GPGME_CONFIG_EXECUTABLE} --cflags
+ OUTPUT_VARIABLE GPGME_CFLAGS
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ execute_process(COMMAND ${GPGME_CONFIG_EXECUTABLE} --libs
+ OUTPUT_VARIABLE GPGME_LIBRARIES
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+endif(GPGME_CONFIG_EXECUTABLE)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(GPGME
+ REQUIRED_VARS GPGME_CONFIG_EXECUTABLE
+ VERSION_VAR GPGME_VERSION) \ No newline at end of file
diff --git a/cmake/FindLIBUUID.cmake b/cmake/FindLIBUUID.cmake
new file mode 100644
index 00000000..bfc364f3
--- /dev/null
+++ b/cmake/FindLIBUUID.cmake
@@ -0,0 +1,42 @@
+# - Find libuuid
+# Find the libuuid library
+#
+# This module defines the following variables:
+# LIBUUID_FOUND - True if library and include directory are found
+# If set to TRUE, the following are also defined:
+# LIBUUID_INCLUDE_DIRS - The directory where to find the header file
+# LIBUUID_LIBRARIES - Where to find the library file
+#
+# For conveniance, these variables are also set. They have the same values
+# than the variables above. The user can thus choose his/her prefered way
+# to write them.
+# LIBUUID_INCLUDE_DIR
+# LIBUUID_LIBRARY
+#
+# This file is in the public domain
+
+include(FindPkgConfig)
+pkg_check_modules(LIBUUID uuid)
+
+if(NOT LIBUUID_FOUND)
+ find_path(LIBUUID_INCLUDE_DIRS NAMES uuid/uuid.h
+ PATH_SUFFIXES uuid
+ DOC "The libuuid include directory")
+
+ find_library(LIBUUID_LIBRARIES NAMES uuid
+ DOC "The libuuid library")
+
+ # Use some standard module to handle the QUIETLY and REQUIRED arguments, and
+ # set LIBUUID_FOUND to TRUE if these two variables are set.
+ include(FindPackageHandleStandardArgs)
+ find_package_handle_standard_args(LIBUUID REQUIRED_VARS LIBUUID_LIBRARIES LIBUUID_INCLUDE_DIRS)
+
+ # Compatibility for all the ways of writing these variables
+ if(LIBUUID_FOUND)
+ set(LIBUUID_INCLUDE_DIR ${LIBUUID_INCLUDE_DIRS})
+ set(LIBUUID_LIBRARY ${LIBUUID_LIBRARIES})
+ set(LIBUUID_CFLAGS -I${LIBUUID_INCLUDE_DIRS})
+ endif()
+endif()
+
+mark_as_advanced(LIBUUID_INCLUDE_DIRS LIBUUID_LIBRARIES LIBUUID_CFLAGS)
diff --git a/cmake/FindVala.cmake b/cmake/FindVala.cmake
new file mode 100644
index 00000000..5150a7d9
--- /dev/null
+++ b/cmake/FindVala.cmake
@@ -0,0 +1,70 @@
+##
+# Find module for the Vala compiler (valac)
+#
+# This module determines wheter a Vala compiler is installed on the current
+# system and where its executable is.
+#
+# Call the module using "find_package(Vala) from within your CMakeLists.txt.
+#
+# The following variables will be set after an invocation:
+#
+# VALA_FOUND Whether the vala compiler has been found or not
+# VALA_EXECUTABLE Full path to the valac executable if it has been found
+# VALA_VERSION Version number of the available valac
+# VALA_USE_FILE Include this file to define the vala_precompile function
+##
+
+##
+# Copyright 2009-2010 Jakob Westhoff. All rights reserved.
+# Copyright 2010-2011 Daniel Pfeifer
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY JAKOB WESTHOFF ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL JAKOB WESTHOFF OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# The views and conclusions contained in the software and documentation are those
+# of the authors and should not be interpreted as representing official policies,
+# either expressed or implied, of Jakob Westhoff
+##
+
+# Search for the valac executable in the usual system paths
+# Some distributions rename the valac to contain the major.minor in the binary name
+find_program(VALA_EXECUTABLE NAMES valac valac-0.20 valac-0.18 valac-0.16 valac-0.14 valac-0.12 valac-0.10)
+mark_as_advanced(VALA_EXECUTABLE)
+
+# Determine the valac version
+if(VALA_EXECUTABLE)
+ execute_process(COMMAND ${VALA_EXECUTABLE} "--version"
+ OUTPUT_VARIABLE VALA_VERSION
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ string(REPLACE "Vala " "" VALA_VERSION "${VALA_VERSION}")
+endif(VALA_EXECUTABLE)
+
+# Handle the QUIETLY and REQUIRED arguments, which may be given to the find call.
+# Furthermore set VALA_FOUND to TRUE if Vala has been found (aka.
+# VALA_EXECUTABLE is set)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(Vala
+ REQUIRED_VARS VALA_EXECUTABLE
+ VERSION_VAR VALA_VERSION)
+
+set(VALA_USE_FILE "${CMAKE_CURRENT_LIST_DIR}/UseVala.cmake")
+
diff --git a/cmake/GenerateGXML.cmake b/cmake/GenerateGXML.cmake
new file mode 100644
index 00000000..4be96041
--- /dev/null
+++ b/cmake/GenerateGXML.cmake
@@ -0,0 +1,124 @@
+include(CMakeParseArguments)
+
+# Generates the resource XML controlling file from resource list (and saves it
+# to xml_path). It's not recommended to use this function directly, since it
+# doesn't handle invalid arguments. It is used by the function
+# COMPILE_GRESOURCES() to create a custom command, so that this function is
+# invoked at build-time in script mode from CMake.
+function(GENERATE_GXML xml_path)
+ # Available options:
+ # COMPRESS_ALL, NO_COMPRESS_ALL Overrides the COMPRESS flag in all
+ # registered resources.
+ # STRIPBLANKS_ALL, NO_STRIPBLANKS_ALL Overrides the STRIPBLANKS flag in all
+ # registered resources.
+ # TOPIXDATA_ALL, NO_TOPIXDATA_ALL Overrides the TOPIXDATA flag in all
+ # registered resources.
+ set(GXML_OPTIONS COMPRESS_ALL NO_COMPRESS_ALL
+ STRIPBLANKS_ALL NO_STRIPBLANKS_ALL
+ TOPIXDATA_ALL NO_TOPIXDATA_ALL)
+
+ # Available one value options:
+ # PREFIX Overrides the resource prefix that is prepended to each
+ # relative file name in registered resources.
+ set(GXML_ONEVALUEARGS PREFIX)
+
+ # Available multi-value options:
+ # RESOURCES The list of resource files. Whether absolute or relative path is
+ # equal, absolute paths are stripped down to relative ones. If the
+ # absolute path is not inside the given base directory SOURCE_DIR
+ # or CMAKE_SOURCE_DIR (if SOURCE_DIR is not overriden), this
+ # function aborts.
+ set(GXML_MULTIVALUEARGS RESOURCES)
+
+ # Parse the arguments.
+ cmake_parse_arguments(GXML_ARG
+ "${GXML_OPTIONS}"
+ "${GXML_ONEVALUEARGS}"
+ "${GXML_MULTIVALUEARGS}"
+ "${ARGN}")
+
+ # Variable to store the double-quote (") string. Since escaping
+ # double-quotes in strings is not possible we need a helper variable that
+ # does this job for us.
+ set(Q \")
+
+ # Process resources and generate XML file.
+ # Begin with the XML header and header nodes.
+ set(GXML_XML_FILE "<?xml version=${Q}1.0${Q} encoding=${Q}UTF-8${Q}?>")
+ set(GXML_XML_FILE "${GXML_XML_FILE}<gresources><gresource prefix=${Q}")
+
+ # Set the prefix for the resources. Depending on the user-override we choose
+ # the standard prefix "/" or the override.
+ if (GXML_ARG_PREFIX)
+ set(GXML_XML_FILE "${GXML_XML_FILE}${GXML_ARG_PREFIX}")
+ else()
+ set(GXML_XML_FILE "${GXML_XML_FILE}/")
+ endif()
+
+ set(GXML_XML_FILE "${GXML_XML_FILE}${Q}>")
+
+ # Process each resource.
+ foreach(res ${GXML_ARG_RESOURCES})
+ if ("${res}" STREQUAL "COMPRESS")
+ set(GXML_COMPRESSION_FLAG ON)
+ elseif ("${res}" STREQUAL "STRIPBLANKS")
+ set(GXML_STRIPBLANKS_FLAG ON)
+ elseif ("${res}" STREQUAL "TOPIXDATA")
+ set(GXML_TOPIXDATA_FLAG ON)
+ else()
+ # The file name.
+ set(GXML_RESOURCE_PATH "${res}")
+
+ # Append to real resource file dependency list.
+ list(APPEND GXML_RESOURCES_DEPENDENCIES ${GXML_RESOURCE_PATH})
+
+ # Assemble <file> node.
+ set(GXML_RES_LINE "<file")
+ if ((GXML_ARG_COMPRESS_ALL OR GXML_COMPRESSION_FLAG) AND NOT
+ GXML_ARG_NO_COMPRESS_ALL)
+ set(GXML_RES_LINE "${GXML_RES_LINE} compressed=${Q}true${Q}")
+ endif()
+
+ # Check preprocess flag validity.
+ if ((GXML_ARG_STRIPBLANKS_ALL OR GXML_STRIPBLANKS_FLAG) AND
+ (GXML_ARG_TOPIXDATA_ALL OR GXML_TOPIXDATA_FLAG))
+ set(GXML_ERRMSG "Resource preprocessing option conflict. Tried")
+ set(GXML_ERRMSG "${GXML_ERRMSG} to specify both, STRIPBLANKS")
+ set(GXML_ERRMSG "${GXML_ERRMSG} and TOPIXDATA. In resource")
+ set(GXML_ERRMSG "${GXML_ERRMSG} ${GXML_RESOURCE_PATH} in")
+ set(GXML_ERRMSG "${GXML_ERRMSG} function COMPILE_GRESOURCES.")
+ message(FATAL_ERROR ${GXML_ERRMSG})
+ endif()
+
+ if ((GXML_ARG_STRIPBLANKS_ALL OR GXML_STRIPBLANKS_FLAG) AND NOT
+ GXML_ARG_NO_STRIPBLANKS_ALL)
+ set(GXML_RES_LINE "${GXML_RES_LINE} preprocess=")
+ set(GXML_RES_LINE "${GXML_RES_LINE}${Q}xml-stripblanks${Q}")
+ elseif((GXML_ARG_TOPIXDATA_ALL OR GXML_TOPIXDATA_FLAG) AND NOT
+ GXML_ARG_NO_TOPIXDATA_ALL)
+ set(GXML_RES_LINE "${GXML_RES_LINE} preprocess=")
+ set(GXML_RES_LINE "${GXML_RES_LINE}${Q}to-pixdata${Q}")
+ endif()
+
+ set(GXML_RES_LINE "${GXML_RES_LINE}>${GXML_RESOURCE_PATH}</file>")
+
+ # Append to file string.
+ set(GXML_XML_FILE "${GXML_XML_FILE}${GXML_RES_LINE}")
+
+ # Unset variables.
+ unset(GXML_COMPRESSION_FLAG)
+ unset(GXML_STRIPBLANKS_FLAG)
+ unset(GXML_TOPIXDATA_FLAG)
+ endif()
+
+ endforeach()
+
+ # Append closing nodes.
+ set(GXML_XML_FILE "${GXML_XML_FILE}</gresource></gresources>")
+
+ # Use "file" function to generate XML controlling file.
+ get_filename_component(xml_path_only_name "${xml_path}" NAME)
+ file(WRITE ${xml_path} ${GXML_XML_FILE})
+
+endfunction()
+
diff --git a/cmake/GlibCompileResourcesSupport.cmake b/cmake/GlibCompileResourcesSupport.cmake
new file mode 100644
index 00000000..2950af34
--- /dev/null
+++ b/cmake/GlibCompileResourcesSupport.cmake
@@ -0,0 +1,11 @@
+# Path to this file.
+set(GCR_CMAKE_MACRO_DIR ${CMAKE_CURRENT_LIST_DIR})
+
+# Finds the glib-compile-resources executable.
+find_program(GLIB_COMPILE_RESOURCES_EXECUTABLE glib-compile-resources)
+mark_as_advanced(GLIB_COMPILE_RESOURCES_EXECUTABLE)
+
+# Include the cmake files containing the functions.
+include(${GCR_CMAKE_MACRO_DIR}/CompileGResources.cmake)
+include(${GCR_CMAKE_MACRO_DIR}/GenerateGXML.cmake)
+
diff --git a/cmake/UseVala.cmake b/cmake/UseVala.cmake
new file mode 100644
index 00000000..a5d14a0f
--- /dev/null
+++ b/cmake/UseVala.cmake
@@ -0,0 +1,271 @@
+##
+# Compile vala files to their c equivalents for further processing.
+#
+# The "vala_precompile" function takes care of calling the valac executable on
+# the given source to produce c files which can then be processed further using
+# default cmake functions.
+#
+# The first parameter provided is a variable, which will be filled with a list
+# of c files outputted by the vala compiler. This list can than be used in
+# conjuction with functions like "add_executable" or others to create the
+# neccessary compile rules with CMake.
+#
+# The following sections may be specified afterwards to provide certain options
+# to the vala compiler:
+#
+# SOURCES
+# A list of .vala files to be compiled. Please take care to add every vala
+# file belonging to the currently compiled project or library as Vala will
+# otherwise not be able to resolve all dependencies.
+#
+# PACKAGES
+# A list of vala packages/libraries to be used during the compile cycle. The
+# package names are exactly the same, as they would be passed to the valac
+# "--pkg=" option.
+#
+# OPTIONS
+# A list of optional options to be passed to the valac executable. This can be
+# used to pass "--thread" for example to enable multi-threading support.
+#
+# DEFINITIONS
+# A list of symbols to be used for conditional compilation. They are the same
+# as they would be passed using the valac "--define=" option.
+#
+# CUSTOM_VAPIS
+# A list of custom vapi files to be included for compilation. This can be
+# useful to include freshly created vala libraries without having to install
+# them in the system.
+#
+# GENERATE_VAPI
+# Pass all the needed flags to the compiler to create a vapi for
+# the compiled library. The provided name will be used for this and a
+# <provided_name>.vapi file will be created.
+#
+# GENERATE_HEADER
+# Let the compiler generate a header file for the compiled code. There will
+# be a header file as well as an internal header file being generated called
+# <provided_name>.h and <provided_name>_internal.h
+#
+# The following call is a simple example to the vala_precompile macro showing
+# an example to every of the optional sections:
+#
+# find_package(Vala "0.12" REQUIRED)
+# include(${VALA_USE_FILE})
+#
+# vala_precompile(VALA_C
+# SOURCES
+# source1.vala
+# source2.vala
+# source3.vala
+# PACKAGES
+# gtk+-2.0
+# gio-1.0
+# posix
+# DIRECTORY
+# gen
+# OPTIONS
+# --thread
+# CUSTOM_VAPIS
+# some_vapi.vapi
+# GENERATE_VAPI
+# myvapi
+# GENERATE_HEADER
+# myheader
+# )
+#
+# Most important is the variable VALA_C which will contain all the generated c
+# file names after the call.
+##
+
+##
+# Copyright 2009-2010 Jakob Westhoff. All rights reserved.
+# Copyright 2010-2011 Daniel Pfeifer
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY JAKOB WESTHOFF ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL JAKOB WESTHOFF OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# The views and conclusions contained in the software and documentation are those
+# of the authors and should not be interpreted as representing official policies,
+# either expressed or implied, of Jakob Westhoff
+##
+
+include(CMakeParseArguments)
+
+function(_vala_mkdir_for_file file)
+ get_filename_component(dir "${file}" DIRECTORY)
+ file(MAKE_DIRECTORY "${dir}")
+endfunction()
+
+function(vala_precompile output)
+ cmake_parse_arguments(ARGS "" "DIRECTORY;GENERATE_HEADER;GENERATE_VAPI"
+ "SOURCES;PACKAGES;OPTIONS;DEFINITIONS;CUSTOM_VAPIS;GRESOURCES" ${ARGN})
+
+ if(ARGS_DIRECTORY)
+ get_filename_component(DIRECTORY ${ARGS_DIRECTORY} ABSOLUTE)
+ else(ARGS_DIRECTORY)
+ set(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+ endif(ARGS_DIRECTORY)
+ include_directories(${DIRECTORY})
+
+ set(vala_pkg_opts "")
+ foreach(pkg ${ARGS_PACKAGES})
+ list(APPEND vala_pkg_opts "--pkg=${pkg}")
+ endforeach(pkg ${ARGS_PACKAGES})
+
+ set(vala_define_opts "")
+ foreach(def ${ARGS_DEFINTIONS})
+ list(APPEND vala_define_opts "--define=${def}")
+ endforeach(def ${ARGS_DEFINTIONS})
+
+ set(custom_vapi_arguments "")
+ if(ARGS_CUSTOM_VAPIS)
+ foreach(vapi ${ARGS_CUSTOM_VAPIS})
+ if(${vapi} MATCHES ${CMAKE_SOURCE_DIR} OR ${vapi} MATCHES ${CMAKE_BINARY_DIR})
+ list(APPEND custom_vapi_arguments ${vapi})
+ else (${vapi} MATCHES ${CMAKE_SOURCE_DIR} OR ${vapi} MATCHES ${CMAKE_BINARY_DIR})
+ list(APPEND custom_vapi_arguments ${CMAKE_CURRENT_SOURCE_DIR}/${vapi})
+ endif(${vapi} MATCHES ${CMAKE_SOURCE_DIR} OR ${vapi} MATCHES ${CMAKE_BINARY_DIR})
+ endforeach(vapi ${ARGS_CUSTOM_VAPIS})
+ endif(ARGS_CUSTOM_VAPIS)
+
+ set(gresources_args "")
+ if(ARGS_GRESOURCES)
+ set(gresources_args --gresources "${ARGS_GRESOURCES}")
+ endif(ARGS_GRESOURCES)
+
+ set(in_files "")
+ set(fast_vapi_files "")
+ set(out_files "")
+ set(out_extra_files "")
+
+ set(vapi_arguments "")
+ if(ARGS_GENERATE_VAPI)
+ list(APPEND out_extra_files "${DIRECTORY}/${ARGS_GENERATE_VAPI}.vapi")
+ set(vapi_arguments "--internal-vapi=${ARGS_GENERATE_VAPI}.vapi")
+
+ # Header and internal header is needed to generate internal vapi
+ if (NOT ARGS_GENERATE_HEADER)
+ set(ARGS_GENERATE_HEADER ${ARGS_GENERATE_VAPI})
+ endif(NOT ARGS_GENERATE_HEADER)
+ endif(ARGS_GENERATE_VAPI)
+
+ set(header_arguments "")
+ if(ARGS_GENERATE_HEADER)
+ list(APPEND out_extra_files "${DIRECTORY}/${ARGS_GENERATE_HEADER}.h")
+ list(APPEND out_extra_files "${DIRECTORY}/${ARGS_GENERATE_HEADER}_internal.h")
+ list(APPEND header_arguments "--header=${DIRECTORY}/${ARGS_GENERATE_HEADER}.h")
+ list(APPEND header_arguments "--internal-header=${DIRECTORY}/${ARGS_GENERATE_HEADER}_internal.h")
+ endif(ARGS_GENERATE_HEADER)
+
+ foreach(src ${ARGS_SOURCES} ${ARGS_UNPARSED_ARGUMENTS})
+ set(in_file "${CMAKE_CURRENT_SOURCE_DIR}/${src}")
+ list(APPEND in_files "${in_file}")
+ string(REPLACE ".vala" ".c" src ${src})
+ string(REPLACE ".gs" ".c" src ${src})
+ string(REPLACE ".c" ".vapi" fast_vapi ${src})
+ set(fast_vapi_file "${DIRECTORY}/${fast_vapi}")
+ list(APPEND fast_vapi_files "${fast_vapi_file}")
+ list(APPEND out_files "${DIRECTORY}/${src}")
+
+ _vala_mkdir_for_file("${fast_vapi_file}")
+
+ add_custom_command(OUTPUT ${fast_vapi_file}
+ COMMAND
+ ${VALA_EXECUTABLE}
+ ARGS
+ --fast-vapi ${fast_vapi_file}
+ ${ARGS_OPTIONS}
+ ${in_file}
+ DEPENDS
+ ${in_file}
+ COMMENT
+ "Generating fast VAPI ${fast_vapi}"
+ )
+ endforeach(src ${ARGS_SOURCES} ${ARGS_UNPARSED_ARGUMENTS})
+
+ foreach(src ${ARGS_SOURCES} ${ARGS_UNPARSED_ARGUMENTS})
+ set(in_file "${CMAKE_CURRENT_SOURCE_DIR}/${src}")
+ string(REPLACE ".vala" ".c" c_code ${src})
+ string(REPLACE ".gs" ".c" c_code ${c_code})
+ string(REPLACE ".c" ".vapi" fast_vapi ${c_code})
+ set(my_fast_vapi_file "${DIRECTORY}/${fast_vapi}")
+ set(c_code_file "${DIRECTORY}/${c_code}")
+ set(fast_vapi_flags "")
+ set(fast_vapi_stamp "")
+ foreach(fast_vapi_file ${fast_vapi_files})
+ if(NOT "${fast_vapi_file}" STREQUAL "${my_fast_vapi_file}")
+ list(APPEND fast_vapi_flags --use-fast-vapi "${fast_vapi_file}")
+ list(APPEND fast_vapi_stamp "${fast_vapi_file}")
+ endif()
+ endforeach(fast_vapi_file)
+
+ _vala_mkdir_for_file("${fast_vapi_file}")
+ get_filename_component(dir "${c_code_file}" DIRECTORY)
+
+ add_custom_command(OUTPUT ${c_code_file}
+ COMMAND
+ ${VALA_EXECUTABLE}
+ ARGS
+ "-C"
+ "-d" ${dir}
+ ${vala_pkg_opts}
+ ${vala_define_opts}
+ ${gresources_args}
+ ${ARGS_OPTIONS}
+ ${fast_vapi_flags}
+ ${in_file}
+ ${custom_vapi_arguments}
+ DEPENDS
+ ${fast_vapi_stamp}
+ ${in_file}
+ ${ARGS_CUSTOM_VAPIS}
+ ${ARGS_GRESOURCES}
+ COMMENT
+ "Generating C source ${c_code}"
+ )
+ endforeach(src)
+
+ if(NOT "${out_extra_files}" STREQUAL "")
+ add_custom_command(OUTPUT ${out_extra_files}
+ COMMAND
+ ${VALA_EXECUTABLE}
+ ARGS
+ -C -q --disable-warnings
+ ${header_arguments}
+ ${vapi_arguments}
+ "-b" ${CMAKE_CURRENT_SOURCE_DIR}
+ "-d" ${DIRECTORY}
+ ${vala_pkg_opts}
+ ${vala_define_opts}
+ ${gresources_args}
+ ${ARGS_OPTIONS}
+ ${in_files}
+ ${custom_vapi_arguments}
+ DEPENDS
+ ${in_files}
+ ${ARGS_CUSTOM_VAPIS}
+ ${ARGS_GRESOURCES}
+ COMMENT
+ "Generating VAPI and headers for linking"
+ )
+ endif()
+ set(${output} ${out_files} PARENT_SCOPE)
+endfunction(vala_precompile)