源码路径下包括:main.cpp、test.cpp、test.h、test.ui、test.qrc
cmake_minimum_required (VERSION 3.1.0)
project( test )
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
# 关闭控制台 :+ WIN32
set(QT_USE_QTMAIN TRUE)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON) #打开全局rcc,没有使用qrc
set(CMAKE_AUTOUIC ON)
set( QT5_ROOT_PATH CACHE PATH "Qt5 root directory (i.e. where the 'bin' folder lies)" )
if ( QT5_ROOT_PATH )
list( APPEND CMAKE_PREFIX_PATH ${QT5_ROOT_PATH} )
endif()
find_package( Qt5
COMPONENTS
Concurrent
Core
Gui
OpenGL
OpenGLExtensions
PrintSupport
Svg
Widgets
REQUIRED
)
file( GLOB header_list *.h )
file( GLOB source_list *.cpp )
file( GLOB ui_list *.ui )
file( GLOB qrc_list *.qrc )
qt5_wrap_ui( generated_ui_list ${ui_list} )
qt5_add_resources( generated_qrc_list ${qrc_list} )
add_executable( ${PROJECT_NAME} WIN32 ${header_list} ${source_list} ${generated_ui_list} ${generated_qrc_list} ${rc_list} ${txt_list} )
target_link_libraries(${PROJECT_NAME} Qt5::Widgets Qt5::Core Qt5::Gui)
if( CCCORELIB_USE_QT_CONCURRENT )
# We want *deployqt to handle this dependency, so instead of just copying the file
# link to the target.
target_link_libraries( ${PROJECT_NAME}
Qt5::Concurrent
)
endif()