1+ # Project-level configuration.
12cmake_minimum_required (VERSION 3.10)
23project (runner LANGUAGES CXX)
34
5+ # The name of the executable created for the application. Change this to change
6+ # the on-disk name of your application.
47set (BINARY_NAME "minimal" )
8+ # The unique GTK application identifier for this application. See:
9+ # https://wiki.gnome.org/HowDoI/ChooseApplicationID
510set (APPLICATION_ID "com.minimal" )
611
12+ # Explicitly opt in to modern CMake behaviors to avoid warnings with recent
13+ # versions of CMake.
714cmake_policy (SET CMP0063 NEW)
815
16+ # Load bundled libraries from the lib/ directory relative to the binary.
917set (CMAKE_INSTALL_RPATH "$ORIGIN/lib" )
1018
1119# Root filesystem for cross-building.
@@ -18,7 +26,7 @@ if(FLUTTER_TARGET_PLATFORM_SYSROOT)
1826 set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
1927endif ()
2028
21- # Configure build options.
29+ # Define build configuration options.
2230if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES )
2331 set (CMAKE_BUILD_TYPE "Debug" CACHE
2432 STRING "Flutter build mode" FORCE)
@@ -27,16 +35,19 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
2735endif ()
2836
2937# Compilation settings that should be applied to most targets.
38+ #
39+ # Be cautious about adding new options here, as plugins use this function by
40+ # default. In most cases, you should add new options to specific targets instead
41+ # of modifying this function.
3042function (APPLY_STANDARD_SETTINGS TARGET )
3143 target_compile_features (${TARGET} PUBLIC cxx_std_14)
3244 target_compile_options (${TARGET} PRIVATE -Wall -Werror)
3345 target_compile_options (${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O3>" )
3446 target_compile_definitions (${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:NDEBUG>" )
3547endfunction ()
3648
37- set (FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR} /flutter" )
38-
3949# Flutter library and tool build rules.
50+ set (FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR} /flutter" )
4051add_subdirectory (${FLUTTER_MANAGED_DIR} )
4152
4253# System-level dependencies.
@@ -45,16 +56,27 @@ pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
4556
4657add_definitions (-DAPPLICATION_ID="${APPLICATION_ID} " )
4758
48- # Application build
59+ # Define the application target. To change its name, change BINARY_NAME above,
60+ # not the value here, or `flutter run` will no longer work.
61+ #
62+ # Any new source files that you add to the application should be added here.
4963add_executable (${BINARY_NAME}
5064 "main.cc"
5165 "my_application.cc"
5266 "${FLUTTER_MANAGED_DIR} /generated_plugin_registrant.cc"
5367)
68+
69+ # Apply the standard set of build settings. This can be removed for applications
70+ # that need different build settings.
5471apply_standard_settings(${BINARY_NAME} )
72+
73+ # Add dependency libraries. Add any application-specific dependencies here.
5574target_link_libraries (${BINARY_NAME} PRIVATE flutter)
5675target_link_libraries (${BINARY_NAME} PRIVATE PkgConfig::GTK)
76+
77+ # Run the Flutter tool portions of the build. This must not be removed.
5778add_dependencies (${BINARY_NAME} flutter_assemble)
79+
5880# Only the install-generated bundle's copy of the executable will launch
5981# correctly, since the resources must in the right relative locations. To avoid
6082# people trying to run the unbundled copy, put it in a subdirectory instead of
@@ -94,11 +116,11 @@ install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}
94116install (FILES "${FLUTTER_LIBRARY} " DESTINATION "${INSTALL_BUNDLE_LIB_DIR} "
95117 COMPONENT Runtime)
96118
97- if ( PLUGIN_BUNDLED_LIBRARIES)
98- install (FILES "${PLUGIN_BUNDLED_LIBRARIES } "
119+ foreach (bundled_library ${ PLUGIN_BUNDLED_LIBRARIES} )
120+ install (FILES "${bundled_library } "
99121 DESTINATION "${INSTALL_BUNDLE_LIB_DIR} "
100122 COMPONENT Runtime)
101- endif ( )
123+ endforeach (bundled_library )
102124
103125# Fully re-copy the assets directory on each build to avoid having stale files
104126# from a previous install.
0 commit comments