diff --git a/CMakeLists.txt b/CMakeLists.txt index 3701bc1..b153ce3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) + diff --git a/glade/CMakeLists.txt b/glade/CMakeLists.txt new file mode 100644 index 0000000..6570bad --- /dev/null +++ b/glade/CMakeLists.txt @@ -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" + ) diff --git a/glade/resources.xml b/glade/resources.xml new file mode 100644 index 0000000..3603dd0 --- /dev/null +++ b/glade/resources.xml @@ -0,0 +1,9 @@ + + + + main.glade + layer-widget.glade + + + + diff --git a/layer-widget/layer-element.c b/layer-widget/layer-element.c index 38a3530..9d7ce8a 100644 --- a/layer-widget/layer-element.c +++ b/layer-widget/layer-element.c @@ -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); diff --git a/main.c b/main.c index 6fdcc35..7a27ed2 100644 --- a/main.c +++ b/main.c @@ -156,7 +156,7 @@ int main(int argc, char **argv) gtk_init(&argc, &argv); - main_builder = gtk_builder_new_from_file("glade/main.glade"); + main_builder = gtk_builder_new_from_resource("/main.glade"); gtk_builder_connect_signals(main_builder, NULL);