summaryrefslogtreecommitdiffstats
path: root/CMakeScripts/UseGlibMarshal.cmake
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:24:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:24:48 +0000
commitcca66b9ec4e494c1d919bff0f71a820d8afab1fa (patch)
tree146f39ded1c938019e1ed42d30923c2ac9e86789 /CMakeScripts/UseGlibMarshal.cmake
parentInitial commit. (diff)
downloadinkscape-cca66b9ec4e494c1d919bff0f71a820d8afab1fa.tar.xz
inkscape-cca66b9ec4e494c1d919bff0f71a820d8afab1fa.zip
Adding upstream version 1.2.2.upstream/1.2.2upstream
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()
+