| 1 | # Project-level configuration. |
| 2 | cmake_minimum_required(VERSION 3.14) |
| 3 | project(cake_wallet 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 "CakeWallet") |
| 8 | |
| 9 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent |
| 10 | # versions of CMake. |
| 11 | cmake_policy(VERSION 3.14...3.25) |
| 12 | |
| 13 | # Define build configuration option. |
| 14 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) |
| 15 | if(IS_MULTICONFIG) |
| 16 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" |
| 17 | CACHE STRING "" FORCE) |
| 18 | else() |
| 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() |
| 25 | endif() |
| 26 | # Define settings for the Profile build mode. |
| 27 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") |
| 28 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") |
| 29 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") |
| 30 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") |
| 31 | |
| 32 | # Use Unicode for all projects. |
| 33 | add_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. |
| 40 | function(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>") |
| 46 | endfunction() |
| 47 | |
| 48 | # Flutter library and tool build rules. |
| 49 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") |
| 50 | add_subdirectory(${FLUTTER_MANAGED_DIR}) |
| 51 | |
| 52 | # Application build; see runner/CMakeLists.txt. |
| 53 | add_subdirectory("runner") |
| 54 | |
| 55 | |
| 56 | # Generated plugin build rules, which manage building the plugins and adding |
| 57 | # them to the application. |
| 58 | include(flutter/generated_plugins.cmake) |
| 59 | |
| 60 | |
| 61 | # === Installation === |
| 62 | # Support files are copied into place next to the executable, so that it can |
| 63 | # run in place. This is done instead of making a separate bundle (as on Linux) |
| 64 | # so that building and running from within Visual Studio will work. |
| 65 | set(BUILD_BUNDLE_DIR "$<TARGET_FILE_DIR:${BINARY_NAME}>") |
| 66 | # Make the "install" step default, as it's required to run. |
| 67 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) |
| 68 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) |
| 69 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) |
| 70 | endif() |
| 71 | |
| 72 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") |
| 73 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") |
| 74 | |
| 75 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" |
| 76 | COMPONENT Runtime) |
| 77 | |
| 78 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" |
| 79 | COMPONENT Runtime) |
| 80 | |
| 81 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" |
| 82 | COMPONENT Runtime) |
| 83 | |
| 84 | install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/../scripts/monero_c/release/monero/x86_64-w64-mingw32_libwallet2_api_c.dll" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" RENAME "monero_libwallet2_api_c.dll" |
| 85 | COMPONENT Runtime) |
| 86 | |
| 87 | install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/../scripts/monero_c/release/wownero/x86_64-w64-mingw32_libwallet2_api_c.dll" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" RENAME "wownero_libwallet2_api_c.dll" |
| 88 | COMPONENT Runtime) |
| 89 | |
| 90 | |
| 91 | install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/../scripts/monero_c/release/monero/x86_64-w64-mingw32_libssp-0.dll" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" RENAME "libssp-0.dll" |
| 92 | COMPONENT Runtime) |
| 93 | |
| 94 | install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/../scripts/monero_c/release/monero/x86_64-w64-mingw32_libwinpthread-1.dll" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" RENAME "libwinpthread-1.dll" |
| 95 | COMPONENT Runtime) |
| 96 | |
| 97 | if(PLUGIN_BUNDLED_LIBRARIES) |
| 98 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" |
| 99 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" |
| 100 | COMPONENT Runtime) |
| 101 | endif() |
| 102 | |
| 103 | # Fully re-copy the assets directory on each build to avoid having stale files |
| 104 | # from a previous install. |
| 105 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") |
| 106 | install(CODE " |
| 107 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") |
| 108 | " COMPONENT Runtime) |
| 109 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" |
| 110 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) |
| 111 | |
| 112 | # Install the AOT library on non-Debug builds only. |
| 113 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" |
| 114 | CONFIGURATIONS Profile;Release |
| 115 | COMPONENT Runtime) |