From cca66b9ec4e494c1d919bff0f71a820d8afab1fa Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:24:48 +0200 Subject: Adding upstream version 1.2.2. Signed-off-by: Daniel Baumann --- CMakeScripts/UseGlibMarshal.cmake | 40 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 CMakeScripts/UseGlibMarshal.cmake (limited to 'CMakeScripts/UseGlibMarshal.cmake') 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() + -- cgit v1.2.3