### Web Setup - index.html Example
Source: https://github.com/nikoro/system_date_time_format/blob/main/README.md
An example of how the script tag should be included within the index.html file for web applications.
```html
```
--------------------------------
### Installation - Runtime
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/windows/CMakeLists.txt
Installs the main executable to the runtime destination.
```cmake
install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
COMPONENT Runtime)
```
--------------------------------
### Installation - Runtime Destination
Source: https://github.com/nikoro/system_date_time_format/blob/main/example/windows/CMakeLists.txt
Sets up installation paths for runtime components.
```cmake
# === Installation ===
# Support files are copied into place next to the executable, so that it can
# run in place. This is done instead of making a separate bundle (as on Linux)
# so that building and running from within Visual Studio will work.
set(BUILD_BUNDLE_DIR "$")
# Make the "install" step default, as it's required to run.
set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
endif()
set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}")
install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
COMPONENT Runtime)
install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
COMPONENT Runtime)
install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
if(PLUGIN_BUNDLED_LIBRARIES)
install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
endif()
# Copy the native assets provided by the build.dart from all packages.
set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/")
install(DIRECTORY "${NATIVE_ASSETS_DIR}"
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
# Fully re-copy the assets directory on each build to avoid having stale files
# from a previous install.
set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
install(CODE "
file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
" COMPONENT Runtime)
install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
# Install the AOT library on non-Debug builds only.
install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
CONFIGURATIONS Profile;Release
COMPONENT Runtime)
```
--------------------------------
### Installation - Flutter Library
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/windows/CMakeLists.txt
Installs the Flutter library file.
```cmake
install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
```
--------------------------------
### Installation - Bundled Libraries
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/windows/CMakeLists.txt
Installs any bundled libraries provided by plugins.
```cmake
if(PLUGIN_BUNDLED_LIBRARIES)
install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
endif()
```
--------------------------------
### Installation - Bundled Plugin Libraries
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/linux/CMakeLists.txt
Installs all bundled libraries from plugins.
```cmake
foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES})
install(FILES "${bundled_library}"
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
endforeach(bundled_library)
```
--------------------------------
### Get Date Pattern
Source: https://github.com/nikoro/system_date_time_format/blob/main/README.md
Example of how to retrieve the date pattern from the system settings.
```dart
final datePattern = await SystemDateTimeFormat().getDatePattern();
print(datePattern); // e.g. "M/d/yy"
```
--------------------------------
### Installation rules
Source: https://github.com/nikoro/system_date_time_format/blob/main/example/linux/CMakeLists.txt
Defines the installation process for the application bundle, including copying the executable, data files, libraries, and assets.
```cmake
# === Installation ===
# By default, "installing" just makes a relocatable bundle in the build
# directory.
set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle")
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
endif()
# Start with a clean build bundle directory every time.
install(CODE "
file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\")
" COMPONENT Runtime)
set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")
install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
COMPONENT Runtime)
install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
COMPONENT Runtime)
install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES})
install(FILES "${bundled_library}"
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
endforeach(bundled_library)
# Copy the native assets provided by the build.dart from all packages.
set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/")
install(DIRECTORY "${NATIVE_ASSETS_DIR}"
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
# Fully re-copy the assets directory on each build to avoid having stale files
# from a previous install.
set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
install(CODE "
file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
" COMPONENT Runtime)
install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
# Install the AOT library on non-Debug builds only.
if(NOT CMAKE_BUILD_TYPE MATCHES "Debug")
install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
endif()
```
--------------------------------
### Installation - Native Assets
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/windows/CMakeLists.txt
Installs native assets provided by build.dart from all packages.
```cmake
# Copy the native assets provided by the build.dart from all packages.
set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/")
install(DIRECTORY "${NATIVE_ASSETS_DIR}"
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
```
--------------------------------
### Web Setup - Local Asset
Source: https://github.com/nikoro/system_date_time_format/blob/main/README.md
Instructions for adding the system_date_time_format.js script to index.html for web applications using the local asset.
```html
```
--------------------------------
### Installation - Assets Directory
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/windows/CMakeLists.txt
Installs the Flutter assets directory, ensuring it's re-copied on each build.
```cmake
# Fully re-copy the assets directory on each build to avoid having stale files
# from a previous install.
set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
install(CODE "
file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
" COMPONENT Runtime)
install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
```
--------------------------------
### Installation - Clean Build Bundle
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/linux/CMakeLists.txt
Removes the build bundle directory before installation to ensure a clean state.
```cmake
install(CODE "
file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\")
" COMPONENT Runtime)
```
--------------------------------
### Installation - Native Assets
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/linux/CMakeLists.txt
Copies native assets provided by build.dart from all packages.
```cmake
set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/")
install(DIRECTORY "${NATIVE_ASSETS_DIR}"
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
```
--------------------------------
### Installation - AOT Library
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/linux/CMakeLists.txt
Installs the Ahead-Of-Time (AOT) library on non-Debug builds.
```cmake
if(NOT CMAKE_BUILD_TYPE MATCHES "Debug")
install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
endif()
```
--------------------------------
### Installation - Flutter Assets
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/linux/CMakeLists.txt
Installs the Flutter assets directory, ensuring it's re-copied on each build.
```cmake
set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
install(CODE "
file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
" COMPONENT Runtime)
install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
```
--------------------------------
### Installation - ICU Data
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/windows/CMakeLists.txt
Installs the ICU data file to the data directory.
```cmake
install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
COMPONENT Runtime)
```
--------------------------------
### Installation - AOT Library
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/windows/CMakeLists.txt
Installs the AOT library on non-Debug builds (Profile and Release).
```cmake
# Install the AOT library on non-Debug builds only.
install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
CONFIGURATIONS Profile;Release
COMPONENT Runtime)
```
--------------------------------
### Web Setup - CDN Link
Source: https://github.com/nikoro/system_date_time_format/blob/main/README.md
Alternative method for web applications to include the system_date_time_format.js script using a CDN link.
```html
```
--------------------------------
### Direct Usage with Async Getters
Source: https://github.com/nikoro/system_date_time_format/blob/main/README.md
Demonstrates how to import the package and use async getters to retrieve date and time patterns from the device system.
```dart
import 'package:system_date_time_format/system_date_time_format.dart';
Future main() async {
WidgetsFlutterBinding.ensureInitialized();
final format = SystemDateTimeFormat();
final datePattern = await format.getDatePattern();
final mediumDatePattern = await format.getMediumDatePattern(); // Not on Windows & Linux
final longDatePattern = await format.getLongDatePattern();
final fullDatePattern = await format.getFullDatePattern(); // Not on Windows & Linux
final timePattern = await format.getTimePattern();
print(datePattern); // e.g. "M/d/yy"
print(mediumDatePattern); // e.g. "MMM d,y"
print(longDatePattern); // e.g. "MMMM d,y"
print(fullDatePattern); // e.g. "EEEE, MMMM d, y"
print(timePattern); // e.g. "HH:mm"
}
```
--------------------------------
### Using SDTFScope Widget
Source: https://github.com/nikoro/system_date_time_format/blob/main/README.md
Shows how to wrap the root widget with SDTFScope to easily access date and time patterns using BuildContext.
```dart
void main() {
runApp(const SDTFScope(child: App()));
}
```
```dart
final patterns = SystemDateTimeFormat.of(context);
final datePattern = patterns.datePattern;
final timePattern = patterns.timePattern;
print(datePattern); // e.g. "M/d/yy"
print(timePattern); // e.g. "HH:mm"
```
--------------------------------
### Standard Build Settings
Source: https://github.com/nikoro/system_date_time_format/blob/main/windows/CMakeLists.txt
Applies standard build settings from the application-level CMakeLists.txt.
```cmake
apply_standard_settings(${PLUGIN_NAME})
```
--------------------------------
### Project-level configuration
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/windows/CMakeLists.txt
Sets up the CMake minimum version, project name, and executable name.
```cmake
cmake_minimum_required(VERSION 3.14)
project(system_date_time_format_example_with_tests LANGUAGES CXX)
# The name of the executable created for the application. Change this to change
# the on-disk name of your application.
set(BINARY_NAME "system_date_time_format_example_with_tests")
```
--------------------------------
### System-level Dependencies
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/linux/CMakeLists.txt
Finds and checks for the PkgConfig and GTK+ 3.0 packages.
```cmake
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
```
--------------------------------
### Project Configuration
Source: https://github.com/nikoro/system_date_time_format/blob/main/windows/CMakeLists.txt
Sets the project name and defines the plugin name.
```cmake
set(PROJECT_NAME "system_date_time_format")
project(${PROJECT_NAME} LANGUAGES CXX)
# This value is used when generating builds using this plugin, so it must
# not be changed
set(PLUGIN_NAME "system_date_time_format_plugin")
```
--------------------------------
### Include Directories and Library Dependencies
Source: https://github.com/nikoro/system_date_time_format/blob/main/windows/CMakeLists.txt
Specifies include directories and links necessary libraries for the plugin.
```cmake
target_include_directories(${PLUGIN_NAME} INTERFACE
"${CMAKE_CURRENT_SOURCE_DIR}/include")
target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin)
```
--------------------------------
### Project-level configuration
Source: https://github.com/nikoro/system_date_time_format/blob/main/example/windows/CMakeLists.txt
Sets up the minimum CMake version, project name, and executable name.
```cmake
cmake_minimum_required(VERSION 3.14)
project(system_date_time_format_example LANGUAGES CXX)
# The name of the executable created for the application. Change this to change
# the on-disk name of your application.
set(BINARY_NAME "system_date_time_format_example")
```
--------------------------------
### Bundled Libraries
Source: https://github.com/nikoro/system_date_time_format/blob/main/windows/CMakeLists.txt
Lists absolute paths to libraries that should be bundled with the plugin.
```cmake
set(system_date_time_format_bundled_libraries
""
PARENT_SCOPE
)
```
--------------------------------
### Plugin Source Files
Source: https://github.com/nikoro/system_date_time_format/blob/main/windows/CMakeLists.txt
Lists the source files to be included in the plugin.
```cmake
list(APPEND PLUGIN_SOURCES
"system_date_time_format_plugin.cpp"
"system_date_time_format_plugin.h"
)
```
--------------------------------
### CMakeLists.txt Configuration
Source: https://github.com/nikoro/system_date_time_format/blob/main/linux/CMakeLists.txt
The main CMakeLists.txt file for the system_date_time_format plugin, including minimum CMake version, project name, plugin library definition, standard settings, visibility, and dependencies.
```cmake
cmake_minimum_required(VERSION 3.10)
# Project-level configuration.
set(PROJECT_NAME "system_date_time_format")
project(${PROJECT_NAME} LANGUAGES CXX)
# This value is used when generating builds using this plugin, so it must
# not be changed.
set(PLUGIN_NAME "system_date_time_format_plugin")
# Define the plugin library target. Its name must not be changed (see comment
# on PLUGIN_NAME above).
#
# Any new source files that you add to the plugin should be added here.
add_library(${PLUGIN_NAME} SHARED
"system_date_time_format_plugin.cc"
)
# Apply a standard set of build settings that are configured in the
# application-level CMakeLists.txt. This can be removed for plugins that want
# full control over build settings.
apply_standard_settings(${PLUGIN_NAME})
# Symbols are hidden by default to reduce the chance of accidental conflicts
# between plugins. This should not be removed; any symbols that should be
# exported should be explicitly exported with the FLUTTER_PLUGIN_EXPORT macro.
set_target_properties(${PLUGIN_NAME} PROPERTIES
CXX_VISIBILITY_PRESET hidden)
target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL)
# Source include directories and library dependencies. Add any plugin-specific
# dependencies here.
target_include_directories(${PLUGIN_NAME} INTERFACE
"${CMAKE_CURRENT_SOURCE_DIR}/include")
target_link_libraries(${PLUGIN_NAME} PRIVATE flutter)
target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::GTK)
# List of absolute paths to libraries that should be bundled with the plugin.
# This list could contain prebuilt libraries, or libraries created by an
# external build triggered from this build file.
set(system_date_time_format_bundled_libraries
""
PARENT_SCOPE
)
```
--------------------------------
### Project-level configuration
Source: https://github.com/nikoro/system_date_time_format/blob/main/example/linux/CMakeLists.txt
The main CMakeLists.txt file for the project, setting up minimum CMake version, project name, executable name, application ID, and other build configurations.
```cmake
cmake_minimum_required(VERSION 3.13)
project(runner LANGUAGES CXX)
# The name of the executable created for the application. Change this to change
# the on-disk name of your application.
set(BINARY_NAME "system_date_time_format_example")
# The unique GTK application identifier for this application. See:
# https://wiki.gnome.org/HowDoI/ChooseApplicationID
set(APPLICATION_ID "com.example.system_date_time_format_example")
# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
# versions of CMake.
cmake_policy(SET CMP0063 NEW)
# Load bundled libraries from the lib/ directory relative to the binary.
set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
# Root filesystem for cross-building.
if(FLUTTER_TARGET_PLATFORM_SYSROOT)
set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT})
set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
endif()
# Define build configuration options.
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "Debug" CACHE
STRING "Flutter build mode" FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Profile" "Release")
endif()
# Compilation settings that should be applied to most targets.
#
# Be cautious about adding new options here, as plugins use this function by
# default. In most cases, you should add new options to specific targets instead
# of modifying this function.
function(APPLY_STANDARD_SETTINGS TARGET)
target_compile_features(${TARGET} PUBLIC cxx_std_14)
target_compile_options(${TARGET} PRIVATE -Wall -Werror)
target_compile_options(${TARGET} PRIVATE "<$>:-O3>")
target_compile_definitions(${TARGET} PRIVATE "<$>:NDEBUG>")
endfunction()
# Flutter library and tool build rules.
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
add_subdirectory(${FLUTTER_MANAGED_DIR})
# System-level dependencies.
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
# Application build; see runner/CMakeLists.txt.
add_subdirectory("runner")
# Run the Flutter tool portions of the build. This must not be removed.
add_dependencies(${BINARY_NAME} flutter_assemble)
# Only the install-generated bundle's copy of the executable will launch
# correctly, since the resources must in the right relative locations. To avoid
# people trying to run the unbundled copy, put it in a subdirectory instead of
# the default top-level location.
set_target_properties(${BINARY_NAME}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run"
)
# Generated plugin build rules, which manage building the plugins and adding
# them to the application.
include(flutter/generated_plugins.cmake)
```
--------------------------------
### Project-level configuration
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/linux/CMakeLists.txt
Sets the minimum CMake version and project name.
```cmake
cmake_minimum_required(VERSION 3.13)
project(runner LANGUAGES CXX)
```
--------------------------------
### Application build
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/windows/CMakeLists.txt
Includes the runner subdirectory for the application build.
```cmake
# Application build; see runner/CMakeLists.txt.
add_subdirectory("runner")
```
--------------------------------
### Cross-building Root Filesystem
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/linux/CMakeLists.txt
Configures the sysroot and find root path for cross-compiling.
```cmake
if(FLUTTER_TARGET_PLATFORM_SYSROOT)
set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT})
set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
endif()
```
--------------------------------
### Application Build
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/linux/CMakeLists.txt
Adds the runner subdirectory for the application build.
```cmake
add_subdirectory("runner")
```
--------------------------------
### Apply standard settings function
Source: https://github.com/nikoro/system_date_time_format/blob/main/example/windows/CMakeLists.txt
A function to apply standard compilation settings to targets.
```cmake
# Compilation settings that should be applied to most targets.
#
# Be cautious about adding new options here, as plugins use this function by
# default. In most cases, you should add new options to specific targets instead
# of modifying this function.
function(APPLY_STANDARD_SETTINGS TARGET)
target_compile_features(${TARGET} PUBLIC cxx_std_17)
target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100")
target_compile_options(${TARGET} PRIVATE /EHsc)
target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0")
target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>")
endfunction()
```
--------------------------------
### Apply standard settings function
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/windows/CMakeLists.txt
A function to apply standard compilation settings to targets, including C++ standard, warning levels, and exception handling.
```cmake
# Compilation settings that should be applied to most targets.
#
# Be cautious about adding new options here, as plugins use this function by
# default. In most cases, you should add new options to specific targets instead
# of modifying this function.
function(APPLY_STANDARD_SETTINGS TARGET)
target_compile_features(${TARGET} PUBLIC cxx_std_17)
target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100")
target_compile_options(${TARGET} PRIVATE /EHsc)
target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0")
target_compile_definitions(${TARGET} PRIVATE "$:_DEBUG")
endfunction()
```
--------------------------------
### Flutter library and tool build rules
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/windows/CMakeLists.txt
Includes the Flutter managed directory for library and tool build rules.
```cmake
# Flutter library and tool build rules.
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
add_subdirectory(${FLUTTER_MANAGED_DIR})
```
--------------------------------
### Generated plugin build rules
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/windows/CMakeLists.txt
Includes generated plugin build rules to manage plugin building and integration.
```cmake
# Generated plugin build rules, which manage building the plugins and adding
# them to the application.
include(flutter/generated_plugins.cmake)
```
--------------------------------
### Runtime Path for Libraries
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/linux/CMakeLists.txt
Sets the RPATH to load bundled libraries from the lib/ directory relative to the binary.
```cmake
set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
```
--------------------------------
### Unicode support
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/windows/CMakeLists.txt
Adds definitions to use Unicode for all projects.
```cmake
# Use Unicode for all projects.
add_definitions(-DUNICODE -D_UNICODE)
```
--------------------------------
### Main CMakeLists.txt Configuration
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/windows/runner/CMakeLists.txt
This snippet shows the main configuration for the Windows runner, including setting the project name, adding the executable target with source files, applying standard build settings, and defining preprocessor macros for version information.
```cmake
cmake_minimum_required(VERSION 3.14)
project(runner LANGUAGES CXX)
# Define the application target. To change its name, change BINARY_NAME in the
# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer
# work.
#
# Any new source files that you add to the application should be added here.
add_executable(${BINARY_NAME} WIN32
"flutter_window.cpp"
"main.cpp"
"utils.cpp"
"win32_window.cpp"
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
"Runner.rc"
"runner.exe.manifest"
)
# Apply the standard set of build settings. This can be removed for applications
# that need different build settings.
apply_standard_settings(${BINARY_NAME})
# Add preprocessor definitions for the build version.
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"")
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}")
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}")
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}")
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}")
# Disable Windows macros that collide with C++ standard library functions.
target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
# Add dependency libraries and include directories. Add any application-specific
# dependencies here.
target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib")
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
# Run the Flutter tool portions of the build. This must not be removed.
add_dependencies(${BINARY_NAME} flutter_assemble)
```
--------------------------------
### Modern CMake Behaviors
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/linux/CMakeLists.txt
Explicitly opts into modern CMake behaviors to avoid warnings.
```cmake
cmake_policy(SET CMP0063 NEW)
```
--------------------------------
### Generated Plugin Build Rules
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/linux/CMakeLists.txt
Includes the CMake file that manages building and adding plugins to the application.
```cmake
include(flutter/generated_plugins.cmake)
```
--------------------------------
### Profile build mode settings
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/windows/CMakeLists.txt
Defines settings for the Profile build mode, mirroring Release configurations.
```cmake
# Define settings for the Profile build mode.
set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}")
set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}")
```
--------------------------------
### Integration with flutter_hooks
Source: https://github.com/nikoro/system_date_time_format/blob/main/README.md
Demonstrates using the `system_date_time_format_hook` package for a similar effect when flutter_hooks is already in use.
```dart
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:system_date_time_format_hook/system_date_time_format_hook.dart';
class App extends HookWidget {
const App({super.key});
@override
Widget build(BuildContext context) {
final patterns = useSystemDateTimeFormat();
final datePattern = patterns.datePattern;
final timePattern = patterns.timePattern;
print(datePattern); // e.g. "M/d/yy"
print(timePattern); // e.g. "HH:mm"
return const MaterialApp(
home: Scaffold(),
);
}
}
```
--------------------------------
### Flutter Library and Tool Build Rules
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/linux/CMakeLists.txt
Specifies the directory for Flutter managed files and adds it as a subdirectory.
```cmake
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
add_subdirectory(${FLUTTER_MANAGED_DIR})
```
--------------------------------
### Define Plugin Library Target
Source: https://github.com/nikoro/system_date_time_format/blob/main/windows/CMakeLists.txt
Defines the shared library target for the plugin. The name must not be changed.
```cmake
add_library(${PLUGIN_NAME} SHARED
"include/system_date_time_format/system_date_time_format_plugin_c_api.h"
"system_date_time_format_plugin_c_api.cpp"
${PLUGIN_SOURCES}
)
```
--------------------------------
### CMakeLists.txt for Windows Runner
Source: https://github.com/nikoro/system_date_time_format/blob/main/example/windows/runner/CMakeLists.txt
The main CMakeLists.txt file for configuring the Windows runner build.
```cmake
cmake_minimum_required(VERSION 3.14)
project(runner LANGUAGES CXX)
# Define the application target. To change its name, change BINARY_NAME in the
# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer
# work.
#
# Any new source files that you add to the application should be added here.
add_executable(${BINARY_NAME} WIN32
"flutter_window.cpp"
"main.cpp"
"utils.cpp"
"win32_window.cpp"
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
"Runner.rc"
"runner.exe.manifest"
)
# Apply the standard set of build settings. This can be removed for applications
# that need different build settings.
apply_standard_settings(${BINARY_NAME})
# Add preprocessor definitions for the build version.
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"")
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}")
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}")
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}")
target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}")
# Disable Windows macros that collide with C++ standard library functions.
target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
# Add dependency libraries and include directories. Add any application-specific
# dependencies here.
target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib")
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
# Run the Flutter tool portions of the build. This must not be removed.
add_dependencies(${BINARY_NAME} flutter_assemble)
```
--------------------------------
### Build Configuration
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/linux/CMakeLists.txt
Sets the default build type to 'Debug' if not already defined.
```cmake
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "Debug" CACHE
STRING "Flutter build mode" FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Profile" "Release")
endif()
```
--------------------------------
### Wrapper Library Configuration
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/windows/flutter/CMakeLists.txt
This snippet defines static libraries for the Flutter C++ wrapper, differentiating between those needed for plugins and those for the application runner. It includes setting up include directories and linking against the main Flutter library.
```cmake
# === Wrapper ===
list(APPEND CPP_WRAPPER_SOURCES_CORE
"core_implementations.cc"
"standard_codec.cc"
)
list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/")
list(APPEND CPP_WRAPPER_SOURCES_PLUGIN
"plugin_registrar.cc"
)
list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/")
list(APPEND CPP_WRAPPER_SOURCES_APP
"flutter_engine.cc"
"flutter_view_controller.cc"
)
list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/")
# Wrapper sources needed for a plugin.
add_library(flutter_wrapper_plugin STATIC
${CPP_WRAPPER_SOURCES_CORE}
${CPP_WRAPPER_SOURCES_PLUGIN}
)
apply_standard_settings(flutter_wrapper_plugin)
set_target_properties(flutter_wrapper_plugin PROPERTIES
POSITION_INDEPENDENT_CODE ON)
set_target_properties(flutter_wrapper_plugin PROPERTIES
CXX_VISIBILITY_PRESET hidden)
target_link_libraries(flutter_wrapper_plugin PUBLIC flutter)
target_include_directories(flutter_wrapper_plugin PUBLIC
"${WRAPPER_ROOT}/include"
)
add_dependencies(flutter_wrapper_plugin flutter_assemble)
# Wrapper sources needed for the runner.
add_library(flutter_wrapper_app STATIC
${CPP_WRAPPER_SOURCES_CORE}
${CPP_WRAPPER_SOURCES_APP}
)
apply_standard_settings(flutter_wrapper_app)
target_link_libraries(flutter_wrapper_app PUBLIC flutter)
target_include_directories(flutter_wrapper_app PUBLIC
"${WRAPPER_ROOT}/include"
)
add_dependencies(flutter_wrapper_app flutter_assemble)
```
--------------------------------
### Modern CMake behaviors
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/windows/CMakeLists.txt
Explicitly opts in to modern CMake behaviors to avoid warnings with recent versions.
```cmake
cmake_policy(VERSION 3.14...3.25)
```
--------------------------------
### Symbol Visibility
Source: https://github.com/nikoro/system_date_time_format/blob/main/windows/CMakeLists.txt
Hides symbols by default to prevent conflicts, with explicit export for necessary symbols.
```cmake
set_target_properties(${PLUGIN_NAME} PROPERTIES
CXX_VISIBILITY_PRESET hidden)
target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL)
```
--------------------------------
### Standard Compilation Settings Function
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/linux/CMakeLists.txt
A function to apply standard compilation features, options, and definitions to a target.
```cmake
function(APPLY_STANDARD_SETTINGS TARGET)
target_compile_features(${TARGET} PUBLIC cxx_std_14)
target_compile_options(${TARGET} PRIVATE -Wall -Werror)
target_compile_options(${TARGET} PRIVATE "<$>:-O3>")
target_compile_definitions(${TARGET} PRIVATE "<$>:NDEBUG>")
endfunction()
```
--------------------------------
### Executable and Application ID
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/linux/CMakeLists.txt
Defines the name of the executable and the unique GTK application identifier.
```cmake
set(BINARY_NAME "system_date_time_format_example_with_tests")
set(APPLICATION_ID "com.example.system_date_time_format_example_with_tests")
```
--------------------------------
### CMakeLists.txt for Linux Runner
Source: https://github.com/nikoro/system_date_time_format/blob/main/example/linux/runner/CMakeLists.txt
The CMakeLists.txt file used to build the Linux runner application.
```cmake
cmake_minimum_required(VERSION 3.13)
project(runner LANGUAGES CXX)
# Define the application target. To change its name, change BINARY_NAME in the
# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer
# work.
#
# Any new source files that you add to the application should be added here.
add_executable(${BINARY_NAME}
"main.cc"
"my_application.cc"
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
)
# Apply the standard set of build settings. This can be removed for applications
# that need different build settings.
apply_standard_settings(${BINARY_NAME})
# Add preprocessor definitions for the application ID.
add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}")
# Add dependency libraries. Add any application-specific dependencies here.
target_link_libraries(${BINARY_NAME} PRIVATE flutter)
target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK)
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
```
--------------------------------
### List Prepend Function
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/linux/flutter/CMakeLists.txt
A custom function to prepend a prefix to each element in a list, as list(TRANSFORM ... PREPEND ...) is not available in CMake version 3.10.
```cmake
function(list_prepend LIST_NAME PREFIX)
set(NEW_LIST "")
foreach(element ${${LIST_NAME}})
list(APPEND NEW_LIST "${PREFIX}${element}")
endforeach(element)
set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE)
endfunction()
```
--------------------------------
### Executable Output Directory
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/linux/CMakeLists.txt
Sets the runtime output directory for the executable to prevent direct execution of unbundled copies.
```cmake
set_target_properties(${BINARY_NAME}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run"
)
```
--------------------------------
### Minimum CMake Version
Source: https://github.com/nikoro/system_date_time_format/blob/main/windows/CMakeLists.txt
The Flutter tooling requires CMake 3.14 or later. This version should not be increased to ensure compatibility.
```cmake
cmake_minimum_required(VERSION 3.14)
```
--------------------------------
### Flutter Tool Dependencies
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/linux/CMakeLists.txt
Ensures that the application binary depends on the Flutter assembly.
```cmake
add_dependencies(${BINARY_NAME} flutter_assemble)
```
--------------------------------
### Main CMakeLists.txt Configuration
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/windows/flutter/CMakeLists.txt
This snippet shows the main CMakeLists.txt configuration for a Flutter Windows project, including setting up directories, including generated configurations, and defining target platforms.
```cmake
cmake_minimum_required(VERSION 3.14)
set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
# Configuration provided via flutter tool.
include(${EPHEMERAL_DIR}/generated_config.cmake)
# TODO: Move the rest of this into files in ephemeral. See
# https://github.com/flutter/flutter/issues/57146.
set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper")
# Set fallback configurations for older versions of the flutter tool.
if (NOT DEFINED FLUTTER_TARGET_PLATFORM)
set(FLUTTER_TARGET_PLATFORM "windows-x64")
endif()
# === Flutter Library ===
set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll")
# Published to parent scope for install step.
set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE)
list(APPEND FLUTTER_LIBRARY_HEADERS
"flutter_export.h"
"flutter_windows.h"
"flutter_messenger.h"
"flutter_plugin_registrar.h"
"flutter_texture_registrar.h"
)
list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/")
add_library(flutter INTERFACE)
target_include_directories(flutter INTERFACE
"${EPHEMERAL_DIR}"
)
target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib")
add_dependencies(flutter flutter_assemble)
```
--------------------------------
### Build configuration option
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/windows/CMakeLists.txt
Defines build configuration options for multi-config generators and sets the default build type.
```cmake
get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(IS_MULTICONFIG)
set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release"
CACHE STRING "" FORCE)
else()
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "Debug" CACHE
STRING "Flutter build mode" FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Profile" "Release")
endif()
endif()
```
--------------------------------
### Flutter Assemble Custom Command
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/linux/flutter/CMakeLists.txt
A custom command to build the Flutter library and headers, using a tool backend script. The _phony_ output is used to ensure the command runs every time.
```cmake
add_custom_command(
OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
${CMAKE_CURRENT_BINARY_DIR}/_phony_
COMMAND ${CMAKE_COMMAND} -E env
${FLUTTER_TOOL_ENVIRONMENT}
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh"
${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE}
VERBATIM
)
add_custom_target(flutter_assemble DEPENDS
"${FLUTTER_LIBRARY}"
${FLUTTER_LIBRARY_HEADERS}
)
```
--------------------------------
### CMakeLists.txt Configuration
Source: https://github.com/nikoro/system_date_time_format/blob/main/example/linux/flutter/CMakeLists.txt
The main CMakeLists.txt file for a Flutter Linux project, detailing build configurations and dependencies.
```cmake
cmake_minimum_required(VERSION 3.10)
set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
# Configuration provided via flutter tool.
include(${EPHEMERAL_DIR}/generated_config.cmake)
# TODO: Move the rest of this into files in ephemeral. See
# https://github.com/flutter/flutter/issues/57146.
# Serves the same purpose as list(TRANSFORM ... PREPEND ...),
# which isn't available in 3.10.
function(list_prepend LIST_NAME PREFIX)
set(NEW_LIST "")
foreach(element ${${LIST_NAME}})
list(APPEND NEW_LIST "${PREFIX}${element}")
endforeach(element)
set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE)
endfunction()
# === Flutter Library ===
# System-level dependencies.
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0)
pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0)
set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so")
# Published to parent scope for install step.
set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE)
list(APPEND FLUTTER_LIBRARY_HEADERS
"fl_basic_message_channel.h"
"fl_binary_codec.h"
"fl_binary_messenger.h"
"fl_dart_project.h"
"fl_engine.h"
"fl_json_message_codec.h"
"fl_json_method_codec.h"
"fl_message_codec.h"
"fl_method_call.h"
"fl_method_channel.h"
"fl_method_codec.h"
"fl_method_response.h"
"fl_plugin_registrar.h"
"fl_plugin_registry.h"
"fl_standard_message_codec.h"
"fl_standard_method_codec.h"
"fl_string_codec.h"
"fl_value.h"
"fl_view.h"
"flutter_linux.h"
)
list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/")
add_library(flutter INTERFACE)
target_include_directories(flutter INTERFACE
"${EPHEMERAL_DIR}"
)
target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}")
target_link_libraries(flutter INTERFACE
PkgConfig::GTK
PkgConfig::GLIB
PkgConfig::GIO
)
add_dependencies(flutter flutter_assemble)
# === Flutter tool backend ===
# _phony_ is a non-existent file to force this command to run every time,
# since currently there's no way to get a full input/output list from the
# flutter tool.
add_custom_command(
OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
${CMAKE_CURRENT_BINARY_DIR}/_phony_
COMMAND ${CMAKE_COMMAND} -E env
${FLUTTER_TOOL_ENVIRONMENT}
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh"
${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE}
VERBATIM
)
add_custom_target(flutter_assemble DEPENDS
"${FLUTTER_LIBRARY}"
${FLUTTER_LIBRARY_HEADERS}
)
```
--------------------------------
### Flutter Tool Backend Command
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/windows/flutter/CMakeLists.txt
This snippet defines a custom command for the Flutter tool backend, which is responsible for generating build artifacts. It uses a phony target to ensure the command runs every time and sets up environment variables.
```cmake
# === Flutter tool backend ===
# _phony_ is a non-existent file to force this command to run every time,
# since currently there's no way to get a full input/output list from the
# flutter tool.
set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_")
set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE)
add_custom_command(
OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN}
${CPP_WRAPPER_SOURCES_APP}
${PHONY_OUTPUT}
COMMAND ${CMAKE_COMMAND} -E env
${FLUTTER_TOOL_ENVIRONMENT}
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat"
${FLUTTER_TARGET_PLATFORM} $
VERBATIM
)
add_custom_target(flutter_assemble DEPENDS
"${FLUTTER_LIBRARY}"
${FLUTTER_LIBRARY_HEADERS}
${CPP_WRAPPER_SOURCES_CORE}
${CPP_WRAPPER_SOURCES_PLUGIN}
${CPP_WRAPPER_SOURCES_APP}
)
```
--------------------------------
### Flutter Library Target
Source: https://github.com/nikoro/system_date_time_format/blob/main/example_with_tests/linux/flutter/CMakeLists.txt
Defines the Flutter library target, including interface include directories and linking against system libraries and the Flutter shared object.
```cmake
add_library(flutter INTERFACE)
target_include_directories(flutter INTERFACE
"${EPHEMERAL_DIR}"
)
target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}")
target_link_libraries(flutter INTERFACE
PkgConfig::GTK
PkgConfig::GLIB
PkgConfig::GIO
)
add_dependencies(flutter flutter_assemble)
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.