summaryrefslogtreecommitdiffstats
path: root/CMakeScripts/UseGlibMarshal.cmake
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 11:50:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 11:50:49 +0000
commitc853ffb5b2f75f5a889ed2e3ef89b818a736e87a (patch)
tree7d13a0883bb7936b84d6ecdd7bc332b41ed04bee /CMakeScripts/UseGlibMarshal.cmake
parentInitial commit. (diff)
downloadinkscape-8a99dde12f4056f9f3e8c91d10a929dbb60d0ab9.tar.xz
inkscape-8a99dde12f4056f9f3e8c91d10a929dbb60d0ab9.zip
Adding upstream version 1.3+ds.upstream/1.3+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'CMakeScripts/UseGlibMarshal.cmake')
-rw-r--r--CMakeScripts/UseGlibMarshal.cmake40
1 files changed, 40 insertions, 0 deletions
diff --git a/CMakeScripts/UseGlibMarshal.cmake b/CMakeScripts/UseGlibMarshal.cmake
new file mode 100644
index 0000000..8fabcaa
--- /dev/null
+++ b/CMakeScripts/UseGlibMarshal.cmake
@@ -0,0 +1,40 @@
+# - This is a module to Generate files using Glib-Marshal
+# Both the header and source files (.h and .cpp)
+# Copyright 2008 - Joshua L. Blocher
+#
+# And it defines the following variables:
+# GLIB_MARSHAL_PREFIX - The name of the files
+# GLIB_MARSHAL_FILE - File to Generate from (.list) and to generate to (.h and .cpp)
+# GLIB_MARSHAL_OUTPUT_HEADER - Result of Generation
+# GLIB_MARSHAL_OUTPUT_CPP - Result of Generation
+# GLIB_MARSHAL_OUTPUT_LOCATION - Where we are putting the Output
+
+find_program(GLIB_MARSHAL_EXECUTABLE NAMES glib-genmarshal PATHS /usr/local/bin )
+
+macro(GLIB_MARSHAL GLIB_MARSHAL_PREFIX GLIB_MARSHAL_FILE GLIB_MARSHAL_OUTPUT_LOCATION)
+ if(GLIB_MARSHAL_EXECUTABLE)
+ set(GLIB_MARSHAL_OUTPUT_EXTRA_LINE "#include \"${GLIB_MARSHAL_FILE}.h\" \n" )
+
+ message(STATUS "Generating header and sourcefiles from ${GLIB_MARSHAL_FILE}.list (Glib-Marshal)")
+ execute_process(COMMAND ${GLIB_MARSHAL_EXECUTABLE} --prefix=${GLIB_MARSHAL_PREFIX} --header ${CMAKE_CURRENT_SOURCE_DIR}/${GLIB_MARSHAL_FILE}.list
+ OUTPUT_VARIABLE GLIB_MARSHAL_OUTPUT_HEADER )
+ execute_process(COMMAND ${GLIB_MARSHAL_EXECUTABLE} --prefix=${GLIB_MARSHAL_PREFIX} --body ${CMAKE_CURRENT_SOURCE_DIR}/${GLIB_MARSHAL_FILE}.list
+ OUTPUT_VARIABLE GLIB_MARSHAL_OUTPUT_CPP )
+
+ # check whether the generated file is the same as the existing one
+ if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/${GLIB_MARSHAL_FILE}.h)
+ file(READ ${CMAKE_CURRENT_BINARY_DIR}/${GLIB_MARSHAL_FILE}.h GLIB_MARSHAL_HEADER_OLD)
+ else()
+ set(GLIB_MARSHAL_HEADER_OLD "")
+ endif()
+ if(NOT GLIB_MARSHAL_HEADER_OLD STREQUAL GLIB_MARSHAL_OUTPUT_HEADER)
+ message(STATUS "${GLIB_MARSHAL_FILE}.h changed; overwriting")
+ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${GLIB_MARSHAL_FILE}.h "${GLIB_MARSHAL_OUTPUT_HEADER}")
+ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${GLIB_MARSHAL_FILE}.cpp "${GLIB_MARSHAL_OUTPUT_EXTRA_LINE}")
+ file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/${GLIB_MARSHAL_FILE}.cpp "${GLIB_MARSHAL_OUTPUT_CPP}")
+ else()
+ message(STATUS "${GLIB_MARSHAL_FILE}.h unchanged")
+ endif()
+ endif()
+endmacro()
+