move glade files into resources inside the binary
This commit is contained in:
parent
f42a4c40fb
commit
302a0d1da7
@ -1,4 +1,16 @@
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_search_module(GLIB REQUIRED glib-2.0)
|
||||
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
|
||||
|
||||
project(gds-render)
|
||||
|
||||
add_subdirectory(glade)
|
||||
|
||||
include_directories(${GLIB_INCLUDE_DIRS} ${GTK3_INCLUDE_DIRS} "layer-widget")
|
||||
link_directories(${GLIB_LINK_DIRS} ${GTK3_LINK_DIRS})
|
||||
add_definitions(${GLIB2_CFLAGS_OTHER})
|
||||
|
||||
|
||||
aux_source_directory("layer-widget" SUB_SOURCES)
|
||||
set(SOURCE "main.c" "gdsparse.c" "layer-selector.c")
|
||||
@ -9,16 +21,9 @@ set(SOURCE
|
||||
${SUB_SOURCES}
|
||||
)
|
||||
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_search_module(GLIB REQUIRED glib-2.0)
|
||||
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
|
||||
|
||||
include_directories(${GLIB_INCLUDE_DIRS} ${GTK3_INCLUDE_DIRS} "layer-widget")
|
||||
link_directories(${GLIB_LINK_DIRS} ${GTK3_LINK_DIRS})
|
||||
configure_file(glade/main.glade glade/main.glade COPYONLY)
|
||||
configure_file(glade/layer-widget.glade glade/layer-widget.glade COPYONLY)
|
||||
|
||||
project(gds-render)
|
||||
add_executable(${PROJECT_NAME} ${SOURCE})
|
||||
|
||||
add_executable(${PROJECT_NAME} ${SOURCE} ${CMAKE_CURRENT_BINARY_DIR}/glade/resources.c)
|
||||
add_dependencies(${PROJECT_NAME} glib-resources)
|
||||
SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/glade/resources.c PROPERTIES GENERATED 1)
|
||||
target_link_libraries(${PROJECT_NAME} ${GLIB_LDFLAGS} ${GTK3_LDFLAGS} m)
|
||||
|
||||
|
10
glade/CMakeLists.txt
Normal file
10
glade/CMakeLists.txt
Normal file
@ -0,0 +1,10 @@
|
||||
add_custom_target(glib-resources DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/resources.c)
|
||||
add_custom_command(DEPENDS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/resources.xml
|
||||
OUTPUT
|
||||
${CMAKE_CURRENT_BINARY_DIR}/resources.c
|
||||
COMMAND
|
||||
echo "$(pwd)"
|
||||
COMMAND
|
||||
glib-compile-resources --target="${CMAKE_CURRENT_BINARY_DIR}/resources.c" --sourcedir="${CMAKE_CURRENT_SOURCE_DIR}" --generate-source "${CMAKE_CURRENT_SOURCE_DIR}/resources.xml"
|
||||
)
|
9
glade/resources.xml
Normal file
9
glade/resources.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<gresources>
|
||||
<gresource>
|
||||
<file compressed="true">main.glade</file>
|
||||
<file>layer-widget.glade</file>
|
||||
</gresource>
|
||||
</gresources>
|
||||
|
||||
|
@ -39,7 +39,7 @@ static void layer_element_init(LayerElement *self)
|
||||
{
|
||||
GtkBuilder *builder;
|
||||
GtkWidget *glade_box;
|
||||
builder = gtk_builder_new_from_file("glade/layer-widget.glade");
|
||||
builder = gtk_builder_new_from_resource("/layer-widget.glade");
|
||||
glade_box = GTK_WIDGET(gtk_builder_get_object(builder, "box"));
|
||||
gtk_box_pack_start(GTK_BOX(self), glade_box, TRUE, TRUE, 0);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user