2022-05-23 11:25:55 +03:00
# Project-level configuration.
cmake_minimum_required ( VERSION 3.14 )
2022-11-12 07:24:50 +03:00
project ( rustdesk LANGUAGES CXX )
2022-05-23 11:25:55 +03:00
# The name of the executable created for the application. Change this to change
# the on-disk name of your application.
2022-09-19 05:05:53 +03:00
set ( BINARY_NAME "rustdesk" )
2022-05-23 11:25:55 +03:00
2023-01-09 09:20:20 +03:00
# Explicitly opt into modern CMake behaviors to avoid warnings with recent
2022-05-23 11:25:55 +03:00
# versions of CMake.
cmake_policy ( SET CMP0063 NEW )
# Define build configuration option.
get_property ( IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG )
if ( IS_MULTICONFIG )
set ( CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release"
C A C H E S T R I N G " " F O R C E )
else ( )
if ( NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES )
set ( CMAKE_BUILD_TYPE "Debug" CACHE
S T R I N G " F l u t t e r b u i l d m o d e " F O R C E )
set_property ( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
" D e b u g " " P r o f i l e " " R e l e a s e " )
endif ( )
endif ( )
# Define settings for the Profile build mode.
set ( CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}" )
set ( CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}" )
set ( CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}" )
set ( CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}" )
2022-11-12 07:24:50 +03:00
# Replace /MD flags to /MT to use static vcruntine
set ( CompilerFlags
C M A K E _ C X X _ F L A G S
C M A K E _ C X X _ F L A G S _ D E B U G
C M A K E _ C X X _ F L A G S _ R E L E A S E
C M A K E _ C _ F L A G S
C M A K E _ C _ F L A G S _ D E B U G
C M A K E _ C _ F L A G S _ R E L E A S E
)
foreach ( CompilerFlag ${ CompilerFlags } )
string ( REPLACE "/MD" "/MT" ${ CompilerFlag } "${${CompilerFlag}}" )
endforeach ( )
2022-05-23 11:25:55 +03:00
# Use Unicode for all projects.
add_definitions ( -DUNICODE -D_UNICODE )
# Compilation settings that should be applied to most targets.
#
# Be cautious about adding new options here, as plugins use this function by
# default. In most cases, you should add new options to specific targets instead
# of modifying this function.
function ( APPLY_STANDARD_SETTINGS TARGET )
target_compile_features ( ${ TARGET } PUBLIC cxx_std_17 )
target_compile_options ( ${ TARGET } PRIVATE /W4 /WX /wd "4100" )
target_compile_options ( ${ TARGET } PRIVATE /EHsc )
2022-11-12 07:24:50 +03:00
# Disable VC140_1
target_compile_options ( ${ TARGET } PRIVATE /d2FH4- )
2022-05-23 11:25:55 +03:00
target_compile_definitions ( ${ TARGET } PRIVATE "_HAS_EXCEPTIONS=0" )
target_compile_definitions ( ${ TARGET } PRIVATE "$<$<CONFIG:Debug>:_DEBUG>" )
endfunction ( )
# Flutter library and tool build rules.
set ( FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter" )
add_subdirectory ( ${ FLUTTER_MANAGED_DIR } )
# Application build; see runner/CMakeLists.txt.
add_subdirectory ( "runner" )
# Generated plugin build rules, which manage building the plugins and adding
# them to the application.
include ( flutter/generated_plugins.cmake )
# === Installation ===
# Support files are copied into place next to the executable, so that it can
# run in place. This is done instead of making a separate bundle (as on Linux)
# so that building and running from within Visual Studio will work.
set ( BUILD_BUNDLE_DIR "$<TARGET_FILE_DIR:${BINARY_NAME}>" )
# Make the "install" step default, as it's required to run.
set ( CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1 )
if ( CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT )
set ( CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE )
endif ( )
set ( INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data" )
set ( INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}" )
install ( TARGETS ${ BINARY_NAME } RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
C O M P O N E N T R u n t i m e )
install ( FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
C O M P O N E N T R u n t i m e )
install ( FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
C O M P O N E N T R u n t i m e )
if ( PLUGIN_BUNDLED_LIBRARIES )
install ( FILES "${PLUGIN_BUNDLED_LIBRARIES}"
D E S T I N A T I O N " $ { I N S T A L L _ B U N D L E _ L I B _ D I R } "
C O M P O N E N T R u n t i m e )
endif ( )
2022-09-12 13:04:00 +03:00
# flutter_rust_bridge
set ( RUSTDESK_LIB_BUILD_TYPE $< IF:$<CONFIG:Debug > ,debug,release> )
message ( STATUS "rustdesk lib build type: ${RUSTDESK_LIB_BUILD_TYPE}" )
set ( RUSTDESK_LIB "../../target/${RUSTDESK_LIB_BUILD_TYPE}/librustdesk.dll" )
install ( FILES "${RUSTDESK_LIB}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
C O M P O N E N T R u n t i m e R E N A M E l i b r u s t d e s k . d l l )
2022-05-23 11:25:55 +03:00
# Fully re-copy the assets directory on each build to avoid having stale files
# from a previous install.
set ( FLUTTER_ASSET_DIR_NAME "flutter_assets" )
install ( CODE "
file ( REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
" C O M P O N E N T R u n t i m e )
install ( DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
D E S T I N A T I O N " $ { I N S T A L L _ B U N D L E _ D A T A _ D I R } " C O M P O N E N T R u n t i m e )
# Install the AOT library on non-Debug builds only.
install ( FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
C O N F I G U R A T I O N S P r o f i l e ; R e l e a s e
C O M P O N E N T R u n t i m e )