Files
MyChat_Client/CMakeLists.txt
2025-05-29 21:31:28 +08:00

66 lines
1.4 KiB
CMake
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

cmake_minimum_required(VERSION 3.16)
project(ClientChat VERSION 0.1 LANGUAGES CXX)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# 查找Qt版本
find_package(Qt6 COMPONENTS Widgets QUIET)
if(NOT Qt6_FOUND)
find_package(Qt5 COMPONENTS Widgets REQUIRED)
set(QT_VERSION_MAJOR 5)
else()
set(QT_VERSION_MAJOR 6)
endif()
set(PROJECT_SOURCES
main.cpp
mainwidget.cpp
mainwidget.h
mainwidget.ui
model/data.h
resource.qrc
sessionfriendarea.h
sessionfriendarea.cpp
debug.h
messageshowarea.h
messageshowarea.cpp
messageeditarea.h
messageeditarea.cpp
SelfInfoWidget.h
SelfInfoWidget.cpp
)
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(ClientChat
MANUAL_FINALIZATION
${PROJECT_SOURCES}
)
else()
if(ANDROID)
add_library(ClientChat SHARED ${PROJECT_SOURCES})
else()
add_executable(ClientChat ${PROJECT_SOURCES})
endif()
endif()
target_link_libraries(ClientChat PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
# Bundle设置
include(GNUInstallDirs)
install(TARGETS ClientChat
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
if(QT_VERSION_MAJOR EQUAL 6)
qt_finalize_executable(ClientChat)
endif()