Skip to content

Commit 9689821

Browse files
committed
Meson with debhelper not available on xenial, fun! (add cmake build sys)
1 parent 9d0450b commit 9689821

18 files changed

+998
-14
lines changed

CMakeLists.txt

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# required for building via debhelper on xenial :(
2+
3+
cmake_minimum_required (VERSION 2.6)
4+
cmake_policy (VERSION 2.6)
5+
6+
# Set the Title to use for the Indicator (May be used in future features)
7+
set (INDICATORTITLE "Synapse")
8+
9+
# The description of what your Indicator is
10+
set (INDICATORDESCRIPTION "Search Indicator")
11+
12+
# Projectname
13+
project (synapse)
14+
15+
#########################################################
16+
# Only alter stuff below if you know what you are doing #
17+
#########################################################
18+
19+
# Configuration
20+
include (GNUInstallDirs)
21+
set (DATADIR "${CMAKE_INSTALL_FULL_LIBDIR}/wingpanel")
22+
set (PKGDATADIR "${DATADIR}")
23+
set (GETTEXT_PACKAGE "${CMAKE_PROJECT_NAME}-indicator")
24+
set (VERSION "2.1.1")
25+
list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
26+
27+
# Configure file
28+
add_definitions (-DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\")
29+
30+
# Comment this out to enable C compiler warnings
31+
add_definitions (-w)
32+
33+
# Files
34+
file (GLOB resources "${CMAKE_CURRENT_SOURCE_DIR}/data/*")
35+
36+
# Code
37+
add_subdirectory (src)
38+
39+
# Uninstall target
40+
configure_file(
41+
"${CMAKE_SOURCE_DIR}/cmake/Uninstall.cmake"
42+
"${CMAKE_CURRENT_BINARY_DIR}/Uninstall.cmake"
43+
IMMEDIATE @ONLY)
44+
45+
add_custom_target(uninstall
46+
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/Uninstall.cmake)

cmake/FindGirCompiler.cmake

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
##
2+
# Copyright 2009-2010 Jakob Westhoff. All rights reserved.
3+
#
4+
# Redistribution and use in source and binary forms, with or without
5+
# modification, are permitted provided that the following conditions are met:
6+
#
7+
# 1. Redistributions of source code must retain the above copyright notice,
8+
# this list of conditions and the following disclaimer.
9+
#
10+
# 2. Redistributions in binary form must reproduce the above copyright notice,
11+
# this list of conditions and the following disclaimer in the documentation
12+
# and/or other materials provided with the distribution.
13+
#
14+
# THIS SOFTWARE IS PROVIDED BY JAKOB WESTHOFF ``AS IS'' AND ANY EXPRESS OR
15+
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16+
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
17+
# EVENT SHALL JAKOB WESTHOFF OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
18+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
19+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
22+
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23+
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24+
#
25+
# The views and conclusions contained in the software and documentation are those
26+
# of the authors and should not be interpreted as representing official policies,
27+
# either expressed or implied, of Jakob Westhoff
28+
##
29+
30+
##
31+
# Find module for the Gir compiler (g-ir-compiler)
32+
#
33+
# This module determines wheter a Gir compiler is installed on the current
34+
# system and where its executable is.
35+
#
36+
# Call the module using "find_package(GirCompiler) from within your CMakeLists.txt.
37+
#
38+
# The following variables will be set after an invocation:
39+
#
40+
# G_IR_COMPILER_FOUND Whether the g-ir-compiler compiler has been found or not
41+
# G_IR_COMPILER_EXECUTABLE Full path to the g-ir-compiler executable if it has been found
42+
##
43+
44+
45+
# Search for the g-ir-compiler executable in the usual system paths.
46+
find_program (G_IR_COMPILER_EXECUTABLE
47+
NAMES g-ir-compiler)
48+
49+
# Handle the QUIETLY and REQUIRED arguments, which may be given to the find call.
50+
# Furthermore set G_IR_COMPILER_FOUND to TRUE if the g-ir-compiler has been found (aka.
51+
# G_IR_COMPILER_EXECUTABLE is set)
52+
53+
include (FindPackageHandleStandardArgs)
54+
find_package_handle_standard_args (GirCompiler DEFAULT_MSG G_IR_COMPILER_EXECUTABLE)
55+
56+
mark_as_advanced (G_IR_COMPILER_EXECUTABLE)

cmake/FindVala.cmake

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
##
2+
# Copyright 2009-2010 Jakob Westhoff. All rights reserved.
3+
#
4+
# Redistribution and use in source and binary forms, with or without
5+
# modification, are permitted provided that the following conditions are met:
6+
#
7+
# 1. Redistributions of source code must retain the above copyright notice,
8+
# this list of conditions and the following disclaimer.
9+
#
10+
# 2. Redistributions in binary form must reproduce the above copyright notice,
11+
# this list of conditions and the following disclaimer in the documentation
12+
# and/or other materials provided with the distribution.
13+
#
14+
# THIS SOFTWARE IS PROVIDED BY JAKOB WESTHOFF ``AS IS'' AND ANY EXPRESS OR
15+
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16+
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
17+
# EVENT SHALL JAKOB WESTHOFF OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
18+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
19+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
22+
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23+
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24+
#
25+
# The views and conclusions contained in the software and documentation are those
26+
# of the authors and should not be interpreted as representing official policies,
27+
# either expressed or implied, of Jakob Westhoff
28+
##
29+
30+
##
31+
# Find module for the Vala compiler (valac)
32+
#
33+
# This module determines wheter a Vala compiler is installed on the current
34+
# system and where its executable is.
35+
#
36+
# Call the module using "find_package(Vala) from within your CMakeLists.txt.
37+
#
38+
# The following variables will be set after an invocation:
39+
#
40+
# VALA_FOUND Whether the vala compiler has been found or not
41+
# VALA_EXECUTABLE Full path to the valac executable if it has been found
42+
# VALA_VERSION Version number of the available valac
43+
##
44+
45+
46+
# Search for the valac executable in the usual system paths.
47+
find_program(VALA_EXECUTABLE
48+
NAMES valac)
49+
50+
# Handle the QUIETLY and REQUIRED arguments, which may be given to the find call.
51+
# Furthermore set VALA_FOUND to TRUE if Vala has been found (aka.
52+
# VALA_EXECUTABLE is set)
53+
54+
include(FindPackageHandleStandardArgs)
55+
find_package_handle_standard_args(Vala DEFAULT_MSG VALA_EXECUTABLE)
56+
57+
mark_as_advanced(VALA_EXECUTABLE)
58+
59+
# Determine the valac version
60+
if(VALA_FOUND)
61+
execute_process(COMMAND ${VALA_EXECUTABLE} "--version"
62+
OUTPUT_VARIABLE "VALA_VERSION")
63+
string(REPLACE "Vala" "" "VALA_VERSION" ${VALA_VERSION})
64+
string(STRIP ${VALA_VERSION} "VALA_VERSION")
65+
endif(VALA_FOUND)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
macro(add_target_gir TARGET_NAME GIR_NAME HEADER CFLAGS GRANITE_VERSION)
2+
set(PACKAGES "")
3+
foreach(PKG ${ARGN})
4+
set(PACKAGES ${PACKAGES} --include=${PKG})
5+
endforeach()
6+
install(CODE "set(ENV{LD_LIBRARY_PATH} \"${CMAKE_CURRENT_BINARY_DIR}:\$ENV{LD_LIBRARY_PATH}\")
7+
execute_process(COMMAND g-ir-scanner ${CFLAGS} -n ${GIR_NAME}
8+
--quiet
9+
--library ${TARGET_NAME} ${PACKAGES}
10+
-o ${CMAKE_CURRENT_BINARY_DIR}/${GIR_NAME}-${GRANITE_VERSION}.gir
11+
-L${CMAKE_CURRENT_BINARY_DIR}
12+
--nsversion=${GRANITE_VERSION} ${HEADER})")
13+
install(CODE "execute_process(COMMAND g-ir-compiler ${CMAKE_CURRENT_BINARY_DIR}/${GIR_NAME}-${GRANITE_VERSION}.gir -o ${CMAKE_CURRENT_BINARY_DIR}/${GIR_NAME}-${GRANITE_VERSION}.typelib)")
14+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${GIR_NAME}-${GRANITE_VERSION}.gir DESTINATION share/gir-1.0/)
15+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${GIR_NAME}-${GRANITE_VERSION}.typelib DESTINATION lib/girepository-1.0/)
16+
endmacro()
17+
18+
macro(add_target_gir_with_executable TARGET_NAME EXE_NAME GIR_NAME HEADER EXE_HEADER CFLAGS GRANITE_VERSION)
19+
set(PACKAGES "")
20+
foreach(PKG ${ARGN})
21+
set(PACKAGES ${PACKAGES} --include=${PKG})
22+
endforeach()
23+
install(CODE "set(ENV{LD_LIBRARY_PATH} \"${CMAKE_CURRENT_BINARY_DIR}:\$ENV{LD_LIBRARY_PATH}\")
24+
execute_process(COMMAND g-ir-scanner ${CFLAGS} -n ${GIR_NAME}
25+
--quiet
26+
--library ${TARGET_NAME} --program ${EXE_NAME} ${PACKAGES}
27+
-o ${CMAKE_CURRENT_BINARY_DIR}/${GIR_NAME}-${GRANITE_VERSION}.gir
28+
-L${CMAKE_CURRENT_BINARY_DIR}
29+
-I${CMAKE_CURRENT_BINARY_DIR}
30+
--nsversion=${GRANITE_VERSION} ${HEADER} ${EXE_HEADER})")
31+
install(CODE "execute_process(COMMAND g-ir-compiler ${CMAKE_CURRENT_BINARY_DIR}/${GIR_NAME}-${GRANITE_VERSION}.gir -o ${CMAKE_CURRENT_BINARY_DIR}/${GIR_NAME}-${GRANITE_VERSION}.typelib)")
32+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${GIR_NAME}-${GRANITE_VERSION}.gir DESTINATION share/gir-1.0/)
33+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${GIR_NAME}-${GRANITE_VERSION}.typelib DESTINATION lib/girepository-1.0/)
34+
endmacro()

