diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2024-08-19 09:11:09 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2024-08-19 09:11:09 +0200 |
| commit | e2dad5f30ca4d8502558e0560d2059a51aae4c4c (patch) | |
| tree | 4be91eaa56c58403d77c6a5b694a9ddc49a4b481 /cmake/Modules | |
| parent | a4e62c525fdc6b9662cdd48aaef2de7e9376f062 (diff) | |
| download | turns-e2dad5f30ca4d8502558e0560d2059a51aae4c4c.tar.xz turns-e2dad5f30ca4d8502558e0560d2059a51aae4c4c.zip | |
core: add settings accessor
Diffstat (limited to 'cmake/Modules')
| -rw-r--r-- | cmake/Modules/GlibCompileSchemas.cmake | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/cmake/Modules/GlibCompileSchemas.cmake b/cmake/Modules/GlibCompileSchemas.cmake new file mode 100644 index 0000000..1595e36 --- /dev/null +++ b/cmake/Modules/GlibCompileSchemas.cmake @@ -0,0 +1,44 @@ +find_program(GLIB_COMPILE_SCHEMAS_BIN + NAMES "glib-compile-schemas" + REQUIRED +) + +function(target_add_glib_schemas TARGET) + set(SINGLE_VALUE_ARGS "SCHEMA_DIR") + cmake_parse_arguments( + PARSE_ARGV 1 + "" + "${OPTIONS}" + "${SINGLE_VALUE_ARGS}" + "${MULTI_VALUE_ARGS}" + ) + + if(NOT TARGET "${TARGET}") + message(FATAL_ERROR "Target '${TARGET}' does not exist") + endif() + + if(NOT IS_ABSOLUTE "${_SCHEMA_DIR}") + get_filename_component(_SCHEMA_DIR "${_SCHEMA_DIR}" REALPATH) + endif() + + if(NOT IS_DIRECTORY "${_SCHEMA_DIR}") + message(FATAL_ERROR "Directory '${_SCHEMA_DIR}' does not exists") + endif() + + file(GLOB SCHAMA_FILES CONFIGURE_DEPENDS "${_SCHEMA_DIR}/*.gschema.xml") + + add_custom_command(TARGET "${TARGET}" + PRE_BUILD + BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/glib-2.0/schemas/gschemas.compiled" + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" + COMMAND "${GLIB_COMPILE_SCHEMAS_BIN}" + ARGS + "--targetdir=${CMAKE_CURRENT_BINARY_DIR}/glib-2.0/schemas" + "--strict" + "${_SCHEMA_DIR}" + VERBATIM + COMMENT "Compiling gsettings schemas" + DEPENDS + ${SCHEMA_FILES} + ) +endfunction() |
