mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

~Update the windows app template and migration to use `CMP0135` when cmake version is >= 3.24.~ Update app templates' and examples' CMakeLists.txt to use `cmake_policy(VERSION`. https://github.com/flutter/packages/pull/3828 should obviate the need for a migration. Addresses https://github.com/flutter/flutter/issues/116866 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [ ] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [test-exempt]: https://github.com/flutter/flutter/wiki/Tree-hygiene#tests [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [Features we expect every widget to implement]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat
96 lines
3.4 KiB
CMake
96 lines
3.4 KiB
CMake
cmake_minimum_required(VERSION 3.14)
|
|
project(dartpad_curve2_d_0 LANGUAGES CXX)
|
|
|
|
set(BINARY_NAME "dartpad_curve2_d_0")
|
|
|
|
cmake_policy(VERSION 3.14...3.25)
|
|
|
|
set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
|
|
|
|
# Configure build options.
|
|
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()
|
|
|
|
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}")
|
|
|
|
# Use Unicode for all projects.
|
|
add_definitions(-DUNICODE -D_UNICODE)
|
|
|
|
# Compilation settings that should be applied to most targets.
|
|
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 "$<$<CONFIG:Debug>:_DEBUG>")
|
|
endfunction()
|
|
|
|
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
|
|
|
|
# Flutter library and tool build rules.
|
|
add_subdirectory(${FLUTTER_MANAGED_DIR})
|
|
|
|
# Application build
|
|
add_subdirectory("runner")
|
|
|
|
# Generated plugin build rules, which manage building the plugins and adding
|
|
# them to the application.
|
|
include(flutter/generated_plugins.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 "$<TARGET_FILE_DIR:${BINARY_NAME}>")
|
|
# 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()
|
|
|
|
# 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)
|