cmake/GSettings.cmake

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# GSettings.cmake, CMake macros written for Marlin, feel free to re-use them.
2+
3+
option (GSETTINGS_LOCALINSTALL "Install GSettings Schemas locally instead of to the GLib prefix" ON)
4+
5+
option (GSETTINGS_COMPILE "Compile GSettings Schemas after installation" ${GSETTINGS_LOCALINSTALL})
6+
7+
if(GSETTINGS_LOCALINSTALL)
8+
message(STATUS "GSettings schemas will be installed locally.")
9+
endif()
10+
11+
if(GSETTINGS_COMPILE)
12+
message(STATUS "GSettings shemas will be compiled.")
13+
endif()
14+
15+
macro(add_schema SCHEMA_NAME)
16+
17+
set(PKG_CONFIG_EXECUTABLE pkg-config)
18+
# Have an option to not install the schema into where GLib is
19+
if (GSETTINGS_LOCALINSTALL)
20+
SET (GSETTINGS_DIR "${CMAKE_INSTALL_PREFIX}/share/glib-2.0/schemas/")
21+
else (GSETTINGS_LOCALINSTALL)
22+
execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} glib-2.0 --variable prefix OUTPUT_VARIABLE _glib_prefix OUTPUT_STRIP_TRAILING_WHITESPACE)
23+
SET (GSETTINGS_DIR "${_glib_prefix}/share/glib-2.0/schemas/")
24+
endif (GSETTINGS_LOCALINSTALL)
25+
26+
# Run the validator and error if it fails
27+
execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} gio-2.0 --variable glib_compile_schemas OUTPUT_VARIABLE _glib_comple_schemas OUTPUT_STRIP_TRAILING_WHITESPACE)
28+
execute_process (COMMAND ${_glib_comple_schemas} --dry-run --schema-file=${CMAKE_CURRENT_SOURCE_DIR}/${SCHEMA_NAME} ERROR_VARIABLE _schemas_invalid OUTPUT_STRIP_TRAILING_WHITESPACE)
29+
30+
if (_schemas_invalid)
31+
message (SEND_ERROR "Schema validation error: ${_schemas_invalid}")
32+
endif (_schemas_invalid)
33+
34+
# Actually install and recomple schemas
35+
message (STATUS "GSettings schemas will be installed into ${GSETTINGS_DIR}")
36+
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/${SCHEMA_NAME} DESTINATION ${GSETTINGS_DIR} OPTIONAL)
37+
38+
if (GSETTINGS_COMPILE)
39+
install (CODE "message (STATUS \"Compiling GSettings schemas\")")
40+
install (CODE "execute_process (COMMAND ${_glib_comple_schemas} ${GSETTINGS_DIR})")
41+
endif ()
42+
endmacro()

