代码拉取完成,页面将自动刷新
同步操作将从 cauchy37/UFX 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
# UFX API导入项目
cmake_minimum_required(VERSION 3.14.5 FATAL_ERROR)
project(UFXTradeAPI LANGUAGES CXX VERSION 0.0.1)
# 为安装和打包功能设置一些选项,默认只安装动态库文件和可执行文件,不安装静态库文件、头文件或导出库文件,也不打包。
option(${PROJECT_NAME}_INSTALL "启用安装功能,默认只安装动态库文件和可执行文件" ON)
option(${PROJECT_NAME}_INSTALL_ALL "安装所有的头文件、库文件、导出库文件和可执行文件" OFF)
option(${PROJECT_NAME}_ENABLE_CPACK "启用打包功能,对项目最终安装的文件目录打包以便分发、发布" OFF)
set(${PROJECT_NAME}_COPY_TO_PATH "" CACHE PATH "将附加的动态依赖库复制到指定目录,比如Windows下可以复制到输出目录以方便调试。")
# 在这里进行平台的检查控制,并设置各种库的目标和变量等。
option(UFX_PRODUCTION "是否使用生产版本的看穿式API" ON)
message("-- UFX_PRODUCTION = ${UFX_PRODUCTION}")
if(UFX_PRODUCTION)
set(system_info_path ${CMAKE_CURRENT_SOURCE_DIR}/hs_futu_system_info/hs_futu_system_info_production)
else()
set(system_info_path ${CMAKE_CURRENT_SOURCE_DIR}/hs_futu_system_info/hs_futu_system_info_simulation)
endif()
list(APPEND import_targets_name t2sdk t2sdk_system_info)
set(include_directory_t2sdk ${CMAKE_CURRENT_SOURCE_DIR}/include)
set(include_directory_t2sdk_system_info ${system_info_path}/include)
set(header_files_t2sdk
${include_directory_t2sdk}/t2sdk_interface.h
${include_directory_t2sdk_system_info}/HsFutuSystemInfo.h)
if(UNIX)
set(t2sdk_root ${CMAKE_CURRENT_SOURCE_DIR}/linux.x64/lib)
set(t2sdk_system_info_root ${system_info_path}/linux.x64/lib)
set(import_location_t2sdk ${t2sdk_root}/libt2sdk.so)
set(import_location_t2sdk_system_info ${t2sdk_system_info_root}/libHsFutuSystemInfo.so)
elseif(WIN32)
if(CMAKE_CXX_COMPILER_ARCHITECTURE_ID STREQUAL "X86")
set(t2sdk_root ${CMAKE_CURRENT_SOURCE_DIR}/win32/lib)
set(t2sdk_system_info_root ${system_info_path}/win32/lib)
elseif(CMAKE_CXX_COMPILER_ARCHITECTURE_ID STREQUAL "x64")
set(t2sdk_root ${CMAKE_CURRENT_SOURCE_DIR}/win64/lib)
set(t2sdk_system_info_root ${system_info_path}/win64/lib)
else()
message(FATAL_ERROR "Arch=${CMAKE_CXX_COMPILER_ARCHITECTURE_ID} on ${CMAKE_SYSTEM_NAME} NOT supported.")
endif()
set(import_location_t2sdk ${t2sdk_root}/t2sdk.dll)
set(implib_location_t2sdk ${t2sdk_root}/t2sdk.lib)
set(import_location_t2sdk_system_info ${t2sdk_system_info_root}/HsFutuSystemInfo.dll)
set(import_location_t2sdk_system_info ${t2sdk_system_info_root}/HsFutuSystemInfo.lib)
else()
message(FATAL_ERROR "Arch=${CMAKE_CXX_COMPILER_ARCHITECTURE_ID} on ${CMAKE_SYSTEM_NAME} NOT supported.")
endif()
# 在这里把必要的依赖项给添加上
find_package(Threads REQUIRED)
# 将API头文件和库文件添加成IMPORTED库目标,以供其他CMake项目引用。
foreach(target_name ${import_targets_name})
add_library(${PROJECT_NAME}::${target_name} INTERFACE IMPORTED GLOBAL)
target_include_directories(${PROJECT_NAME}::${target_name}
INTERFACE $<BUILD_INTERFACE:${include_directory_${target_name}}>
INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
get_filename_component(_import_directory_${target_name} ${import_location_${target_name}} DIRECTORY)
# message(STATUS "_import_directory_${target_name} = ${_import_directory_${target_name}}")
if(implib_location_${target_name})
get_filename_component(_implib_directory_${target_name} ${implib_location_${target_name}} DIRECTORY)
# message(STATUS "_implib_directory_${target_name} = ${_implib_directory_${target_name}}")
endif()
target_link_directories(${PROJECT_NAME}::${target_name}
INTERFACE $<$<PLATFORM_ID:Linux>:${_import_directory_${target_name}}>
INTERFACE $<$<PLATFORM_ID:Windows>:${_implib_directory_${target_name}}>)
get_filename_component(_import_filename_${target_name} ${import_location_${target_name}} NAME)
# message(STATUS "_import_filename_${target_name} = ${_import_filename_${target_name}}")
if(implib_location_${target_name})
get_filename_component(_implib_filename_${target_name} ${implib_location_${target_name}} NAME)
# message(STATUS "_implib_filename_${target_name} = ${_implib_filename_${target_name}}")
endif()
target_link_libraries(${PROJECT_NAME}::${target_name}
INTERFACE $<$<PLATFORM_ID:Linux>::${_import_filename_${target_name}}> # 注意两个冒号,因为库文件不是标准unix命名方式
INTERFACE $<$<PLATFORM_ID:Windows>:${_implib_filename_${target_name}}>
INTERFACE Threads::Threads)
endforeach()
# 将动态库文件复制到指定目录
if(${PROJECT_NAME}_COPY_TO_PATH)
if(NOT EXISTS ${${PROJECT_NAME}_COPY_TO_PATH})
message(FATAL_ERROR "${PROJECT_NAME}_COPY_TO_PATH NOT EXISTS: ${${PROJECT_NAME}_COPY_TO_PATH}")
endif()
# message(STATUS "${PROJECT_NAME}_COPY_TO_PATH = ${${PROJECT_NAME}_COPY_TO_PATH}")
foreach(target_name ${import_targets_name})
# message(STATUS "import_location_${target_name} = ${import_location_${target_name}}")
file(COPY ${import_location_${target_name}} DESTINATION ${${PROJECT_NAME}_COPY_TO_PATH})
endforeach()
endif()
# 对于安装的文件名,Windows平台下动态库和导出库不要以lib开头,静态库要以lib开头;UNIX平台下动态库和静态库都要以lib开头。
# Windows下动态库安装在${CMAKE_INSTALL_BINDIR}下,其他库安装在${CMAKE_INSTALL_LIBDIR};Unix下库都安装在${CMAKE_INSTALL_LIBDIR}下。
# 可执行项目,可执行文件安装在${CMAKE_INSTALL_BINDIR}下,配置文件安装在${CMAKE_INSTALL_SYSCONFDIR}/${PROJECT_NAME}下;
# 库项目,可执行文件应当安装在${CMAKE_INSTALL_LIBEXECDIR}目录下,配置文件安装在${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}下。
# 特定用户的配置文件和数据文件不应当被安装,应当在程序运行时生成在$HOME/.${PROJECT_NAME}下,或者%USERPROFILE%/.${PROJECT_NAME}下。
if(${PROJECT_NAME}_INSTALL)
include(GNUInstallDirs)
if(WIN32)
set(runtime_install_dir ${CMAKE_INSTALL_BINDIR})
else()
set(runtime_install_dir ${CMAKE_INSTALL_LIBDIR})
endif()
foreach(target_name ${import_targets_name})
install(FILES ${import_location_${target_name}} DESTINATION ${runtime_install_dir})
if(${PROJECT_NAME}_INSTALL_ALL)
if(WIN32)
install(FILES ${implib_location_${target_name}} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
install(FILES ${header_files_${target_name}} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
endif()
endforeach()
if(${PROJECT_NAME}_ENABLE_CPACK)
include(CPack)
endif()
endif()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。