main
1# Project-level configuration.
2cmake_minimum_required(VERSION 3.14)
3project(blood_pressure_app LANGUAGES CXX)
4
5# The name of the executable created for the application. Change this to change
6# the on-disk name of your application.
7set(BINARY_NAME "blood_pressure_app")
8
9# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
10# versions of CMake.
11cmake_policy(SET CMP0063 NEW)
12
13# Define build configuration option.
14get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
15if(IS_MULTICONFIG)
16 set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release"
17 CACHE STRING "" FORCE)
18else()
19 if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
20 set(CMAKE_BUILD_TYPE "Debug" CACHE
21 STRING "Flutter build mode" FORCE)
22 set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
23 "Debug" "Profile" "Release")
24 endif()
25endif()
26# Define settings for the Profile build mode.
27set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
28set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
29set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}")
30set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}")
31
32# Use Unicode for all projects.
33add_definitions(-DUNICODE -D_UNICODE)
34
35# Compilation settings that should be applied to most targets.
36#
37# Be cautious about adding new options here, as plugins use this function by
38# default. In most cases, you should add new options to specific targets instead
39# of modifying this function.
40function(APPLY_STANDARD_SETTINGS TARGET)
41 target_compile_features(${TARGET} PUBLIC cxx_std_17)
42 target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100")
43 target_compile_options(${TARGET} PRIVATE /EHsc)
44 target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0")
45 target_compile_definitions(${TARGET} PRIVATE "$<$<CONFIG:Debug>:_DEBUG>")
46endfunction()
47
48# Flutter library and tool build rules.
49set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
50add_subdirectory(${FLUTTER_MANAGED_DIR})
51
52# Application build; see runner/CMakeLists.txt.
53add_subdirectory("runner")
54
55# Generated plugin build rules, which manage building the plugins and adding
56# them to the application.
57include(flutter/generated_plugins.cmake)
58
59
60# === Installation ===
61# Support files are copied into place next to the executable, so that it can
62# run in place. This is done instead of making a separate bundle (as on Linux)
63# so that building and running from within Visual Studio will work.
64set(BUILD_BUNDLE_DIR "$<TARGET_FILE_DIR:${BINARY_NAME}>")
65# Make the "install" step default, as it's required to run.
66set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1)
67if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
68 set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
69endif()
70
71set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
72set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}")
73
74install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
75 COMPONENT Runtime)
76
77install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
78 COMPONENT Runtime)
79
80install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
81 COMPONENT Runtime)
82
83if(PLUGIN_BUNDLED_LIBRARIES)
84 install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
85 DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
86 COMPONENT Runtime)
87endif()
88
89# Fully re-copy the assets directory on each build to avoid having stale files
90# from a previous install.
91set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
92install(CODE "
93 file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
94 " COMPONENT Runtime)
95install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
96 DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
97
98# Install the AOT library on non-Debug builds only.
99install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
100 CONFIGURATIONS Profile;Release
101 COMPONENT Runtime)