mirror of
https://github.com/EdgeTX/edgetx.git
synced 2025-07-24 16:55:15 +03:00
[build] Only build companion/simulator resources files once. (#4670)
* [build] Only build companion/simulator resources files once and include in common lib; Consolidate/cosmetics. * [build] Fix "missing" translation resource files with some builds (since last commit); move resource file declarations to after app init as recommended; fix name of Qt translation file since v5.3 (this still only works on some systems with Qt installed and on the build machine).
This commit is contained in:
parent
4faf323aed
commit
919e8eb962
3 changed files with 50 additions and 45 deletions
|
@ -100,6 +100,7 @@ use_cxx11() # ensure gnu++11 in CXX_FLAGS with CMake < 3.1
|
||||||
include_directories(
|
include_directories(
|
||||||
${CMAKE_BINARY_DIR}
|
${CMAKE_BINARY_DIR}
|
||||||
${CMAKE_CURRENT_BINARY_DIR}
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
${CMAKE_SOURCE_DIR}
|
||||||
${COMPANION_SRC_DIRECTORY}
|
${COMPANION_SRC_DIRECTORY}
|
||||||
${COMPANION_SRC_DIRECTORY}/shared
|
${COMPANION_SRC_DIRECTORY}/shared
|
||||||
${SIMU_SRC_DIRECTORY}
|
${SIMU_SRC_DIRECTORY}
|
||||||
|
@ -109,6 +110,11 @@ include_directories(
|
||||||
${COMPANION_SRC_DIRECTORY}/storage
|
${COMPANION_SRC_DIRECTORY}/storage
|
||||||
)
|
)
|
||||||
|
|
||||||
|
configure_file(${COMPANION_SRC_DIRECTORY}/version.h.in ${CMAKE_BINARY_DIR}/version.h @ONLY)
|
||||||
|
configure_file(${COMPANION_SRC_DIRECTORY}/translations.qrc.in ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc @ONLY)
|
||||||
|
configure_file(${COMPANION_SRC_DIRECTORY}/companion.desktop.in ${CMAKE_CURRENT_BINARY_DIR}/companion.desktop @ONLY)
|
||||||
|
configure_file(${COMPANION_SRC_DIRECTORY}/simulator.desktop.in ${CMAKE_CURRENT_BINARY_DIR}/simulator.desktop @ONLY)
|
||||||
|
|
||||||
############# Supporting libraries ###############
|
############# Supporting libraries ###############
|
||||||
|
|
||||||
add_subdirectory(shared)
|
add_subdirectory(shared)
|
||||||
|
@ -144,11 +150,25 @@ set(common_MOC_HDRS
|
||||||
modeledit/node.h
|
modeledit/node.h
|
||||||
)
|
)
|
||||||
|
|
||||||
qt5_wrap_cpp(common_SRCS ${common_MOC_HDRS})
|
set(common_RESOURCES
|
||||||
|
companion.qrc
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/translations.qrc
|
||||||
|
)
|
||||||
|
|
||||||
add_library(common ${common_SRCS})
|
set(LANGUAGES pl de fr es it sv cs fi zh)
|
||||||
|
foreach(language ${LANGUAGES})
|
||||||
|
list(APPEND common_TS translations/companion_${language}.ts)
|
||||||
|
endforeach(language)
|
||||||
|
|
||||||
|
qt5_wrap_cpp(common_SRCS ${common_MOC_HDRS})
|
||||||
|
qt5_add_translation(common_QM ${common_TS})
|
||||||
|
qt5_add_resources(common_RCC ${common_RESOURCES})
|
||||||
|
add_custom_target(gen_qrc DEPENDS ${common_RCC} ${common_QM})
|
||||||
|
|
||||||
|
add_library(common ${common_SRCS} ${common_RCC})
|
||||||
qt5_use_modules(common Core Xml Widgets)
|
qt5_use_modules(common Core Xml Widgets)
|
||||||
target_link_libraries(common simulation)
|
target_link_libraries(common PRIVATE simulation)
|
||||||
|
add_dependencies(common gen_qrc)
|
||||||
|
|
||||||
############# Companion ###############
|
############# Companion ###############
|
||||||
|
|
||||||
|
@ -238,39 +258,15 @@ set(companion_UIS
|
||||||
radionotfound.ui
|
radionotfound.ui
|
||||||
)
|
)
|
||||||
|
|
||||||
set(companion_RESOURCES
|
|
||||||
companion.qrc
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/translations.qrc
|
|
||||||
)
|
|
||||||
|
|
||||||
configure_file(${COMPANION_SRC_DIRECTORY}/version.h.in ${CMAKE_BINARY_DIR}/version.h @ONLY)
|
|
||||||
configure_file(${COMPANION_SRC_DIRECTORY}/translations.qrc.in ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc @ONLY)
|
|
||||||
configure_file(${COMPANION_SRC_DIRECTORY}/companion.desktop.in ${CMAKE_CURRENT_BINARY_DIR}/companion.desktop @ONLY)
|
|
||||||
configure_file(${COMPANION_SRC_DIRECTORY}/simulator.desktop.in ${CMAKE_CURRENT_BINARY_DIR}/simulator.desktop @ONLY)
|
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
list(APPEND companion_SRCS icon.rc)
|
list(APPEND companion_SRCS icon.rc)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include_directories(${CMAKE_BINARY_DIR})
|
|
||||||
include_directories(${CMAKE_SOURCE_DIR})
|
|
||||||
|
|
||||||
set(LANGUAGES pl de fr es it sv cs fi zh)
|
|
||||||
foreach(language ${LANGUAGES})
|
|
||||||
list(APPEND companion_TS translations/companion_${language}.ts)
|
|
||||||
endforeach(language)
|
|
||||||
|
|
||||||
qt5_wrap_ui(companion_SRCS ${companion_UIS})
|
qt5_wrap_ui(companion_SRCS ${companion_UIS})
|
||||||
qt5_wrap_cpp(companion_SRCS ${companion_MOC_HDRS})
|
qt5_wrap_cpp(companion_SRCS ${companion_MOC_HDRS})
|
||||||
qt5_add_translation(companion_QM ${companion_TS})
|
|
||||||
qt5_add_resources(companion_RCC ${companion_RESOURCES})
|
|
||||||
add_custom_target(gen_qrc DEPENDS ${companion_RCC} ${companion_QM})
|
|
||||||
|
|
||||||
add_executable(${COMPANION_NAME} MACOSX_BUNDLE ${WIN_EXECUTABLE_TYPE} ${companion_SRCS} ${companion_RCC})
|
add_executable(${COMPANION_NAME} MACOSX_BUNDLE ${WIN_EXECUTABLE_TYPE} ${companion_SRCS})
|
||||||
|
|
||||||
add_dependencies(${COMPANION_NAME} gen_qrc)
|
|
||||||
qt5_use_modules(${COMPANION_NAME} Core Widgets Network)
|
qt5_use_modules(${COMPANION_NAME} Core Widgets Network)
|
||||||
|
|
||||||
target_link_libraries(${COMPANION_NAME} PRIVATE generaledit modeledit simulation common qcustomplot shared storage ${PTHREAD_LIBRARY} ${SDL_LIBRARY} ${WIN_LINK_LIBRARIES})
|
target_link_libraries(${COMPANION_NAME} PRIVATE generaledit modeledit simulation common qcustomplot shared storage ${PTHREAD_LIBRARY} ${SDL_LIBRARY} ${WIN_LINK_LIBRARIES})
|
||||||
|
|
||||||
PrintTargetReport("${COMPANION_NAME}")
|
PrintTargetReport("${COMPANION_NAME}")
|
||||||
|
@ -283,9 +279,7 @@ if(WIN32)
|
||||||
list(APPEND simu_SRCS icon.rc)
|
list(APPEND simu_SRCS icon.rc)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_executable(${SIMULATOR_NAME} MACOSX_BUNDLE ${WIN_EXECUTABLE_TYPE} ${simu_SRCS} ${companion_RCC})
|
add_executable(${SIMULATOR_NAME} MACOSX_BUNDLE ${WIN_EXECUTABLE_TYPE} ${simu_SRCS})
|
||||||
add_dependencies(${SIMULATOR_NAME} gen_qrc)
|
|
||||||
|
|
||||||
target_link_libraries(${SIMULATOR_NAME} PRIVATE simulation common storage qxtcommandoptions ${PTHREAD_LIBRARY} ${SDL_LIBRARY} ${WIN_LINK_LIBRARIES})
|
target_link_libraries(${SIMULATOR_NAME} PRIVATE simulation common storage qxtcommandoptions ${PTHREAD_LIBRARY} ${SDL_LIBRARY} ${WIN_LINK_LIBRARIES})
|
||||||
|
|
||||||
############# Translations ####################
|
############# Translations ####################
|
||||||
|
@ -295,7 +289,7 @@ if(LUPDATE_FOUND)
|
||||||
message(STATUS "Qt lupdate: " ${LUPDATE_EXECUTABLE})
|
message(STATUS "Qt lupdate: " ${LUPDATE_EXECUTABLE})
|
||||||
add_custom_target(translations
|
add_custom_target(translations
|
||||||
WORKING_DIRECTORY ${COMPANION_SRC_DIRECTORY}
|
WORKING_DIRECTORY ${COMPANION_SRC_DIRECTORY}
|
||||||
COMMAND ${LUPDATE_EXECUTABLE} ${CMAKE_SOURCE_DIR} -no-obsolete -ts ${companion_TS}
|
COMMAND ${LUPDATE_EXECUTABLE} ${CMAKE_SOURCE_DIR} -no-obsolete -ts ${common_TS}
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
message(STATUS "Qt lupdate not found, 'translations' target will not be availabe.")
|
message(STATUS "Qt lupdate not found, 'translations' target will not be availabe.")
|
||||||
|
|
|
@ -51,17 +51,17 @@ class MyProxyStyle : public QProxyStyle
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
Q_INIT_RESOURCE(companion);
|
|
||||||
|
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
|
|
||||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
app.setApplicationName(APP_COMPANION);
|
app.setApplicationName(APP_COMPANION);
|
||||||
app.setOrganizationName(COMPANY);
|
app.setOrganizationName(COMPANY);
|
||||||
app.setOrganizationDomain(COMPANY_DOMAIN);
|
app.setOrganizationDomain(COMPANY_DOMAIN);
|
||||||
app.setAttribute(Qt::AA_DontShowIconsInMenus, false);
|
app.setAttribute(Qt::AA_DontShowIconsInMenus, false);
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
|
||||||
|
app.setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Q_INIT_RESOURCE(companion);
|
||||||
|
Q_INIT_RESOURCE(translations);
|
||||||
|
|
||||||
if (AppDebugMessageHandler::instance())
|
if (AppDebugMessageHandler::instance())
|
||||||
AppDebugMessageHandler::instance()->installAppMessageHandler();
|
AppDebugMessageHandler::instance()->installAppMessageHandler();
|
||||||
|
@ -84,7 +84,12 @@ int main(int argc, char *argv[])
|
||||||
QTranslator companionTranslator;
|
QTranslator companionTranslator;
|
||||||
companionTranslator.load(":/companion_" + g.locale());
|
companionTranslator.load(":/companion_" + g.locale());
|
||||||
QTranslator qtTranslator;
|
QTranslator qtTranslator;
|
||||||
qtTranslator.load((QString)"qt_" + g.locale().left(2), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
|
||||||
|
QString qtfile = "qtbase_";
|
||||||
|
#else
|
||||||
|
QString qtfile = "qt_";
|
||||||
|
#endif
|
||||||
|
qtTranslator.load(qtfile + g.locale().left(2), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
||||||
app.installTranslator(&companionTranslator);
|
app.installTranslator(&companionTranslator);
|
||||||
app.installTranslator(&qtTranslator);
|
app.installTranslator(&qtTranslator);
|
||||||
|
|
||||||
|
|
|
@ -73,16 +73,17 @@ void sharedHelpText(QTextStream &stream)
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
Q_INIT_RESOURCE(companion);
|
|
||||||
|
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
|
|
||||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
app.setApplicationName(APP_SIMULATOR);
|
app.setApplicationName(APP_SIMULATOR);
|
||||||
app.setOrganizationName(COMPANY);
|
app.setOrganizationName(COMPANY);
|
||||||
app.setOrganizationDomain(COMPANY_DOMAIN);
|
app.setOrganizationDomain(COMPANY_DOMAIN);
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
|
||||||
|
app.setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Q_INIT_RESOURCE(companion);
|
||||||
|
Q_INIT_RESOURCE(translations);
|
||||||
|
|
||||||
if (AppDebugMessageHandler::instance())
|
if (AppDebugMessageHandler::instance())
|
||||||
AppDebugMessageHandler::instance()->installAppMessageHandler();
|
AppDebugMessageHandler::instance()->installAppMessageHandler();
|
||||||
|
@ -96,7 +97,12 @@ int main(int argc, char *argv[])
|
||||||
QTranslator companionTranslator;
|
QTranslator companionTranslator;
|
||||||
companionTranslator.load(":/companion_" + g.locale());
|
companionTranslator.load(":/companion_" + g.locale());
|
||||||
QTranslator qtTranslator;
|
QTranslator qtTranslator;
|
||||||
qtTranslator.load((QString)"qt_" + g.locale().left(2), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
|
||||||
|
QString qtfile = "qtbase_";
|
||||||
|
#else
|
||||||
|
QString qtfile = "qt_";
|
||||||
|
#endif
|
||||||
|
qtTranslator.load(qtfile + g.locale().left(2), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
||||||
app.installTranslator(&companionTranslator);
|
app.installTranslator(&companionTranslator);
|
||||||
app.installTranslator(&qtTranslator);
|
app.installTranslator(&qtTranslator);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue