Skip to content

Commit

Permalink
conditionally use and link QT UI, lower UI priority
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubfi committed Feb 16, 2024
1 parent 0e66ddf commit 0c7cdf7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 7 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,14 @@ endif()

# --- QT

set(UI_QT OFF)
find_package(Qt5 COMPONENTS Widgets)

if (Qt5Widgets_FOUND)
message(STATUS "Found QT: ${Qt5Widgets_VERSION_STRING}")
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(UI_QT ON)
else()
message(STATUS "QT not found")
endif()
Expand Down Expand Up @@ -257,7 +259,7 @@ if(PULSEAUDIO_FOUND)
list(APPEND SOURCES_EM400 src/sound/pulseaudio.c)
endif()

if (Qt5Widgets_FOUND)
if (UI_QT)
list(APPEND SOURCES_EM400 src/ui/qt5/qt5.cpp)
list(APPEND SOURCES_EM400 src/ui/qt5/mainwindow.ui)
list(APPEND SOURCES_EM400 src/ui/qt5/mainwindow.cpp)
Expand Down Expand Up @@ -306,13 +308,14 @@ target_include_directories(em400 PRIVATE ${CMAKE_BINARY_DIR})
target_compile_definitions(em400 PRIVATE EM400_VERSION="${APP_VERSION}")
if(UI_CURSES)
target_compile_definitions(em400 PRIVATE UI_CURSES)
target_link_libraries(em400 ui-curses)
endif(UI_CURSES)

if(IPO_SUPPORTED)
set_property(TARGET em400 PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()

if (Qt5Widgets_FOUND)
if (UI_QT)
set_property(TARGET em400 PROPERTY AUTOMOC ON)
set_property(TARGET em400 PROPERTY AUTOUIC ON)
set_property(TARGET em400 PROPERTY AUTORCC ON)
Expand All @@ -323,6 +326,8 @@ if (Qt5Widgets_FOUND)
set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/uicurses_parser.h PROPERTY SKIP_AUTOGEN ON)
set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/uicurses_scanner.c PROPERTY SKIP_AUTOGEN ON)
target_include_directories(em400 PRIVATE ${Qt5Widgets_INCLUDE_DIRS})
target_compile_definitions(em400 PRIVATE UI_QT)
target_link_libraries(em400 ${Qt5Widgets_LIBRARIES})
endif()

target_link_libraries(em400
Expand All @@ -332,15 +337,8 @@ target_link_libraries(em400
${FLEX_LIBRARIES}
${BISON_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
${Qt5Widgets_LIBRARIES}
)

if(UI_CURSES)
target_link_libraries(em400
ui-curses
)
endif(UI_CURSES)

if(NOT WIN32)
target_link_libraries(em400
${RT_LIBRARY}
Expand Down
4 changes: 3 additions & 1 deletion src/ui/ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ extern struct ui_drv ui_qt5;

// in order of preference
struct ui_drv* uis[] = {
&ui_qt5,
#ifdef UI_CURSES
&ui_curses,
#endif
#ifdef UI_QT
&ui_qt5,
#endif
&ui_cmd,
NULL
Expand Down

0 comments on commit 0c7cdf7

Please sign in to comment.