wsk3q

导航

我的CMakeLists.txt模板——QT5

# 我的CMakeLists.txt模板, 使用QT5.

# ################################################################
# Copyright (c) 2022 wsk3Q
#
# cmake with QT5
# history:
#  2022-11-22 created
#
# 使用:
# mkdir build
# cd build
# cmake -A Win32 -DCMAKE_INSTALL_PREFIX=d:\temp\XXX ..
# cmake -G "MSYS Makefiles" ..
# cmake --build . --config Release --target install
# ################################################################

cmake_minimum_required(VERSION 3.1)

set(PROJ_NAME "myproj")
project(${PROJ_NAME})

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)

find_package(Qt5Widgets REQUIRED)
find_package(Qt5Core REQUIRED)
find_package(Qt5Gui REQUIRED)
if (${Qt5_FOUND})
    message("Found Qt " ${Qt5_VERSION})
else()
    message("Couldn't find Qt")
endif()

set(PROJ_HDRS   resource.h)
set(PROJ_SRCS MyWidget.cpp main.cpp)
set(PROJ_UIS MyWidget.ui)

qt5_wrap_ui(PROJ_WRAPPED_UIS ${PROJ_UIS})

# windows console
#add_executable(${PROJ_NAME} ${PROJ_SRCS} ${PROJ_HDRS} ${PROJ_WRAPPED_UIS})

# windows GUI
add_executable(${PROJ_NAME} WIN32 ${PROJ_SRCS} ${PROJ_HDRS} ${PROJ_WRAPPED_UIS})

target_link_libraries(${PROJ_NAME}
                        Qt5::Core
                        Qt5::Gui
                        Qt5::Widgets
                      )


 

posted on 2023-09-08 22:40  wsk3q  阅读(64)  评论(0编辑  收藏  举报