0

GTK project has the ability to bundle resources as library with the executable target, and it is done with the help of glib-compile-resources program.

I have to compile my resources first before building the target project but CMake's add_custom_command() is not doing anything at all in this sample dummy project:

cmake_minimum_required(VERSION 3.15)

project(dummy)

find_program(GLIB_COMPILE_RESOURCES NAMES glib-compile-resources REQUIRED)
mark_as_advanced(GLIB_COMPILE_RESOURCES)

set(GRESOURCE test.gresource)
set(GRESOURCE_XML test.gresource.xml)

add_custom_command(
    OUTPUT ${GRESOURCE}
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
    COMMAND ${GLIB_COMPILE_RESOURCES}
    ARGS
        --target=${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE}
        ${GRESOURCE_XML}
    VERBATIM
    MAIN_DEPENDENCY ${GRESOURCE_XML}
    DEPENDS
        hello.txt
        world.txt
)

My expected output is the generated test.gresource from test.gresource.xml file, however, I don't find that file in the out-of-source build directory.

0 Answers0