### Define Installation Directory for CMake Modules Source: https://github.com/eclipse-ecal/fineftp-server/blob/master/fineftp-server/CMakeLists.txt Sets the installation path for CMake configuration files related to the FineFTP server. This allows other projects to find and use the installed FineFTP server components via CMake. ```cmake set(FINEFTP_INSTALL_CMAKE_DIR "lib/cmake/fineftp") ``` -------------------------------- ### Install Public Header Files Source: https://github.com/eclipse-ecal/fineftp-server/blob/master/fineftp-server/CMakeLists.txt Installs the public header files for the FineFTP server into the include directory. This is part of the development package. ```cmake install( DIRECTORY "include/fineftp" DESTINATION "include" COMPONENT fineftp_server_dev FILES_MATCHING PATTERN "*.h" ) ``` -------------------------------- ### Create and Start FineFTP Server Source: https://github.com/eclipse-ecal/fineftp-server/blob/master/README.md This C++ code demonstrates how to initialize an FtpServer, add an anonymous user with specified permissions and path, and start the server with a thread pool. It's designed for applications needing a simple FTP server without root privileges. ```cpp #include #include int main() { // Create an FTP Server on port 2121. We use 2121 instead of the default port // 21, as your application would need root privileges to open port 21. fineftp::FtpServer ftp_server(2121); // Add the well known anonymous user. Clients can log in using username // "anonymous" or "ftp" with any password. The user will be able to access // your C:\ drive and upload, download, create or delete files. On Linux just // replace "C:\\" with any valid path. FineFTP is designed to be cross-platform. ftp_server.addUserAnonymous("C:\\", fineftp::Permission::All); // Start the FTP Server with a thread-pool size of 4. ftp_server.start(4); // Prevent the application from exiting immediately for (;;) std::this_thread::sleep_for(std::chrono::milliseconds(100)); return 0; } ``` -------------------------------- ### Install FineFTP Server Runtime and Libraries Source: https://github.com/eclipse-ecal/fineftp-server/blob/master/fineftp-server/CMakeLists.txt Installs the FineFTP server executable, libraries, and archives to their respective destinations. It also assigns components for runtime and development packages. ```cmake install( TARGETS ${PROJECT_NAME} EXPORT fineftpTargets RUNTIME DESTINATION "bin" COMPONENT fineftp_server_runtime LIBRARY DESTINATION "lib" COMPONENT fineftp_server_runtime ARCHIVE DESTINATION "lib" COMPONENT fineftp_server_dev ) ``` -------------------------------- ### Configure and Install Package Config File Source: https://github.com/eclipse-ecal/fineftp-server/blob/master/fineftp-server/CMakeLists.txt Configures and installs the Config.cmake and ConfigVersion.cmake files for the FineFTP package. This enables package management and versioning for the development package. ```cmake include(CMakePackageConfigHelpers) configure_package_config_file( "../cmake/fineftpConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_/fineftpConfig.cmake" INSTALL_DESTINATION ${FINEFTP_INSTALL_CMAKE_DIR} PATH_VARS FINEFTP_INSTALL_CMAKE_DIR ) write_basic_package_version_file( "${CMAKE_CURRENT_BINARY_DIR}/cmake_/fineftpConfigVersion.cmake" VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion ) install( FILES "${CMAKE_CURRENT_BINARY_DIR}/cmake_/fineftpConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/cmake_/fineftpConfigVersion.cmake" DESTINATION ${FINEFTP_INSTALL_CMAKE_DIR} COMPONENT fineftp_server_dev ) ``` -------------------------------- ### Install Export CMake Targets Source: https://github.com/eclipse-ecal/fineftp-server/blob/master/fineftp-server/CMakeLists.txt Installs the CMake export file for fineftpTargets, which allows other projects to find and use FineFTP. This is part of the development package. ```cmake install( EXPORT fineftpTargets FILE fineftpTargets.cmake DESTINATION ${FINEFTP_INSTALL_CMAKE_DIR} NAMESPACE fineftp:: COMPONENT fineftp_server_dev ) ``` -------------------------------- ### Set CMAKE_PREFIX_PATH for Binary Integration Source: https://github.com/eclipse-ecal/fineftp-server/blob/master/README.md When integrating FineFTP Server as pre-compiled binaries, add the installation directory to your CMAKE_PREFIX_PATH to allow CMake to find the installed components. ```shell cmake your_command_line -DCMAKE_PREFIX_PATH=path/to/fineftp/install/dir ``` -------------------------------- ### Install Auto-generated Header Files Source: https://github.com/eclipse-ecal/fineftp-server/blob/master/fineftp-server/CMakeLists.txt Installs the auto-generated header files, including export macros, into the include directory. This is also part of the development package. ```cmake install( DIRECTORY "${PROJECT_BINARY_DIR}/include/fineftp" DESTINATION "include" COMPONENT fineftp_server_dev FILES_MATCHING PATTERN "*.h" ) ``` -------------------------------- ### FineFTP Server CMakeLists Configuration Source: https://github.com/eclipse-ecal/fineftp-server/blob/master/samples/fineftp_example/CMakeLists.txt Configures a C++ executable to link against the FineFTP server library. Ensure FineFTP is installed and findable by CMake. ```cmake cmake_minimum_required(VERSION 3.13...4.0) project(fineftp_example) set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE) find_package(fineftp REQUIRED) set(sources src/main.cpp ) add_executable (${PROJECT_NAME} ${sources} ) target_link_libraries (${PROJECT_NAME} fineftp::server ) target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_14 ) ``` -------------------------------- ### CMake Project Configuration Source: https://github.com/eclipse-ecal/fineftp-server/blob/master/README.md This command configures the FineFTP project using CMake, specifying the build type as Debug and the installation prefix. This step is necessary before compiling the project. ```console mkdir _build cd _build cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=_install ``` -------------------------------- ### Define Public and Private Include Directories Source: https://github.com/eclipse-ecal/fineftp-server/blob/master/fineftp-server/CMakeLists.txt Configures include directories for the project. It specifies public include paths for build and installation interfaces, and private include paths for internal source files and platform-specific headers. ```cmake target_include_directories(${PROJECT_NAME} PUBLIC $ $ # To find the export file generated by generate_export_header $ PRIVATE src/ ${platform_include} ) ``` -------------------------------- ### Add FineFTP Server Source Directory (Minimal Integration) Source: https://github.com/eclipse-ecal/fineftp-server/blob/master/README.md Include only the server subdirectory for a cleaner integration, requiring you to manage dependencies like Asio separately. ```cmake add_subdirectory(path/to/fineftp-server/server) ``` -------------------------------- ### Checkout and Update Submodules Source: https://github.com/eclipse-ecal/fineftp-server/blob/master/README.md These console commands are used to clone the FineFTP repository and initialize/update its submodules, which is a prerequisite for building the project. ```console git clone https://github.com/eclipse-ecal/fineftp-server.git cd fineftp-server git submodule init git submodule update ``` -------------------------------- ### Add FineFTP Server Source Directory (Full Integration) Source: https://github.com/eclipse-ecal/fineftp-server/blob/master/README.md Include the top-level CMakeLists.txt of FineFTP Server into your project to inherit its build configurations and options. ```cmake add_subdirectory(path/to/fineftp-server) ``` -------------------------------- ### CMakeLists.txt for FineFTP Integration Test Source: https://github.com/eclipse-ecal/fineftp-server/blob/master/samples/integration_test/CMakeLists.txt Configures the build environment for the FineFTP server integration test. It sets the C++ standard, finds the FineFTP package, and links the executable against the FineFTP server library. ```cmake cmake_minimum_required(VERSION 3.5.1...4.0) project(integration_test) set(CMAKE_CXX_STANDARD 14) set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE) find_package(fineftp REQUIRED) set(sources src/main.cpp ) add_executable (${PROJECT_NAME} ${sources} ) target_link_libraries (${PROJECT_NAME} fineftp::server ) ``` -------------------------------- ### Link Against FineFTP Server Library Source: https://github.com/eclipse-ecal/fineftp-server/blob/master/README.md After finding the FineFTP package, link your target executable or library against the FineFTP server library using target_link_libraries. ```cmake find_package(fineftp REQUIRED) target_link_libraries(your_target PRIVATE fineftp::server) ``` -------------------------------- ### Set Target Properties Source: https://github.com/eclipse-ecal/fineftp-server/blob/master/fineftp-server/CMakeLists.txt Sets versioning and output naming properties for the FineFTP server target. This includes the main version, shared object version, and a custom output name. ```cmake set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR} OUTPUT_NAME fineftp-${PROJECT_NAME} ) ``` -------------------------------- ### Group Source Files by Directory Tree Source: https://github.com/eclipse-ecal/fineftp-server/blob/master/fineftp-server/CMakeLists.txt Organizes source files within the build system based on their directory structure in the source tree. This aids in managing and visualizing the project's file organization. ```cmake source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" FILES ${includes} ${sources} ) ``` -------------------------------- ### Configure Delay for 226 Response Source: https://github.com/eclipse-ecal/fineftp-server/blob/master/fineftp-server/CMakeLists.txt Sets a cache variable to configure an optional delay in milliseconds for the 226 response code when a file is fetched. This is used to improve compatibility with FTP clients that prematurely close data connections. The delay is applied as a compile definition. ```cmake set(FINEFTP_SERVER_DELAY_226_RESP_MS 0 CACHE STRING "An optional delay (in ms) for the 226 response when a file has been fetched. Used to improve interoperability with buggy clients.") target_compile_definitions(${PROJECT_NAME} PRIVATE DELAY_226_RESP_MS=${FINEFTP_SERVER_DELAY_226_RESP_MS}) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.