dev
txt 183 lines 6.27 KB
Raw
1 # Project-level configuration.
2 cmake_minimum_required(VERSION 3.10)
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 "cake_wallet")
8 # The unique GTK application identifier for this application. See:
9 # https://wiki.gnome.org/HowDoI/ChooseApplicationID
10 set(APPLICATION_ID "com.example.cake_wallet")
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 add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}")
58
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.
63 add_executable(${BINARY_NAME}
64 "main.cc"
65 "my_application.cc"
66 "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
67 )
68
69 # Apply the standard set of build settings. This can be removed for applications
70 # that need different build settings.
71 apply_standard_settings(${BINARY_NAME})
72
73 # Add dependency libraries. Add any application-specific dependencies here.
74 target_link_libraries(${BINARY_NAME} PRIVATE flutter)
75 target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK)
76
77 # Run the Flutter tool portions of the build. This must not be removed.
78 add_dependencies(${BINARY_NAME} flutter_assemble)
79
80 # Only the install-generated bundle's copy of the executable will launch
81 # correctly, since the resources must in the right relative locations. To avoid
82 # people trying to run the unbundled copy, put it in a subdirectory instead of
83 # the default top-level location.
84 set_target_properties(${BINARY_NAME}
85 PROPERTIES
86 RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run"
87 )
88
89 # Generated plugin build rules, which manage building the plugins and adding
90 # them to the application.
91 include(flutter/generated_plugins.cmake)
92
93
94 # === Installation ===
95 # By default, "installing" just makes a relocatable bundle in the build
96 # directory.
97 set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle")
98 if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
99 set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
100 endif()
101
102 # Start with a clean build bundle directory every time.
103 install(CODE "
104 file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\")
105 " COMPONENT Runtime)
106
107 set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
108 set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")
109
110 if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
111 set(LIB_TRIPLET "aarch64-linux-gnu")
112 else()
113 set(LIB_TRIPLET "x86_64-linux-gnu")
114 endif()
115
116 execute_process(
117 COMMAND git describe --tags
118 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/monero_c
119 OUTPUT_VARIABLE MONERO_C_TAG
120 OUTPUT_STRIP_TRAILING_WHITESPACE
121 )
122
123 set(MONERO_C_RELEASE_DIR
124 "${CMAKE_CURRENT_SOURCE_DIR}/../scripts/monero_c/release/${MONERO_C_TAG}/${LIB_TRIPLET}"
125 )
126
127 install(
128 FILES "${CMAKE_CURRENT_SOURCE_DIR}/../scripts/zcash_lib/target/release/libwarp_api_ffi.so"
129 DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
130 RENAME "libwarp_api_ffi.so"
131 COMPONENT Runtime
132 )
133
134 install(
135 FILES "${MONERO_C_RELEASE_DIR}/libmonero_wallet2_api_c.so"
136 DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
137 RENAME "libmonero_wallet2_api_c.so"
138 COMPONENT Runtime
139 )
140
141 install(
142 FILES "${MONERO_C_RELEASE_DIR}/libwownero_wallet2_api_c.so"
143 DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
144 RENAME "libwownero_wallet2_api_c.so"
145 COMPONENT Runtime
146 )
147
148 install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
149 COMPONENT Runtime)
150
151 install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
152 COMPONENT Runtime)
153
154 install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
155 COMPONENT Runtime)
156
157 foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES})
158 install(FILES "${bundled_library}"
159 DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
160 COMPONENT Runtime)
161 endforeach(bundled_library)
162
163 install(CODE "
164 execute_process(
165 COMMAND \"${CMAKE_COMMAND}\" -E create_symlink
166 libsqlite3_flutter_libs_plugin.so
167 \"${INSTALL_BUNDLE_LIB_DIR}/libsqlite3.so\")
168 " COMPONENT Runtime)
169
170 # Fully re-copy the assets directory on each build to avoid having stale files
171 # from a previous install.
172 set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
173 install(CODE "
174 file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
175 " COMPONENT Runtime)
176 install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
177 DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
178
179 # Install the AOT library on non-Debug builds only.
180 if(NOT CMAKE_BUILD_TYPE MATCHES "Debug")
181 install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
182 COMPONENT Runtime)
183 endif()