@@ -163,6 +163,14 @@ if(GPGFRONTEND_BUILD_TYPE_ONLY_APPLICATION)
163163 set (STABLE_BUILD_ONLY_APPLICATION 1)
164164endif ()
165165
166+ # Fallback for BUILD_APPLICATION if not set by any build type
167+ if (NOT DEFINED BUILD_APPLICATION)
168+ if (GPGFRONTEND_GENERATE_LINUX_INSTALL_SOFTWARE OR GPGFRONTEND_BUILD_TYPE_STABLE OR GPGFRONTEND_BUILD_TYPE_ONLY_APPLICATION)
169+ set (BUILD_APPLICATION 1)
170+ message (STATUS "Setting BUILD_APPLICATION=1 as fallback based on build configuration" )
171+ endif ()
172+ endif ()
173+
166174if (GPGFRONTEND_BUILD_APP_IMAGE)
167175 set (BUILD_APP_IMAGE 1)
168176endif ()
@@ -413,6 +421,18 @@ set(CMAKE_AUTOUIC ON)
413421set (CMAKE_AUTORCC_OPTIONS "--compress;9" )
414422set (CMAKE_AUTOUIC_SEARCH_PATHS ${CMAKE_AUTOUIC_SEARCH_PATHS} ${CMAKE_SOURCE_DIR} /ui)
415423
424+ # Find and configure libassuan using pkg-config
425+ find_package (PkgConfig REQUIRED )
426+ pkg_check_modules (LIBASSUAN libassuan )
427+
428+ if (NOT LIBASSUAN_FOUND)
429+ message (FATAL_ERROR "libassuan not found. Please install libassuan-dev or libassuan-devel package for your system." )
430+ endif ()
431+
432+ # Add libassuan include and library paths globally since it's a core dependency
433+ include_directories (${LIBASSUAN_INCLUDE_DIRS} )
434+ link_directories (${LIBASSUAN_LIBRARY_DIRS} )
435+
416436if (STABLE_BUILD_APPLICATION)
417437 message ("[*] Build Stable Application" )
418438 set (BUILD_CORE 1)
@@ -456,6 +476,99 @@ message(STATUS "Build Type: ${CMAKE_BUILD_TYPE}")
456476message (STATUS "Build C Flags: ${CMAKE_C_FLAGS} " )
457477message (STATUS "Build C++ Flags: ${CMAKE_CXX_FLAGS} " )
458478
479+ # CPack configuration
480+ set (CPACK_GENERATOR "RPM" )
481+ set (CPACK_PACKAGE_NAME "GpgFrontend" )
482+ set (CPACK_PACKAGE_VERSION "${PROJECT_VERSION} " )
483+ set (CPACK_PACKAGE_RELEASE "1" )
484+ set (CPACK_PACKAGING_INSTALL_PREFIX "/usr" )
485+ set (CPACK_PACKAGE_CONTACT "eric@bktus.com" )
486+ set (CPACK_RPM_PACKAGE_LICENSE "GPLv3" )
487+ set (CPACK_RPM_PACKAGE_GROUP "Applications/System" )
488+ set (CPACK_RPM_PACKAGE_REQUIRES "libassuan >= 2.5.0, gpgme >= 1.12.0, qt6-qtbase >= 6.0.0, gtk-update-icon-cache" )
489+ set (CPACK_RPM_PACKAGE_URL "https://gpgfrontend.bktus.com" )
490+ set (CPACK_RPM_PACKAGE_DESCRIPTION "GpgFrontend is a free, open-source, robust yet user-friendly, compact and cross-platform tool for OpenPGP encryption." )
491+
492+ # Configure RPM scripts
493+ configure_file (
494+ "${CMAKE_SOURCE_DIR} /cmake/rpm/post-install.sh"
495+ "${CMAKE_BINARY_DIR} /rpm-post-install.sh"
496+ @ONLY
497+ )
498+ configure_file (
499+ "${CMAKE_SOURCE_DIR} /cmake/rpm/post-uninstall.sh"
500+ "${CMAKE_BINARY_DIR} /rpm-post-uninstall.sh"
501+ @ONLY
502+ )
503+
504+ # Set RPM scripts
505+ set (CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_BINARY_DIR} /rpm-post-install.sh" )
506+ set (CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_BINARY_DIR} /rpm-post-uninstall.sh" )
507+
508+ # Make the scripts executable
509+ file (CHMOD ${CMAKE_BINARY_DIR} /rpm-post-install.sh
510+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE )
511+ file (CHMOD ${CMAKE_BINARY_DIR} /rpm-post-uninstall.sh
512+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE )
513+
514+ # Documentation handling
515+ set (CPACK_RPM_PACKAGE_LICENSE_FILE "${CMAKE_SOURCE_DIR} /COPYING" )
516+ set (CPACK_RPM_PACKAGE_DOCUMENTATION "${CMAKE_SOURCE_DIR} /README.md" )
517+
518+ # Install license and documentation
519+ install (FILES "${CMAKE_SOURCE_DIR} /COPYING"
520+ DESTINATION "share/licenses/${CPACK_PACKAGE_NAME} "
521+ COMPONENT runtime )
522+ install (FILES "${CMAKE_SOURCE_DIR} /README.md"
523+ DESTINATION "share/doc/${CPACK_PACKAGE_NAME} "
524+ COMPONENT runtime )
525+
526+ # Install icons for all resolutions
527+ foreach (size IN ITEMS 32 48 64 128 256 512)
528+ install (FILES "${CMAKE_SOURCE_DIR} /resource/lfs/hicolor/${size} x${size} /apps/com.bktus.gpgfrontend.png"
529+ DESTINATION "share/icons/hicolor/${size} x${size} /apps"
530+ RENAME "gpgfrontend.png"
531+ COMPONENT runtime )
532+ # Also install with the full name for .desktop file compatibility
533+ install (FILES "${CMAKE_SOURCE_DIR} /resource/lfs/hicolor/${size} x${size} /apps/com.bktus.gpgfrontend.png"
534+ DESTINATION "share/icons/hicolor/${size} x${size} /apps"
535+ COMPONENT runtime )
536+ endforeach ()
537+
538+ # Install desktop file
539+ install (FILES "${CMAKE_SOURCE_DIR} /resource/appstream/com.bktus.gpgfrontend.desktop"
540+ DESTINATION "share/applications"
541+ COMPONENT runtime )
542+
543+ # Install metainfo/appdata
544+ install (FILES "${CMAKE_SOURCE_DIR} /resource/appstream/com.bktus.gpgfrontend.metainfo.xml"
545+ DESTINATION "share/metainfo"
546+ COMPONENT runtime )
547+
548+ # Exclude files from auto-detection of dependencies
549+ set (CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION
550+ "/usr/share/doc"
551+ "/usr/share/licenses"
552+ "/usr/share/applications"
553+ "/usr/share/metainfo"
554+ "/usr/share/icons"
555+ "/usr/share/icons/hicolor"
556+ "/usr/share/icons/hicolor/128x128"
557+ "/usr/share/icons/hicolor/256x256"
558+ "/usr/share/icons/hicolor/32x32"
559+ "/usr/share/icons/hicolor/48x48"
560+ "/usr/share/icons/hicolor/512x512"
561+ "/usr/share/icons/hicolor/64x64"
562+ "/usr/share/icons/hicolor/128x128/apps"
563+ "/usr/share/icons/hicolor/256x256/apps"
564+ "/usr/share/icons/hicolor/32x32/apps"
565+ "/usr/share/icons/hicolor/48x48/apps"
566+ "/usr/share/icons/hicolor/512x512/apps"
567+ "/usr/share/icons/hicolor/64x64/apps" )
568+
569+ # Include CPack to enable packaging support
570+ include (CPack )
571+
459572# third_party
460573add_subdirectory (third_party ) # source code
461574add_subdirectory (src )
0 commit comments