CMakeLists.txt 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # Copyright (C) 2017, David PHAM-VAN <dev.nfet.net@gmail.com>
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License"); you may not
  4. # use this file except in compliance with the License. You may obtain a copy of
  5. # the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  11. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  12. # License for the specific language governing permissions and limitations under
  13. # the License.
  14. cmake_minimum_required(VERSION 3.10)
  15. set(PROJECT_NAME "printing")
  16. project(${PROJECT_NAME} LANGUAGES CXX)
  17. set(PDFIUM_VERSION "4929" CACHE STRING "Version of pdfium used")
  18. set(PDFIUM_ARCH "x64" CACHE STRING "Architecture of pdfium used")
  19. if(${PDFIUM_VERSION} STREQUAL "latest")
  20. set(
  21. PDFIUM_URL
  22. "https://github.com/bblanchon/pdfium-binaries/releases/latest/download/pdfium-linux-${PDFIUM_ARCH}.tgz"
  23. )
  24. else()
  25. set(
  26. PDFIUM_URL
  27. "https://github.com/bblanchon/pdfium-binaries/releases/download/chromium/${PDFIUM_VERSION}/pdfium-linux-${PDFIUM_ARCH}.tgz"
  28. )
  29. endif()
  30. # Download pdfium
  31. include(../windows/DownloadProject.cmake)
  32. download_project(PROJ
  33. pdfium
  34. URL
  35. ${PDFIUM_URL})
  36. # This value is used when generating builds using this plugin, so it must not be
  37. # changed
  38. set(PLUGIN_NAME "printing_plugin")
  39. include(${pdfium_SOURCE_DIR}/PDFiumConfig.cmake)
  40. # System-level dependencies.
  41. find_package(PkgConfig REQUIRED)
  42. pkg_check_modules(GTKUnixPrint
  43. REQUIRED
  44. IMPORTED_TARGET
  45. gtk+-unix-print-3.0)
  46. add_library(${PLUGIN_NAME} SHARED
  47. "printing_plugin.cc"
  48. "include/printing/printing_plugin.h"
  49. "print_job.cc"
  50. "print_job.h")
  51. apply_standard_settings(${PLUGIN_NAME})
  52. set_target_properties(${PLUGIN_NAME} PROPERTIES CXX_VISIBILITY_PRESET hidden)
  53. target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL)
  54. target_include_directories(${PLUGIN_NAME}
  55. INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include")
  56. target_link_libraries(${PLUGIN_NAME} PRIVATE flutter)
  57. target_link_libraries(${PLUGIN_NAME}
  58. PRIVATE PkgConfig::GTK PkgConfig::GTKUnixPrint)
  59. target_link_libraries(${PLUGIN_NAME} PRIVATE pdfium)
  60. get_filename_component(PDFium_lib_path "${PDFium_LIBRARY}" DIRECTORY)
  61. set_target_properties(${PLUGIN_NAME}
  62. PROPERTIES SKIP_BUILD_RPATH
  63. FALSE
  64. BUILD_WITH_INSTALL_RPATH
  65. TRUE
  66. INSTALL_RPATH
  67. "$ORIGIN:${PDFium_lib_path}")
  68. # List of absolute paths to libraries that should be bundled with the plugin
  69. set(printing_bundled_libraries "${PDFium_LIBRARY}" PARENT_SCOPE)