cmake/ParseArguments.cmake

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
##
2+
# This is a helper Macro to parse optional arguments in Macros/Functions
3+
# It has been taken from the public CMake wiki.
4+
# See http://www.cmake.org/Wiki/CMakeMacroParseArguments for documentation and
5+
# licensing.
6+
##
7+
macro(parse_arguments prefix arg_names option_names)
8+
set(DEFAULT_ARGS)
9+
foreach(arg_name ${arg_names})
10+
set(${prefix}_${arg_name})
11+
endforeach(arg_name)
12+
foreach(option ${option_names})
13+
set(${prefix}_${option} FALSE)
14+
endforeach(option)
15+
16+
set(current_arg_name DEFAULT_ARGS)
17+
set(current_arg_list)
18+
foreach(arg ${ARGN})
19+
set(larg_names ${arg_names})
20+
list(FIND larg_names "${arg}" is_arg_name)
21+
if(is_arg_name GREATER -1)
22+
set(${prefix}_${current_arg_name} ${current_arg_list})
23+
set(current_arg_name ${arg})
24+
set(current_arg_list)
25+
else(is_arg_name GREATER -1)
26+
set(loption_names ${option_names})
27+
list(FIND loption_names "${arg}" is_option)
28+
if(is_option GREATER -1)
29+
set(${prefix}_${arg} TRUE)
30+
else(is_option GREATER -1)
31+
set(current_arg_list ${current_arg_list} ${arg})
32+
endif(is_option GREATER -1)
33+
endif(is_arg_name GREATER -1)
34+
endforeach(arg)
35+
set(${prefix}_${current_arg_name} ${current_arg_list})
36+
endmacro(parse_arguments)

cmake/README

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Elementary CMake modules
2+
3+
This is a set of CMake modules: Translations, GSettings, and Vala modules.
4+
5+
For all the Vala related modules see README.Vala.rst:
6+
- ParseArguments.cmake
7+
- ValaPrecompile.cmake
8+
- ValaVersion.cmake
9+
- FindVala.cmake
10+

0 commit comments

Comments
 (0)