CMakeLists.txt 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. cmake_minimum_required(VERSION 3.13)
  2. set(FLAMESHOT_VERSION 11.0.0)
  3. set(GIT_API_URL "https://api.github.com/repos/flameshot-org/flameshot/releases/latest")
  4. project(
  5. flameshot
  6. VERSION ${FLAMESHOT_VERSION}
  7. LANGUAGES CXX)
  8. set(PROJECT_NAME_CAPITALIZED "Flameshot")
  9. # This can be read from ${PROJECT_NAME} after project() is called
  10. if (APPLE)
  11. set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version")
  12. endif()
  13. # Configuration options
  14. set(DEFAULT_RUN_IN_PLACE FALSE)
  15. if(WIN32)
  16. set(DEFAULT_RUN_IN_PLACE TRUE)
  17. # For Windows RC file.
  18. add_definitions(-DFLAMESHOT_VERSION_MAJOR=${CMAKE_PROJECT_VERSION_MAJOR})
  19. add_definitions(-DFLAMESHOT_VERSION_MINOR=${CMAKE_PROJECT_VERSION_MINOR})
  20. add_definitions(-DFLAMESHOT_VERSION_BUGFIX=${CMAKE_PROJECT_VERSION_PATCH})
  21. add_definitions(-DFLAMESHOT_VERSION_BUILD=1)
  22. add_definitions(-DFLAMESHOT_VERSION_STRING="${PROJECT_VERSION}")
  23. elseif(APPLE)
  24. set(Qt6_DIR "$(brew --prefix qt6)/lib/cmake/Qt6/" CACHE PATH "directory where Qt6Config.cmake exists.")
  25. set(CMAKE_MACOSX_BUNDLE ON)
  26. set(CMAKE_MACOSX_RPATH ON)
  27. endif()
  28. set(RUN_IN_PLACE
  29. ${DEFAULT_RUN_IN_PLACE}
  30. CACHE BOOL "Run directly in source directory structure")
  31. option(USE_QT6 "Enable building aginst Qt6" ON)
  32. option(FLAMESHOT_DEBUG_CAPTURE "Enable mode to make debugging easier" OFF)
  33. option(USE_MONOCHROME_ICON "Build using monochrome icon as default" OFF)
  34. option(GENERATE_TS "Regenerate translation source files" OFF)
  35. option(USE_EXTERNAL_SINGLEAPPLICATION "Use external QtSingleApplication library" OFF)
  36. option(USE_LAUNCHER_ABSOLUTE_PATH "Use absolute path for the desktop launcher" ON)
  37. option(USE_WAYLAND_CLIPBOARD "USE KF Gui Wayland Clipboard" OFF)
  38. if (USE_QT6)
  39. set(QT_DEFAULT_MAJOR_VERSION 6)
  40. set(QT_VERSION_MAJOR 6)
  41. else()
  42. set(QT_DEFAULT_MAJOR_VERSION 5)
  43. set(QT_VERSION_MAJOR 5)
  44. endif()
  45. include(cmake/StandardProjectSettings.cmake)
  46. add_library(project_options INTERFACE)
  47. target_compile_features(project_options INTERFACE cxx_std_17)
  48. add_library(project_warnings INTERFACE)
  49. # enable cache system
  50. include(cmake/Cache.cmake)
  51. # standard compiler warnings
  52. include(cmake/CompilerWarnings.cmake)
  53. # set_project_warnings(project_warnings)
  54. # sanitizer options if supported by compiler
  55. include(cmake/Sanitizers.cmake)
  56. enable_sanitizers(project_options)
  57. # allow for static analysis options include(cmake/StaticAnalyzers.cmake)
  58. set(QAPPLICATION_CLASS
  59. QApplication
  60. CACHE STRING "Inheritance class for SingleApplication")
  61. if(USE_EXTERNAL_SINGLEAPPLICATION)
  62. # look for external QtSingleApplication
  63. # package dev-qt/qtsingleapplication provides no symlink to current version
  64. set(qtsingleapplication_libs libQt6Solutions_SingleApplication-2.6 Qt6Solutions_SingleApplication-2.6)
  65. find_library(QTSINGLEAPPLICATION_LIBRARY NAMES ${qtsingleapplication_libs})
  66. message(STATUS "Using external SingleApplication library")
  67. else()
  68. add_subdirectory(external/singleapplication)
  69. set(QTSINGLEAPPLICATION_LIBRARY SingleApplication::SingleApplication)
  70. endif()
  71. option(BUILD_STATIC_LIBS ON)
  72. option(BUILD_SHARED_LIBS OFF)
  73. add_subdirectory(external/Qt-Color-Widgets EXCLUDE_FROM_ALL)
  74. if (APPLE)
  75. add_subdirectory(external/QHotkey)
  76. endif()
  77. add_subdirectory(src)
  78. # CPack
  79. set(CPACK_PACKAGE_VENDOR "flameshot-org")
  80. set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Powerful yet simple to use screenshot software.")
  81. set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
  82. set(CPACK_PACKAGE_HOMEPAGE_URL "https://flameshot.org")
  83. set(CPACK_PACKAGE_CONTACT "flameshot-org developers <info@flameshot.org>")
  84. set(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/data/img/app/org.flameshot.Flameshot.svg") # TODO: Can any generator make
  85. # use of this?
  86. set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md") # TODO: Where is this used? Do we need a better
  87. # source?
  88. if(WIN32)
  89. # Include all dynamically linked runtime libraries such as MSVCRxxx.dll
  90. include(InstallRequiredSystemLibraries)
  91. if(RUN_IN_PLACE)
  92. if(CMAKE_SIZEOF_VOID_P EQUAL 8)
  93. set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}-win64")
  94. else()
  95. set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}-win32")
  96. endif()
  97. set(CPACK_GENERATOR ZIP)
  98. else()
  99. set(CPACK_GENERATOR WIX ZIP)
  100. set(CPACK_PACKAGE_NAME "${PROJECT_NAME_CAPITALIZED}")
  101. set(CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME_CAPITALIZED}")
  102. set(CPACK_PACKAGE_EXECUTABLES ${PROJECT_NAME} "${PROJECT_NAME_CAPITALIZED}")
  103. set(CPACK_CREATE_DESKTOP_LINKS ${PROJECT_NAME})
  104. # WIX (Windows .msi installer)
  105. # 48x48 pixels
  106. set(CPACK_WIX_PRODUCT_ICON "${CMAKE_SOURCE_DIR}/data/img/app/flameshot.ico")
  107. # Supported languages can be found at http://wixtoolset.org/documentation/manual/v3/wixui/wixui_localization.html
  108. # set(CPACK_WIX_CULTURES "ar-SA,bg-BG,ca-ES,hr-HR,cs-CZ,da-DK,nl-NL,en-US,et-EE,fi-FI,fr-FR,de-DE")
  109. set(CPACK_WIX_UI_BANNER "${CMAKE_SOURCE_DIR}/packaging/win-installer/Bitmaps/CPACK_WIX_UI_BANNER.BMP")
  110. set(CPACK_WIX_UI_DIALOG "${CMAKE_SOURCE_DIR}/packaging/win-installer/Bitmaps/CPACK_WIX_UI_DIALOG.BMP")
  111. set(CPACK_WIX_PROPERTY_ARPHELPLINK "${CPACK_PACKAGE_HOMEPAGE_URL}")
  112. set(CPACK_WIX_PROPERTY_ARPURLINFOABOUT "${CPACK_PACKAGE_HOMEPAGE_URL}")
  113. set(CPACK_WIX_ROOT_FEATURE_DESCRIPTION "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}")
  114. set(CPACK_WIX_LIGHT_EXTRA_FLAGS "-dcl:high") # set high compression
  115. set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/packaging/win-installer/LICENSE/GPL-3.0.txt")
  116. set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md")
  117. # The correct way would be to include both x32 and x64 into one installer and install the appropriate one. CMake
  118. # does not support that, so there are two separate GUID's
  119. if(CMAKE_SIZEOF_VOID_P EQUAL 8)
  120. set(CPACK_WIX_UPGRADE_GUID "26D8062A-66D9-48D9-8924-42090FB9B3F9")
  121. else()
  122. set(CPACK_WIX_UPGRADE_GUID "2C53E1B9-51D9-4429-AAE4-B02221959AA5")
  123. endif()
  124. endif()
  125. elseif(APPLE)
  126. set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0)
  127. set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}-osx")
  128. set(CPACK_GENERATOR ZIP)
  129. else()
  130. set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}-linux")
  131. set(CPACK_GENERATOR TGZ)
  132. set(CPACK_SOURCE_GENERATOR TGZ)
  133. endif()
  134. include(CPack)