AntiClipSettings/CMakeLists.txt
luocai ef7aa73c8d
All checks were successful
Release tag / build (push) Successful in 3m5s
修复早期T009版本不回复不支持的命令,导致上位机不发送后续命令的问题。
2024-12-03 17:56:24 +08:00

161 lines
5.0 KiB
CMake

cmake_minimum_required(VERSION 3.16)
project(AntiClipSettings VERSION 1.6 LANGUAGES C CXX)
set(APPLICATION_NAME "视觉防夹设备上位机工具")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(Libraries_ROOT E:/Projects/Libraries CACHE STRING "Libraries directory.")
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Qml Quick Network QuickControls2)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Qml Quick Network QuickControls2)
if (Qt6_FOUND)
qt_standard_project_setup(REQUIRES 6.5)
set(BOOST_ROOT ${Libraries_ROOT}/boost_1_86_0_msvc2022_64bit)
set(Boost_INCLUDE_DIR ${BOOST_ROOT}/include/boost-1_86)
add_compile_definitions(
BOOST_USE_WINAPI_VERSION=BOOST_WINAPI_VERSION_WIN10
)
set(FFmpeg_ROOT ${Libraries_ROOT}/ffmpeg-7.0.2-full_build-shared)
else()
add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(BOOST_ROOT ${Libraries_ROOT}/boost_1_83_0_msvc2022_64bit)
set(Boost_INCLUDE_DIR ${BOOST_ROOT}/include/boost-1_83)
set(FFmpeg_ROOT ${Libraries_ROOT}/ffmpeg-6.1.1-full_build-shared)
endif()
option(Boost_USE_STATIC_LIBS OFF)
set(OpenSSL_ROOT D:/Qt/Tools/OpenSSLv3/Win_x64)
set(OPENSSL_INCLUDE_DIR ${OpenSSL_ROOT}/include)
set(OpenSSL_LIBRARY_DIRS ${OpenSSL_ROOT}/lib)
set(OpenSSL_LIBRARIES libssl libcrypto)
set(FFmpeg_INCLUDE_DIR ${FFmpeg_ROOT}/include)
set(FFmpeg_LIB_DIR ${FFmpeg_ROOT}/lib)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(JPEGTURBO_ROOT ${Libraries_ROOT}/libjpeg-turbo-3.0.3_msvc2022_64bit_debug)
set(MBEDTLS_ROOT ${Libraries_ROOT}/mbedtls-3.6.2_msvc2022_64bit_debug)
else()
set(JPEGTURBO_ROOT ${Libraries_ROOT}/libjpeg-turbo-3.0.3_msvc2022_64bit_release)
set(MBEDTLS_ROOT ${Libraries_ROOT}/mbedtls-3.6.2_msvc2022_64bit_release)
endif()
set(MbedTLS_DIR ${MBEDTLS_ROOT}/lib/cmake/MbedTLS)
set(JPEGTURBO_INCLUDE_DIR ${JPEGTURBO_ROOT}/include)
set(JPEGTURBO_LIB_DIR ${JPEGTURBO_ROOT}/lib)
find_package(Boost REQUIRED COMPONENTS json)
execute_process(
COMMAND D:/msys64/usr/bin/git rev-parse --short HEAD
OUTPUT_VARIABLE GIT_COMMIT_ID
OUTPUT_STRIP_TRAILING_WHITESPACE
)
configure_file(Configuration.h.in Configuration.h)
add_executable(AntiClipSettings
AntiClipSettings.rc AntiClipSettings.qrc
main.cpp
Application.h Application.cpp
DataStructure.h
DataCollection.h DataCollection.cpp
DeviceConnection.h DeviceConnection.cpp
DeviceListModel.h DeviceListModel.cpp
H264Palyer.h H264Palyer.cpp
VideoFrameProvider.h VideoFrameProvider.cpp
Settings.h Settings.cpp
)
if (Qt6_FOUND)
qt_add_qml_module(AntiClipSettings
URI AntiClipSettings
VERSION 1.0
QML_FILES
qml/Main.qml
qml/DeviceView.qml
qml/IconButton.qml
qml/MessageDialog.qml
qml/NetworkSettingPopup.qml
qml/OtaPopup.qml
qml/StatusTip.qml
qml/IpTextField.qml
RESOURCES
resources/popup_close.svg
resources/prompt_delete.svg
resources/successfull.svg
resources/warning.svg
)
endif()
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
# If you are developing for iOS or macOS you should consider setting an
# explicit, fixed bundle identifier manually though.
set_target_properties(AntiClipSettings PROPERTIES
# MACOSX_BUNDLE_GUI_IDENTIFIER com.example.AntiClipSettings
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
)
include(CPack)
include(FetchContent)
FetchContent_Declare(Kylin
GIT_REPOSITORY https://amass.fun/gitea/amass/Kylin.git
)
set(KYLIN_WITH_FLUENT OFF)
FetchContent_MakeAvailable(Kylin)
target_include_directories(AntiClipSettings
PRIVATE ${FFmpeg_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
PRIVATE ${JPEGTURBO_INCLUDE_DIR}
)
target_link_directories(AntiClipSettings
PRIVATE ${FFmpeg_LIB_DIR}
PRIVATE ${JPEGTURBO_LIB_DIR}
)
target_link_libraries(AntiClipSettings
PRIVATE Qt${QT_VERSION_MAJOR}::Qml
PRIVATE Qt${QT_VERSION_MAJOR}::Quick
PRIVATE Qt${QT_VERSION_MAJOR}::QuickControls2
PRIVATE Qt${QT_VERSION_MAJOR}::Network
PRIVATE Boost::json
PRIVATE avcodec
PRIVATE swscale
PRIVATE avutil
PRIVATE avdevice
PRIVATE avformat
PRIVATE Universal
PRIVATE Encrypt
PRIVATE turbojpeg-static
PRIVATE Ws2_32
)
include(GNUInstallDirs)
install(TARGETS AntiClipSettings
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
if (Qt6_FOUND)
qt_generate_deploy_qml_app_script(
TARGET AntiClipSettings
OUTPUT_SCRIPT deploy_script
MACOS_BUNDLE_POST_BUILD
NO_UNSUPPORTED_PLATFORM_ERROR
DEPLOY_USER_QML_MODULES_ON_UNSUPPORTED_PLATFORM
)
install(SCRIPT ${deploy_script})
endif()