Adding xml file to cmake project

Hi all,

I have a project on C that uses GTK+3 and glade, I’m compiling using cmake on CLion IDE.

My problem arises when I call a file.glade file into my code giving me a not found error.
Here’s my CMakeLists.txt file:

cmake_minimum_required(VERSION 3.23)
project(sync_select_files C)

set(CMAKE_C_STANDARD 11)

# Find dependencies
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
pkg_check_modules(GTK3 REQUIRED gtksourceview-4)
link_directories(${GTK3_LIBRARY_DIRS})
link_directories(${GTKSOURCEVIEW_LIBRARY_DIRS})
add_compile_options(${GTK3_CFLAGS_OTHER})
add_compile_options(${GTKSOURCEVIEW_FLAGS_OTHER})
set(LIBRARIES ${LIBRARIES} ${GTK3_LIBRARIES})

set(FLAGS "-I${GTK3_INCLUDE_DIRS}")
message(STATUS "Flags: ${FLAGS}")
string(REPLACE ";" " -I" FLAGS "${FLAGS}")
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} ${GTK3_FLAGS} ${FLAGS})

# Compile
add_executable(ssf src/ssf.c src/ssf_app.c src/ssf_window.c src/ssf_content.c)

target_link_libraries(ssf ${LIBRARIES})

Could anyone help me to correctly compile my code please? Thanks in advance.

You can do one of the following:

  1. Install the xml file to the data dir (i.e. /usr/share/ssf) using install and then load it from there.

  2. Use a cmake script like GCR_CMake to compile the xml files into a bundle, then load the bundle.

  3. Use a cmake script like GCR_CMake to compile the xml files into the program.