Skip to content

Commit

Permalink
Improved cmake-config for GUI build
Browse files Browse the repository at this point in the history
  • Loading branch information
Nightwalker-87 committed May 19, 2020
1 parent 7ef0637 commit 5fc02ab
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 29 deletions.
57 changes: 30 additions & 27 deletions src/stlink-gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,40 @@
# Build GUI
###

## GUI-Building requires the presence of a GTK3 toolset
if (NOT GTK3_FOUND)
message(STATUS "GTK3 not found!")
return() # no GTK3 present => no GUI build
else (GTK3_FOUND)
message(STATUS "Found GTK3: -I${GTK3_INCLUDE_DIRS}, ${GTK3_LIBRARIES}")
endif ()
if (NOT WIN32)
## GUI-Building requires the presence of a GTK3 toolset
if (NOT GTK3_FOUND)
message(STATUS "GTK3 not found!")
return() # no GTK3 present => no GUI build
else (GTK3_FOUND)
message(STATUS "Found GTK3: -I${GTK3_INCLUDE_DIRS}, ${GTK3_LIBRARIES}")
include_directories(SYSTEM ${GTK3_INCLUDE_DIRS})

# Install desktop application entry
install(FILES stlink-gui.desktop
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/applications)

include_directories(SYSTEM ${GTK3_INCLUDE_DIRS})
# Install icons
install(FILES icons/stlink-gui.svg
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/icons/hicolor/scalable/apps)

set(GUI_SOURCES gui.c gui.h)
set(GUI_SOURCES gui.c gui.h)

## stlink-gui-local
add_executable(stlink-gui-local ${GUI_SOURCES})
set_target_properties(stlink-gui-local PROPERTIES
# Note: ${CMAKE_CURRENT_SOURCE_DIR} is src/stlink-gui
COMPILE_DEFINITIONS STLINK_UI_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
target_link_libraries(stlink-gui-local ${STLINK_LIB_SHARED} ${SSP_LIB} ${GTK3_LDFLAGS})
## stlink-gui-local
add_executable(stlink-gui-local ${GUI_SOURCES})
file(COPY stlink-gui.ui DESTINATION ${CMAKE_BINARY_DIR}/bin)
set_target_properties(stlink-gui-local PROPERTIES
COMPILE_DEFINITIONS STLINK_UI_DIR="${CMAKE_BINARY_DIR}/bin")
target_link_libraries(stlink-gui-local ${STLINK_LIB_SHARED} ${SSP_LIB} ${GTK3_LDFLAGS})

## stlink-gui
add_executable(stlink-gui ${GUI_SOURCES})
set_target_properties(stlink-gui PROPERTIES
COMPILE_DEFINITIONS STLINK_UI_DIR="${CMAKE_INSTALL_BINDIR}")
target_link_libraries(stlink-gui ${STLINK_LIB_SHARED} ${SSP_LIB} ${GTK3_LDFLAGS})
## stlink-gui
add_executable(stlink-gui ${GUI_SOURCES})
install(FILES stlink-gui.ui DESTINATION ${CMAKE_INSTALL_BINDIR})
set_target_properties(stlink-gui PROPERTIES
COMPILE_DEFINITIONS STLINK_UI_DIR="${CMAKE_INSTALL_PREFIX}/bin")
target_link_libraries(stlink-gui ${STLINK_LIB_SHARED} ${SSP_LIB} ${GTK3_LDFLAGS})
install(TARGETS stlink-gui DESTINATION ${CMAKE_INSTALL_BINDIR})

install(TARGETS stlink-gui DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES stlink-gui.ui DESTINATION ${CMAKE_INSTALL_BINDIR})

if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
# Install desktop application entry
install(FILES stlink-gui.desktop DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/applications)
# Install icons
install(FILES icons/stlink-gui.svg DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/icons/hicolor/scalable/apps)
endif ()
endif ()
3 changes: 1 addition & 2 deletions src/stlink-gui/gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -781,8 +781,7 @@ static void stlink_gui_build_ui (STlinkGUI *gui) {
GtkListStore *filemem_store;
gchar *ui_file = STLINK_UI_DIR "/stlink-gui.ui";

if (!g_file_test (ui_file, G_FILE_TEST_EXISTS))
ui_file = "stlink-gui.ui";
if (!g_file_test (ui_file, G_FILE_TEST_EXISTS)) ui_file = "stlink-gui.ui";
builder = gtk_builder_new ();
if (!gtk_builder_add_from_file (builder, ui_file, NULL)) {
g_printerr ("Failed to load UI file: %s\n", ui_file);
Expand Down

0 comments on commit 5fc02ab

Please sign in to comment.