languages

A collection of programs made with different programming languages.
git clone git://evanalba.com/languages
Log | Files | Refs

CMakeLists.txt (4146B)


      1 # Project-level configuration.
      2 cmake_minimum_required(VERSION 3.14)
      3 project(penny 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 "penny")
      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 if(PLUGIN_BUNDLED_LIBRARIES)
     85   install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
     86     DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
     87     COMPONENT Runtime)
     88 endif()
     89 
     90 # Copy the native assets provided by the build.dart from all packages.
     91 set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/")
     92 install(DIRECTORY "${NATIVE_ASSETS_DIR}"
     93    DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
     94    COMPONENT Runtime)
     95 
     96 # Fully re-copy the assets directory on each build to avoid having stale files
     97 # from a previous install.
     98 set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
     99 install(CODE "
    100   file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
    101   " COMPONENT Runtime)
    102 install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
    103   DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
    104 
    105 # Install the AOT library on non-Debug builds only.
    106 install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
    107   CONFIGURATIONS Profile;Release
    108   COMPONENT Runtime)