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