CMakeLists.txt 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. # Project-level configuration.
  2. cmake_minimum_required(VERSION 3.13)
  3. project(runner LANGUAGES CXX)
  4. # The name of the executable created for the application. Change this to change
  5. # the on-disk name of your application.
  6. set(BINARY_NAME "veloe_kemono_party_flutter")
  7. # The unique GTK application identifier for this application. See:
  8. # https://wiki.gnome.org/HowDoI/ChooseApplicationID
  9. set(APPLICATION_ID "com.example.veloe_kemono_party_flutter")
  10. # Explicitly opt in to modern CMake behaviors to avoid warnings with recent
  11. # versions of CMake.
  12. cmake_policy(SET CMP0063 NEW)
  13. # Load bundled libraries from the lib/ directory relative to the binary.
  14. set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
  15. # Root filesystem for cross-building.
  16. if(FLUTTER_TARGET_PLATFORM_SYSROOT)
  17. set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT})
  18. set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
  19. set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
  20. set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
  21. set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
  22. set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
  23. endif()
  24. # Define build configuration options.
  25. if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
  26. set(CMAKE_BUILD_TYPE "Debug" CACHE
  27. STRING "Flutter build mode" FORCE)
  28. set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
  29. "Debug" "Profile" "Release")
  30. endif()
  31. # Compilation settings that should be applied to most targets.
  32. #
  33. # Be cautious about adding new options here, as plugins use this function by
  34. # default. In most cases, you should add new options to specific targets instead
  35. # of modifying this function.
  36. function(APPLY_STANDARD_SETTINGS TARGET)
  37. target_compile_features(${TARGET} PUBLIC cxx_std_14)
  38. target_compile_options(${TARGET} PRIVATE -Wall -Werror)
  39. target_compile_options(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O3>")
  40. target_compile_definitions(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:NDEBUG>")
  41. endfunction()
  42. # Flutter library and tool build rules.
  43. set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
  44. add_subdirectory(${FLUTTER_MANAGED_DIR})
  45. # System-level dependencies.
  46. find_package(PkgConfig REQUIRED)
  47. pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
  48. # Application build; see runner/CMakeLists.txt.
  49. add_subdirectory("runner")
  50. # Run the Flutter tool portions of the build. This must not be removed.
  51. add_dependencies(${BINARY_NAME} flutter_assemble)
  52. # Only the install-generated bundle's copy of the executable will launch
  53. # correctly, since the resources must in the right relative locations. To avoid
  54. # people trying to run the unbundled copy, put it in a subdirectory instead of
  55. # the default top-level location.
  56. set_target_properties(${BINARY_NAME}
  57. PROPERTIES
  58. RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run"
  59. )
  60. # Generated plugin build rules, which manage building the plugins and adding
  61. # them to the application.
  62. include(flutter/generated_plugins.cmake)
  63. # === Installation ===
  64. # By default, "installing" just makes a relocatable bundle in the build
  65. # directory.
  66. set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle")
  67. if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
  68. set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
  69. endif()
  70. # Start with a clean build bundle directory every time.
  71. install(CODE "
  72. file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\")
  73. " COMPONENT Runtime)
  74. set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
  75. set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")
  76. install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
  77. COMPONENT Runtime)
  78. install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
  79. COMPONENT Runtime)
  80. install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
  81. COMPONENT Runtime)
  82. foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES})
  83. install(FILES "${bundled_library}"
  84. DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
  85. COMPONENT Runtime)
  86. endforeach(bundled_library)
  87. # Copy the native assets provided by the build.dart from all packages.
  88. set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/")
  89. install(DIRECTORY "${NATIVE_ASSETS_DIR}"
  90. DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
  91. COMPONENT Runtime)
  92. # Fully re-copy the assets directory on each build to avoid having stale files
  93. # from a previous install.
  94. set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
  95. install(CODE "
  96. file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
  97. " COMPONENT Runtime)
  98. install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
  99. DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
  100. # Install the AOT library on non-Debug builds only.
  101. if(NOT CMAKE_BUILD_TYPE MATCHES "Debug")
  102. install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
  103. COMPONENT Runtime)
  104. endif()