2024-03-19 14:45:23 +01:00
# CMakeLists.txt file to build the MEGAcmd
cmake_minimum_required ( VERSION 3.16 )
2024-11-19 14:01:18 +01:00
find_package ( Git REQUIRED )
execute_process (
C O M M A N D $ { G I T _ E X E C U T A B L E } r e v - p a r s e - - s h o r t H E A D
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ C U R R E N T _ L I S T _ D I R } / s d k
O U T P U T _ V A R I A B L E S D K _ C O M M I T _ H A S H
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E
)
2025-01-23 21:03:55 +01:00
set ( MEGACMD_MAJOR_VERSION 2 )
2025-03-19 10:30:34 +01:00
set ( MEGACMD_MINOR_VERSION 1 )
2024-07-10 16:34:47 +02:00
set ( MEGACMD_MICRO_VERSION 0 )
2024-11-19 14:01:18 +01:00
## Configure megacmdversion.h
2024-07-10 16:34:47 +02:00
configure_file ( "${CMAKE_CURRENT_LIST_DIR}/src/megacmdversion.h.in" "${CMAKE_CURRENT_LIST_DIR}/src/megacmdversion.h" @ONLY )
if ( APPLE )
configure_file ( "${CMAKE_CURRENT_LIST_DIR}/build/installer/Info.plist.in" "${CMAKE_CURRENT_LIST_DIR}/build/installer/Info.plist" @ONLY )
endif ( )
2024-03-19 14:45:23 +01:00
# Qt Creator configures VCPKG automatically. Disable it, we may want to use different tripplets, paths...
set ( QT_CREATOR_SKIP_VCPKG_SETUP TRUE CACHE BOOL "" )
## Modules location
2024-04-30 17:20:21 +02:00
list ( APPEND CMAKE_MODULE_PATH ${ CMAKE_CURRENT_LIST_DIR } /build/cmake/modules ) # Modules from MEGAcmd
2024-11-05 13:20:57 +01:00
list ( APPEND CMAKE_MODULE_PATH ${ CMAKE_CURRENT_LIST_DIR } /sdk/cmake/modules ) # Modules from MEGAsdk
2024-03-19 14:45:23 +01:00
2024-04-30 10:56:00 +02:00
set ( VCPKG_ROOT "${CMAKE_CURRENT_LIST_DIR}/../vcpkg" CACHE PATH "If set, it will build and use the VCPKG packages defined in the manifest file" )
2025-01-22 10:49:05 +01:00
include ( detect_host_architecture )
2024-07-18 16:37:53 +02:00
if ( WIN32 )
execute_process (
C O M M A N D b a s h - - v e r s i o n
R E S U L T _ V A R I A B L E B A S H _ V E R S I O N _ R E S U L T
O U T P U T _ Q U I E T
E R R O R _ Q U I E T
)
endif ( )
if ( ( NOT WIN32 OR BASH_VERSION_RESULT EQUAL 0 ) AND NOT EXISTS ${ VCPKG_ROOT } )
2024-04-30 10:56:00 +02:00
message ( STATUS "vcpkg will be cloned into ${VCPKG_ROOT}" )
execute_process (
#TODO: have the same for windows ... or at least check if bash is available
2024-07-19 14:11:58 +02:00
C O M M A N D " b a s h " " - x " " $ { C M A K E _ C U R R E N T _ L I S T _ D I R } / b u i l d / c l o n e _ v c p k g _ f r o m _ b a s e l i n e . s h " " $ { V C P K G _ R O O T } "
2024-04-30 10:56:00 +02:00
W O R K I N G _ D I R E C T O R Y " $ { C M A K E _ C U R R E N T _ L I S T _ D I R } "
E R R O R _ V A R I A B L E r e s u l t e
O U T P U T _ V A R I A B L E r e s u l t
R E S U L T _ V A R I A B L E s t a t u s
)
if ( NOT status EQUAL "0" )
2024-07-19 14:00:59 +02:00
message ( FATAL_ERROR "Failed to run the clone_vcpkg_from_baseline. ${status} ${result} ${resulte} " )
2024-04-30 10:56:00 +02:00
endif ( )
message ( STATUS "vcpkg cloned successfully: ${status}" )
endif ( )
2024-04-25 13:42:32 +02:00
#TODO: Review the following, move to a separate module and add add_executable WIN32/MACOSX_BUNDLE properties
# Set min OSX version
if ( CMAKE_HOST_APPLE )
# Minimum deployment target differs if we are building for intel or arm64 targets
# CMAKE_SYSTEM_PROCESSOR and CMAKE_HOST_SYSTEM_PROCESSOR are only available after project()
execute_process (
C O M M A N D u n a m e - m
O U T P U T _ V A R I A B L E H O S T _ A R C H I T E C T U R E
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
# Setup CMAKE_OSX_DEPLOYMENT_TARGET before project()
if ( CMAKE_OSX_ARCHITECTURES STREQUAL "arm64" OR ( NOT CMAKE_OSX_ARCHITECTURES AND HOST_ARCHITECTURE STREQUAL "arm64" ) )
set ( CMAKE_OSX_DEPLOYMENT_TARGET "11.1" CACHE STRING "Minimum OS X deployment version" )
else ( )
2024-10-28 17:05:28 +01:00
set ( CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version" )
2024-04-25 13:42:32 +02:00
endif ( )
message ( STATUS "Minimum OS X deployment version is set to ${CMAKE_OSX_DEPLOYMENT_TARGET}" )
unset ( HOST_ARCHITECTURE )
endif ( )
if ( WIN32 )
add_definitions ( -DUNICODE -D_UNICODE ) # needed for visual studio projects to use the unicode runtime libraries
#supported windows version: 7 and beyond
2024-07-25 12:55:17 +02:00
add_definitions ( -D_WIN32_WINNT=0x0601 ) # 0601: windows 7. Note: NTDDI_VERSIO & WINVER shall be inferred from those by Win SDK
2024-04-25 16:36:48 +02:00
add_definitions ( -DNO_READLINE ) # This one is defined within SdkLib, but we need it too for MEGAcmd code.
2024-04-25 16:15:20 +02:00
add_definitions ( -DUSE_CPPTHREAD ) # For win32, we need this to be defined explicitly (used directly in different targets). TODO: remove in CMD-318
2024-04-25 16:36:48 +02:00
add_definitions ( -DNOMINMAX ) # To fix usages of std::min / std::max
2024-04-25 13:42:32 +02:00
endif ( )
2024-03-19 14:45:23 +01:00
## Configurable options ##
include ( megacmd_options ) #Load first MEGAcmd's options (that we have prevalescence over SDK (e.g libuv)
include ( sdklib_options ) #load default sdk's
2024-04-30 10:56:00 +02:00
if ( EXISTS ${ CMAKE_CURRENT_LIST_DIR } /sdk/include/mega/config.h )
file ( RENAME ${ CMAKE_CURRENT_LIST_DIR } /sdk/include/mega/config.h ${ CMAKE_CURRENT_LIST_DIR } /sdk/include/mega/config.h_non_cmake_bk )
endif ( )
2024-03-19 14:45:23 +01:00
message ( STATUS "Using VCPKG_ROOT = ${VCPKG_ROOT}" )
if ( VCPKG_ROOT )
2024-04-30 17:27:40 +02:00
if ( ENABLE_MEGACMD_TESTS )
list ( APPEND VCPKG_MANIFEST_FEATURES "megacmd-enable-tests" )
endif ( )
2024-03-19 14:45:23 +01:00
# Include VCPKG management tools.
include ( vcpkg_management )
2024-11-05 13:20:57 +01:00
list ( APPEND vcpkg_overlay ${ CMAKE_CURRENT_LIST_DIR } /sdk/cmake ) # MEGAsdk overlays
2024-03-19 14:45:23 +01:00
process_vcpkg_libraries ( "${vcpkg_overlay}" ) # Choose and build libraries depending on the configured options.
else ( )
# For packages with no pkg-config in the system.
2024-11-05 13:20:57 +01:00
list ( APPEND CMAKE_MODULE_PATH sdk/cmake/modules/packages )
2024-03-19 14:45:23 +01:00
message ( STATUS "Using system dependencies" )
endif ( )
project ( MEGAcmd
2024-07-10 16:34:47 +02:00
V E R S I O N $ { M E G A C M D _ M A J O R _ V E R S I O N } . $ { M E G A C M D _ M I N O R _ V E R S I O N } . $ { M E G A C M D _ M I C R O _ V E R S I O N }
2024-03-19 14:45:23 +01:00
D E S C R I P T I O N " M E G A c m d "
)
# In-source build not allowed
if ( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR )
message ( FATAL_ERROR "In-source build is not allowed. Remove CMakeCache.txt and the CMakeFiles directory and set a new binary directory different than the source tree." )
endif ( )
message ( STATUS "Building MEGAcmd v${PROJECT_VERSION}" )
#utilities/helper functions
include ( GNUInstallDirs ) # Values for installation directories. All platforms
include ( CMakePackageConfigHelpers ) # For the CMake package
include ( target_sources_conditional ) # To add files to the project without building them
include ( target_platform_compile_options ) # To add compile options depeding on the platform
2024-05-08 14:52:45 +02:00
if ( UNIX AND NOT APPLE )
# Set rpath and location for dirs accordingly:
# If CMAKE_INSTALL_PREFIX is set (not default), it will set rpath to to such prefix plus /opt/....
# If CMAKE_INSTALL_PREFIX is not set, it will set rpath to /opt/....
# Note: using cmake --install --prefix /some/prefix will not set rpath relative to that prefix
# The above can be used for building packages: in which install dir is a path construction folder that will not be there in packages
set ( CMAKE_INSTALL_LIBDIR "opt/megacmd/lib" )
set ( CMAKE_INSTALL_BINDIR "usr/bin" ) #override default "bin"
if ( CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT )
message ( STATUS "Overriding default CMAKE_INSTALL_PREFIX to /" )
2024-05-15 10:18:24 +02:00
set ( CMAKE_INSTALL_PREFIX "/" CACHE PATH "Default install path" FORCE ) # override default /usr/local
2024-05-09 13:02:44 +02:00
set ( RPATH_FOR_DYNAMIC_LIBS "/${CMAKE_INSTALL_LIBDIR}" )
2024-05-08 14:52:45 +02:00
else ( )
# If explicit cmake prefix at cmake call time, make rpath relative to install dir
set ( RPATH_FOR_DYNAMIC_LIBS "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" )
endif ( )
list ( APPEND CMAKE_INSTALL_RPATH "${RPATH_FOR_DYNAMIC_LIBS}" )
endif ( )
2024-03-26 17:53:48 +01:00
if ( APPLE )
set ( CMAKE_MACOSX_RPATH 1 )
get_filename_component ( ABSOLUTE_RPATH_LIBS ${ CMAKE_INSTALL_PREFIX } / ${ CMAKE_INSTALL_LIBDIR } ABSOLUTE )
list ( APPEND CMAKE_INSTALL_RPATH ${ ABSOLUTE_RPATH_LIBS } )
#set(CMAKE_INSTALL_RPATH ${ABSOLUTE_RPATH_LIBS})
message ( STATUS "Added CMAKE_INSTALL_LIBDIR=${ABSOLUTE_RPATH_LIBS} to rpath: ${CMAKE_INSTALL_RPATH}" )
endif ( )
2024-03-19 14:45:23 +01:00
# Load SDK project to build sdk library
add_subdirectory ( sdk )
#LOAD MEGACMD modules:
include ( megacmd_configuration ) ## Load global CMake configuration for the project
include ( megacmd_libraries ) # to load libraries dependencies by target
2024-03-20 12:56:06 +01:00
include ( megacmd_utility_functions ) # utility functions
2024-03-19 14:45:23 +01:00
2024-03-20 12:56:06 +01:00
#TODO: CONSIDER SPLITTING TARGET IN FILES and have add_subdirectory(src) , ... See MR !682
2024-03-19 14:45:23 +01:00
set ( ProjectDir "${CMAKE_CURRENT_LIST_DIR}" )
2024-10-04 16:33:14 +02:00
# Populate list of MEGAcmd source files (used by logger):
generate_src_file_list ( "${ProjectDir}/sdk" SDK_SRCS )
generate_src_file_list ( "${ProjectDir}/src" MEGACMD_SRCS )
foreach ( CMDFILE ${ MEGACMD_SRCS } )
if ( CMDFILE IN_LIST SDK_SRCS )
message ( FATAL_ERROR "MEGAcmd src filename ${CMDFILE} clashing with SDK's: please, pick a new one" )
endif ( )
endforeach ( )
string ( JOIN ", " MEGACMD_SRC_FILE_LIST ${ MEGACMD_SRCS } )
configure_file ( "${ProjectDir}/src/megacmd_src_file_list.h.in" "${ProjectDir}/src/megacmd_src_file_list.h" @ONLY )
2024-09-25 21:53:35 +02:00
2024-05-15 13:26:34 +02:00
add_library ( LMEGAcmdCommonUtils STATIC )
add_source_and_corresponding_header_to_target ( LMEGAcmdCommonUtils
P U B L I C
" $ { P r o j e c t D i r } / s r c / m e g a c m d c o m m o n u t i l s . c p p "
2025-01-27 12:24:06 +01:00
" $ { P r o j e c t D i r } / s r c / m e g a c m d _ u t f 8 . c p p "
2024-05-15 13:26:34 +02:00
)
2024-03-20 12:56:06 +01:00
add_library ( LMegacmdServer STATIC )
add_source_and_corresponding_header_to_target ( LMegacmdServer
P U B L I C
2024-03-19 14:45:23 +01:00
" $ { P r o j e c t D i r } / s r c / m e g a c m d . c p p "
" $ { P r o j e c t D i r } / s r c / m e g a c m d e x e c u t e r . c p p "
" $ { P r o j e c t D i r } / s r c / m e g a c m d _ e v e n t s . c p p "
" $ { P r o j e c t D i r } / s r c / m e g a c m d l o g g e r . c p p "
" $ { P r o j e c t D i r } / s r c / m e g a c m d s a n d b o x . c p p "
" $ { P r o j e c t D i r } / s r c / m e g a c m d u t i l s . c p p "
" $ { P r o j e c t D i r } / s r c / c o m u n i c a t i o n s m a n a g e r . c p p "
" $ { P r o j e c t D i r } / s r c / c o m u n i c a t i o n s m a n a g e r f i l e s o c k e t s . c p p "
" $ { P r o j e c t D i r } / s r c / c o m u n i c a t i o n s m a n a g e r n a m e d p i p e s . c p p "
" $ { P r o j e c t D i r } / s r c / c o n f i g u r a t i o n m a n a g e r . c p p "
" $ { P r o j e c t D i r } / s r c / l i s t e n e r s . c p p "
2024-09-16 21:34:56 +02:00
" $ { P r o j e c t D i r } / s r c / s y n c _ c o m m a n d . c p p "
2024-09-02 17:48:42 +02:00
" $ { P r o j e c t D i r } / s r c / s y n c _ i s s u e s . c p p "
2024-08-09 14:34:55 +02:00
" $ { P r o j e c t D i r } / s r c / s y n c _ i g n o r e . c p p "
2024-11-18 22:17:35 +01:00
" $ { P r o j e c t D i r } / s r c / m e g a c m d _ r o t a t i n g _ l o g g e r . c p p "
2025-01-02 18:14:59 +01:00
" $ { P r o j e c t D i r } / s r c / m e g a c m d _ f u s e . c p p "
2024-03-19 14:45:23 +01:00
)
2024-03-20 13:41:05 +01:00
target_sources_conditional ( LMegacmdServer
F L A G APPLE
P R I V A T E
" $ { P r o j e c t D i r } / s r c / m e g a c m d p l a t f o r m . h "
" $ { P r o j e c t D i r } / s r c / m e g a c m d p l a t f o r m . m m "
)
2024-08-09 14:34:55 +02:00
# Given we are no longer including the sdk, and some sources use certain defines without including SDK's config.h,
2024-11-19 00:45:33 +01:00
# We need to explicitly pass the compiling options.
2024-03-19 14:45:23 +01:00
target_compile_definitions ( LMegacmdServer
P U B L I C
$ < $ < B O O L : $ { U S E _ P C R E } > : U S E _ P C R E >
)
2025-01-20 14:13:17 +01:00
if ( NOT WIN32 )
if ( ENABLE_ASAN )
add_compile_options ( "-fsanitize=address" "-fno-omit-frame-pointer" "-fno-common" )
link_libraries ( "-fsanitize=address" )
endif ( )
if ( ENABLE_UBSAN )
add_compile_options ( "-fsanitize=undefined" "-fno-omit-frame-pointer" )
link_libraries ( "-fsanitize=undefined" )
endif ( )
if ( ENABLE_TSAN )
add_compile_options ( "-fsanitize=thread" "-fno-omit-frame-pointer" )
link_libraries ( "-fsanitize=thread" )
endif ( )
endif ( )
2024-07-10 13:44:14 +02:00
if ( APPLE )
set ( executablesType MACOSX_BUNDLE )
endif ( )
2024-07-10 16:34:47 +02:00
add_executable ( mega-cmd-server ${ executablesType } )
2024-07-10 19:00:43 +02:00
if ( WIN32 )
2024-08-27 16:59:18 +02:00
set ( MEGACMD_RESOURCE_NAME MEGAcmdServer )
2024-07-11 14:26:02 +02:00
configure_file ( "${CMAKE_CURRENT_LIST_DIR}/build/installer/winversion.rc.in" "${CMAKE_CURRENT_LIST_DIR}/build/installer/mega-cmd-server_version.rc" @ONLY )
2024-08-27 16:59:18 +02:00
set ( RESOURCE_FILES_MEGACMD_SERVER "${CMAKE_CURRENT_LIST_DIR}/build/installer/mega-cmd-server_version.rc" )
set ( MEGACMD_RESOURCE_NAME MEGAclient )
configure_file ( "${CMAKE_CURRENT_LIST_DIR}/build/installer/winversion.rc.in" "${CMAKE_CURRENT_LIST_DIR}/build/installer/mega-cmd-client_version.rc" @ONLY )
set ( RESOURCE_FILES_MEGACMD_CLIENT "${CMAKE_CURRENT_LIST_DIR}/build/installer/mega-cmd-client_version.rc" )
set ( MEGACMD_RESOURCE_NAME MEGAcmdShell )
configure_file ( "${CMAKE_CURRENT_LIST_DIR}/build/installer/winversion.rc.in" "${CMAKE_CURRENT_LIST_DIR}/build/installer/mega-cmd-shell_version.rc" @ONLY )
set ( RESOURCE_FILES_MEGACMD_SHELL "${CMAKE_CURRENT_LIST_DIR}/build/installer/mega-cmd-shell_version.rc" )
set ( MEGACMD_RESOURCE_NAME MEGAcmdUpdater )
configure_file ( "${CMAKE_CURRENT_LIST_DIR}/build/installer/winversion.rc.in" "${CMAKE_CURRENT_LIST_DIR}/build/installer/mega-cmd-updater_version.rc" @ONLY )
set ( RESOURCE_FILES_MEGACMD_UPDATER "${CMAKE_CURRENT_LIST_DIR}/build/installer/mega-cmd-updater_version.rc" )
2024-07-10 19:00:43 +02:00
elseif ( APPLE )
2024-08-27 16:59:18 +02:00
set ( RESOURCE_FILES_MEGACMD_SERVER
2024-07-10 19:00:43 +02:00
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / b u i l d / i n s t a l l e r / a p p . i c n s
)
set_target_properties ( mega-cmd-server PROPERTIES
M A C O S X _ B U N D L E T R U E
M A C O S X _ B U N D L E _ I N F O _ P L I S T $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / b u i l d / i n s t a l l e r / I n f o . p l i s t
2024-08-27 16:59:18 +02:00
R E S O U R C E " $ { R E S O U R C E _ F I L E S _ M E G A C M D _ S E R V E R } "
2024-07-10 19:00:43 +02:00
)
endif ( )
2024-03-20 12:56:06 +01:00
add_source_and_corresponding_header_to_target ( mega-cmd-server PRIVATE
2024-03-19 14:45:23 +01:00
" $ { P r o j e c t D i r } / s r c / m e g a c m d _ s e r v e r _ m a i n . c p p "
2024-08-27 16:59:18 +02:00
" $ { R E S O U R C E _ F I L E S _ M E G A C M D _ S E R V E R } "
2024-03-19 14:45:23 +01:00
)
2024-07-10 17:55:37 +02:00
if ( APPLE )
set_target_properties ( mega-cmd-server PROPERTIES OUTPUT_NAME "MEGAcmd" )
2024-07-11 12:53:56 +02:00
elseif ( WIN32 )
set_target_properties ( mega-cmd-server PROPERTIES OUTPUT_NAME "MEGAcmdServer" )
2024-07-10 17:55:37 +02:00
endif ( )
2024-03-19 14:45:23 +01:00
2024-03-20 12:56:06 +01:00
add_library ( LMegacmdClient STATIC )
add_source_and_corresponding_header_to_target ( LMegacmdClient PUBLIC
2024-03-19 14:45:23 +01:00
" $ { P r o j e c t D i r } / s r c / c l i e n t / m e g a c m d c l i e n t . c p p "
" $ { P r o j e c t D i r } / s r c / m e g a c m d s h e l l / m e g a c m d s h e l l c o m m u n i c a t i o n s n a m e d p i p e s . c p p "
" $ { P r o j e c t D i r } / s r c / m e g a c m d s h e l l / m e g a c m d s h e l l c o m m u n i c a t i o n s . c p p "
)
2024-07-10 13:44:14 +02:00
add_executable ( mega-exec ${ executablesType } )
2024-03-20 12:56:06 +01:00
add_source_and_corresponding_header_to_target ( mega-exec PRIVATE
2024-03-19 14:45:23 +01:00
" $ { P r o j e c t D i r } / s r c / c l i e n t / m e g a c m d _ c l i e n t _ m a i n . c p p "
2024-08-27 16:59:18 +02:00
" $ { R E S O U R C E _ F I L E S _ M E G A C M D _ C L I E N T } "
2024-03-19 14:45:23 +01:00
)
2024-07-10 13:44:14 +02:00
add_executable ( mega-cmd ${ executablesType } )
2024-03-20 12:56:06 +01:00
add_source_and_corresponding_header_to_target ( mega-cmd PRIVATE
2024-03-19 14:45:23 +01:00
" $ { P r o j e c t D i r } / s r c / m e g a c m d s h e l l / m e g a c m d s h e l l c o m m u n i c a t i o n s . c p p "
" $ { P r o j e c t D i r } / s r c / m e g a c m d s h e l l / m e g a c m d s h e l l c o m m u n i c a t i o n s n a m e d p i p e s . c p p "
" $ { P r o j e c t D i r } / s r c / m e g a c m d s h e l l / m e g a c m d s h e l l . c p p "
2024-08-27 16:59:18 +02:00
" $ { R E S O U R C E _ F I L E S _ M E G A C M D _ S H E L L } "
2024-03-19 14:45:23 +01:00
)
2024-07-11 16:56:21 +02:00
if ( WIN32 )
add_executable ( mega-cmd-updater WIN32 )
else ( )
add_executable ( mega-cmd-updater ${ executablesType } )
endif ( )
2024-03-20 12:56:06 +01:00
add_source_and_corresponding_header_to_target ( mega-cmd-updater PRIVATE
2024-03-19 14:45:23 +01:00
" $ { P r o j e c t D i r } / s r c / u p d a t e r / M e g a U p d a t e r . c p p "
2024-03-20 12:56:06 +01:00
)
add_source_and_corresponding_header_to_target ( mega-cmd-updater PRIVATE
2024-03-19 14:45:23 +01:00
" $ { P r o j e c t D i r } / s r c / u p d a t e r / U p d a t e T a s k . c p p "
2024-08-27 16:59:18 +02:00
" $ { R E S O U R C E _ F I L E S _ M E G A C M D _ U P D A T E R } "
2024-03-19 14:45:23 +01:00
)
2024-03-20 13:41:05 +01:00
target_sources_conditional ( mega-cmd-updater
F L A G APPLE
P R I V A T E
" $ { P r o j e c t D i r } / s r c / u p d a t e r / M a c U t i l s . h "
" $ { P r o j e c t D i r } / s r c / u p d a t e r / M a c U t i l s . m m "
)
2024-04-30 10:56:00 +02:00
if ( ENABLE_MEGACMD_TESTS )
#Test Common:
add_library ( LMegacmdTestsCommon STATIC )
add_source_and_corresponding_header_to_target ( LMegacmdTestsCommon PRIVATE
" $ { P r o j e c t D i r } / t e s t s / c o m m o n / I n s t r u m e n t s . c p p "
" $ { P r o j e c t D i r } / t e s t s / c o m m o n / T e s t U t i l s . c p p "
)
2024-03-19 14:45:23 +01:00
2024-04-30 10:56:00 +02:00
#Integration tests:
2024-12-12 14:22:03 +01:00
add_executable ( mega-cmd-tests-integration ${ executablesType } )
2024-04-30 10:56:00 +02:00
add_source_and_corresponding_header_to_target ( mega-cmd-tests-integration PRIVATE
" $ { P r o j e c t D i r } / t e s t s / i n t e g r a t i o n / B a s i c T e s t s . c p p "
2025-01-27 23:45:58 +01:00
" $ { P r o j e c t D i r } / t e s t s / i n t e g r a t i o n / C a t T e s t s . c p p "
2024-04-30 10:56:00 +02:00
" $ { P r o j e c t D i r } / t e s t s / i n t e g r a t i o n / E x p o r t T e s t s . c p p "
2024-09-02 17:48:42 +02:00
" $ { P r o j e c t D i r } / t e s t s / i n t e g r a t i o n / S y n c I s s u e s T e s t s . c p p "
2024-08-09 14:34:55 +02:00
" $ { P r o j e c t D i r } / t e s t s / i n t e g r a t i o n / S y n c I g n o r e T e s t s . c p p "
2025-01-09 14:32:11 +01:00
" $ { P r o j e c t D i r } / t e s t s / i n t e g r a t i o n / F u s e T e s t s . c p p "
2024-04-30 10:56:00 +02:00
" $ { P r o j e c t D i r } / t e s t s / i n t e g r a t i o n / M e g a C m d T e s t i n g T o o l s . c p p "
" $ { P r o j e c t D i r } / t e s t s / i n t e g r a t i o n / m a i n . c p p "
)
target_include_directories ( mega-cmd-tests-integration PUBLIC ${ ProjectDir } /src ${ ProjectDir } /tests/common )
target_link_libraries ( mega-cmd-tests-integration PUBLIC LMegacmdServer LMegacmdClient LMegacmdTestsCommon )
if ( APPLE )
target_link_libraries ( mega-cmd-tests-integration PRIVATE "-framework Security" )
endif ( )
2024-03-19 14:45:23 +01:00
2024-04-30 10:56:00 +02:00
#Unit tests:
2024-12-12 14:22:03 +01:00
add_executable ( mega-cmd-tests-unit ${ executablesType } )
2024-04-30 10:56:00 +02:00
add_source_and_corresponding_header_to_target ( mega-cmd-tests-unit PRIVATE
" $ { P r o j e c t D i r } / t e s t s / u n i t / S t r i n g U t i l s T e s t s . c p p "
" $ { P r o j e c t D i r } / t e s t s / u n i t / U t i l s T e s t s . c p p "
" $ { P r o j e c t D i r } / t e s t s / u n i t / P l a t f o r m D i r e c t o r i e s T e s t . c p p "
" $ { P r o j e c t D i r } / t e s t s / u n i t / m a i n . c p p "
)
2024-03-19 14:45:23 +01:00
2024-04-30 10:56:00 +02:00
if ( APPLE )
target_link_libraries ( mega-cmd-tests-unit PRIVATE "-framework Security" )
endif ( )
2024-03-19 14:45:23 +01:00
endif ( )
if ( WIN32 )
set_target_properties ( mega-exec PROPERTIES OUTPUT_NAME MEGAclient )
set_target_properties ( mega-cmd PROPERTIES OUTPUT_NAME MEGAcmdShell )
set_target_properties ( mega-cmd-updater PROPERTIES OUTPUT_NAME MEGAcmdUpdater )
set_target_properties ( mega-cmd-server PROPERTIES OUTPUT_NAME MEGAcmdServer )
set_target_properties ( mega-cmd-server PROPERTIES LINK_FLAGS "/LARGEADDRESSAWARE /DEBUG" )
#TODO: if this is still required, these paths will need adjusting
#set(3RDPARTY_RUNTIME_PATH_DEBUG "PATH=%PATH%" "${Mega3rdPartyDir}/vcpkg/installed/${VCPKG_TRIPLET}/debug/bin")
#set(3RDPARTY_RUNTIME_PATH_RELEASE "PATH=%PATH%" "${Mega3rdPartyDir}/vcpkg/installed/${VCPKG_TRIPLET}/bin")
#set_target_properties(mega-exec PROPERTIES VS_DEBUGGER_ENVIRONMENT "${3RDPARTY_RUNTIME_PATH_DEBUG}")
#set_target_properties(mega-cmd PROPERTIES VS_DEBUGGER_ENVIRONMENT "${3RDPARTY_RUNTIME_PATH_DEBUG}")
#set_target_properties(mega-cmd-updater PROPERTIES VS_DEBUGGER_ENVIRONMENT "${3RDPARTY_RUNTIME_PATH_DEBUG}")
#set_target_properties(mega-cmd-server PROPERTIES VS_DEBUGGER_ENVIRONMENT "${3RDPARTY_RUNTIME_PATH_DEBUG}")
endif ( )
2024-05-15 13:26:34 +02:00
target_link_libraries ( LMegacmdClient PUBLIC MEGA::SDKlib LMEGAcmdCommonUtils )
2024-03-19 14:45:23 +01:00
target_link_libraries ( mega-exec LMegacmdClient )
2024-05-15 13:26:34 +02:00
target_link_libraries ( mega-cmd PUBLIC MEGA::SDKlib LMEGAcmdCommonUtils )
target_link_libraries ( mega-cmd-updater PUBLIC MEGA::SDKlib LMEGAcmdCommonUtils )
target_link_libraries ( LMegacmdServer PUBLIC MEGA::SDKlib LMEGAcmdCommonUtils )
2024-03-19 14:45:23 +01:00
2024-03-26 19:19:54 +01:00
if ( ENABLE_MEGACMD_TESTS )
target_link_libraries ( LMegacmdServer PUBLIC LMegacmdTestsCommon )
endif ( )
2024-03-19 14:45:23 +01:00
if ( WIN32 )
target_link_libraries ( LMegacmdServer PUBLIC Lz32.lib Taskschd.lib )
target_link_libraries ( mega-cmd-updater PUBLIC Lz32.lib Urlmon.lib )
endif ( )
target_link_libraries ( mega-cmd-server PUBLIC LMegacmdServer )
2024-04-30 10:56:00 +02:00
if ( ENABLE_MEGACMD_TESTS )
2024-10-17 14:56:21 +02:00
target_include_directories ( LMegacmdTestsCommon PUBLIC ${ ProjectDir } /src ${ ProjectDir } /tests/common )
2024-04-30 10:56:00 +02:00
target_link_libraries ( mega-cmd-tests-unit PUBLIC LMegacmdServer LMegacmdTestsCommon )
endif ( )
2024-03-19 14:45:23 +01:00
2024-03-19 18:44:09 +01:00
# Load 3rd parties #TODO: consider splitting by target?
load_megacmdserver_libraries ( )
2024-03-26 11:37:52 +01:00
#file(GET_RUNTIME_DEPENDENCIES ... _deps)
#foreach(_dep IN LISTS _deps)
# message( "es una dependencia")
## if("${_dep}" SAME_FILE "/some/file/built/by/cmake.so") # if(SAME_FILE) doesn't currently exist, we'd have to create it
## # Target install rules for this CMake-built target
# #else()
## # Standard install rules for external runtime dependencies
## endif()
#endforeach()
2024-04-30 10:56:00 +02:00
list ( APPEND all_targets mega-exec mega-cmd mega-cmd-server )
2024-07-10 16:34:47 +02:00
if ( APPLE )
list ( APPEND all_targets mega-cmd-updater )
endif ( )
2024-04-30 10:56:00 +02:00
if ( ENABLE_MEGACMD_TESTS )
list ( APPEND all_targets mega-cmd-tests-unit mega-cmd-tests-integration )
endif ( )
2024-03-25 19:25:28 +01:00
# Install stuff
2024-07-10 16:34:47 +02:00
if ( APPLE )
install ( TARGETS ${ all_targets }
B U N D L E
2024-07-10 17:55:37 +02:00
D E S T I N A T I O N " . / "
2024-07-10 16:34:47 +02:00
)
elseif ( NOT WIN32 )
2024-07-04 11:23:24 +02:00
set ( PERMISSIONS755
O W N E R _ R E A D
O W N E R _ W R I T E
O W N E R _ E X E C U T E
G R O U P _ R E A D
G R O U P _ E X E C U T E
W O R L D _ R E A D
W O R L D _ E X E C U T E
)
set ( CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS ${ PERMISSIONS755 } )
2024-04-30 10:56:00 +02:00
install ( TARGETS ${ all_targets }
2024-03-26 17:53:48 +01:00
R U N T I M E
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ B I N D I R }
)
2024-06-10 18:38:10 +02:00
2024-07-04 08:35:17 +02:00
install ( DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/src/client/"
2024-06-10 18:38:10 +02:00
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ B I N D I R }
2024-07-04 11:23:24 +02:00
F I L E _ P E R M I S S I O N S $ { P E R M I S S I O N S 7 5 5 }
2024-06-10 18:38:10 +02:00
F I L E S _ M A T C H I N G
P A T T E R N " m e g a - * "
P A T T E R N " * . c p p " E X C L U D E
P A T T E R N " * . h " E X C L U D E
P A T T E R N " m e g a - e x e c " E X C L U D E
P A T T E R N " m e g a c m d _ c o m p l e t i o n . s h " E X C L U D E
P A T T E R N " p y t h o n " E X C L U D E
P A T T E R N " w i n " E X C L U D E )
install ( FILES "${CMAKE_CURRENT_LIST_DIR}/src/client/megacmd_completion.sh"
D E S T I N A T I O N " e t c / b a s h _ c o m p l e t i o n . d "
)
# generate 100-megacmd-inotify-limit.conf file and have it installed
execute_process ( COMMAND echo "fs.inotify.max_user_watches = 524288"
O U T P U T _ F I L E $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / 9 9 - m e g a c m d - i n o t i f y - l i m i t . c o n f )
install ( FILES ${ CMAKE_CURRENT_BINARY_DIR } /99-megacmd-inotify-limit.conf
D E S T I N A T I O N " e t c / s y s c t l . d "
)
2024-05-08 14:52:45 +02:00
#Install vcpkg dynamic libraries in locations defined by GNUInstallDirs.
2024-03-26 11:37:52 +01:00
if ( CMAKE_BUILD_TYPE STREQUAL "Debug" )
SET ( vcpkg_lib_folder "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/lib/" )
else ( )
SET ( vcpkg_lib_folder "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/" )
endif ( )
install ( DIRECTORY "${vcpkg_lib_folder}"
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ L I B D I R }
F I L E S _ M A T C H I N G
P A T T E R N " l i b * . s o * "
2024-03-26 12:51:09 +01:00
P A T T E R N " * d y l i b * " #macOS
2024-03-26 11:37:52 +01:00
P A T T E R N " m a n u a l - l i n k " E X C L U D E
P A T T E R N " p k g c o n f i g " E X C L U D E )
endif ( ) #not WIN32