From 3e9b3045f914ee5feb7676b50995e6b076746115 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Fri, 27 Mar 2015 13:42:10 +0000 Subject: [PATCH] Tidy up resource generation with a CMake function This change generates all the resources using a CMake function add_resources() and substitution into a template .qrc file. The location of resource files in the source tree is no longer related to the path of the resources in the embedded executable resources file system. Instead the roesources are embedded with predetermined paths e.g. :/, :/Palettes/ and, :/samples/ . git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@5131 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- CMakeLists.txt | 67 ++++++++++++++++++++++++++++++++++++++++++++------ wsjtx.qrc.in | 41 +++--------------------------- 2 files changed, 63 insertions(+), 45 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a9aee3b17..494da0d06 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -383,19 +383,50 @@ set (all_C_and_CXXSRCS ${all_CXXSRCS} ) +set (TOP_LEVEL_RESOURCES + shortcuts.txt + mouse_commands.txt + prefixes.txt + cty.dat + kvasd.dat + ) + +set (PALETTE_FILES + Palettes/Banana.pal + Palettes/Blue1.pal + Palettes/Blue2.pal + Palettes/Blue3.pal + Palettes/Brown.pal + Palettes/Cyan1.pal + Palettes/Cyan2.pal + Palettes/Cyan3.pal + Palettes/Default.pal + Palettes/Digipan.pal + Palettes/Fldigi.pal + Palettes/Gray1.pal + Palettes/Gray2.pal + Palettes/Green1.pal + Palettes/Green2.pal + Palettes/Jungle.pal + Palettes/Linrad.pal + Palettes/Negative.pal + Palettes/Orange.pal + Palettes/Pink.pal + Palettes/Rainbow.pal + Palettes/Scope.pal + Palettes/Sunburst.pal + Palettes/VK4BDJ.pal + Palettes/YL2KF.pal + Palettes/Yellow1.pal + Palettes/Yellow2.pal + Palettes/ZL1FZ.pal +) + set (SAMPLE_FILES samples/130418_1742.wav samples/130610_2343.wav ) -if (WSJT_EMBED_SAMPLES) - foreach (SAMPLE ${SAMPLE_FILES}) - set (SAMPLE_PATHS "${SAMPLE_PATHS}\n ${CMAKE_SOURCE_DIR}/${SAMPLE}") - endforeach (SAMPLE ${SAMPLE_FILES}) -endif (WSJT_EMBED_SAMPLES) - -configure_file (wsjtx.qrc.in wsjtx.qrc @ONLY) - if (APPLE) set (WSJTX_ICON_FILE ${CMAKE_PROJECT_NAME}.icns) set (ICONSRCS @@ -688,6 +719,26 @@ elseif (CMAKE_HOST_WIN32) endif () +# embedded resources +function (add_resources resources path) + foreach (resource_file_ ${ARGN}) + get_filename_component (name_ ${resource_file_} NAME) + file (TO_NATIVE_PATH ${CMAKE_SOURCE_DIR}/${resource_file_} source_) + file (TO_NATIVE_PATH ${path}/${name_} dest_) + set (resources_ "${resources_}\n ${source_}") + set (${resources} ${${resources}}${resources_} PARENT_SCOPE) + endforeach (resource_file_ ${ARGN}) +endfunction (add_resources resources path) + +add_resources (wsjtx_RESOURCES "" ${TOP_LEVEL_RESOURCES}) +add_resources (wsjtx_RESOURCES /Palettes ${PALETTE_FILES}) +if (WSJT_EMBED_SAMPLES) + add_resources (wsjtx_RESOURCES /samples ${SAMPLE_FILES}) +endif (WSJT_EMBED_SAMPLES) + +configure_file (wsjtx.qrc.in wsjtx.qrc @ONLY) + + # UI generation qt5_wrap_ui (wsjt_qt_GENUISRCS ${wsjt_qt_UISRCS}) qt5_wrap_ui (wsjtx_GENUISRCS ${wsjtx_UISRCS}) diff --git a/wsjtx.qrc.in b/wsjtx.qrc.in index 0072c2ee5..ffa9bf887 100644 --- a/wsjtx.qrc.in +++ b/wsjtx.qrc.in @@ -1,38 +1,5 @@ - - - @CMAKE_SOURCE_DIR@/shortcuts.txt - @CMAKE_SOURCE_DIR@/mouse_commands.txt - @CMAKE_SOURCE_DIR@/prefixes.txt - @CMAKE_SOURCE_DIR@/cty.dat - @CMAKE_SOURCE_DIR@/kvasd.dat - @CMAKE_SOURCE_DIR@/Palettes/Banana.pal - @CMAKE_SOURCE_DIR@/Palettes/Blue1.pal - @CMAKE_SOURCE_DIR@/Palettes/Blue2.pal - @CMAKE_SOURCE_DIR@/Palettes/Blue3.pal - @CMAKE_SOURCE_DIR@/Palettes/Brown.pal - @CMAKE_SOURCE_DIR@/Palettes/Cyan1.pal - @CMAKE_SOURCE_DIR@/Palettes/Cyan2.pal - @CMAKE_SOURCE_DIR@/Palettes/Cyan3.pal - @CMAKE_SOURCE_DIR@/Palettes/Default.pal - @CMAKE_SOURCE_DIR@/Palettes/Digipan.pal - @CMAKE_SOURCE_DIR@/Palettes/Fldigi.pal - @CMAKE_SOURCE_DIR@/Palettes/Gray1.pal - @CMAKE_SOURCE_DIR@/Palettes/Gray2.pal - @CMAKE_SOURCE_DIR@/Palettes/Green1.pal - @CMAKE_SOURCE_DIR@/Palettes/Green2.pal - @CMAKE_SOURCE_DIR@/Palettes/Jungle.pal - @CMAKE_SOURCE_DIR@/Palettes/Linrad.pal - @CMAKE_SOURCE_DIR@/Palettes/Negative.pal - @CMAKE_SOURCE_DIR@/Palettes/Orange.pal - @CMAKE_SOURCE_DIR@/Palettes/Pink.pal - @CMAKE_SOURCE_DIR@/Palettes/Rainbow.pal - @CMAKE_SOURCE_DIR@/Palettes/Scope.pal - @CMAKE_SOURCE_DIR@/Palettes/Sunburst.pal - @CMAKE_SOURCE_DIR@/Palettes/VK4BDJ.pal - @CMAKE_SOURCE_DIR@/Palettes/YL2KF.pal - @CMAKE_SOURCE_DIR@/Palettes/Yellow1.pal - @CMAKE_SOURCE_DIR@/Palettes/Yellow2.pal - @CMAKE_SOURCE_DIR@/Palettes/ZL1FZ.pal - @SAMPLE_PATHS@ - + + + @wsjtx_RESOURCES@ +