diff --git a/development/cmake/modules/LyXMacros.cmake b/development/cmake/modules/LyXMacros.cmake index 2b62513065..36dac00e1e 100644 --- a/development/cmake/modules/LyXMacros.cmake +++ b/development/cmake/modules/LyXMacros.cmake @@ -204,3 +204,29 @@ macro(lyx_const_touched_files _allinone_name _list) endmacro(lyx_const_touched_files) +macro(lyx_qt_resources_file _qrc_name _to_dir _list) + if (NOT EXISTS ${_qrc_name}) + set(_rebuild_file 1) + else() + FILE(READ ${_qrc_name} _file_content) + if (NOT _file_content) + set(_rebuild_file 1) + endif() + endif() + + if (_rebuild_file) + message(STATUS "Generating ${_qrc_name}") + file(WRITE ${_qrc_name} "\n") + file(APPEND ${_qrc_name} "\n") + + foreach (_current_FILE ${${_list}}) + get_filename_component(_abs_FILE ${_current_FILE} ABSOLUTE) + string(REGEX REPLACE "${_to_dir}" "" _file_name ${_abs_FILE}) + file(APPEND ${_qrc_name} " ${_abs_FILE}\n") + endforeach (_current_FILE) + + file(APPEND ${_qrc_name} "\n") + file(APPEND ${_qrc_name} "\n") + endif() +endmacro(lyx_const_touched_files) + diff --git a/development/cmake/src/frontends/qt4/CMakeLists.txt b/development/cmake/src/frontends/qt4/CMakeLists.txt index 6cf8a5e943..1d6e658e72 100644 --- a/development/cmake/src/frontends/qt4/CMakeLists.txt +++ b/development/cmake/src/frontends/qt4/CMakeLists.txt @@ -19,6 +19,12 @@ lyx_automoc(${frontends_qt4_sources}) lyx_add_ui_files(frontends_qt4_sources ui_files ${frontend_qt4_UI}) +file(GLOB_RECURSE frontend_qt4_images ${TOP_SRC_DIR}/lib/images/*.png) +set(resource_name ${CMAKE_CURRENT_BINARY_DIR}/Resources.qrc) +lyx_qt_resources_file(${resource_name} "${TOP_SRC_DIR}/lib/" frontend_qt4_images) +qt4_add_resources(resource_files ${resource_name}) + + add_definitions(-DQT_GENUINE_STR -DLYX_BUILD_QT4_FRONTEND) include_directories( @@ -34,12 +40,13 @@ if(MERGE_FILES) set_source_files_properties(_allinone_touched.C PROPERTIES OBJECT_DEPENDS "${depends_moc_uic}") add_library(frontend_qt4 ${library_type} - ${_allinone_files} ${frontends_qt4_headers} ${ui_files}) + ${_allinone_files} ${frontends_qt4_headers} ${ui_files} ${resource_files}) else() add_library(frontend_qt4 ${library_type} - ${frontends_qt4_sources} ${frontends_qt4_headers} ${ui_files}) + ${frontends_qt4_sources} ${frontends_qt4_headers} ${ui_files} ${resource_files}) endif() + target_link_libraries(frontend_qt4 frontends ${QT_QTCORE_LIBRARY} diff --git a/src/frontends/qt4/GuiToolbar.cpp b/src/frontends/qt4/GuiToolbar.cpp index 9c58a2cab3..921c5b3f20 100644 --- a/src/frontends/qt4/GuiToolbar.cpp +++ b/src/frontends/qt4/GuiToolbar.cpp @@ -45,10 +45,9 @@ static void initializeResources() { - extern void qInitResources(); static bool initialized = false; if (!initialized) { - qInitResources(); + Q_INIT_RESOURCE(Resources); initialized = true; } }