cmake_minimum_required(VERSION 3.5) project(protoDebuger LANGUAGES CXX) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOUIC FALSE) set(CMAKE_AUTOMOC FALSE) set(CMAKE_AUTORCC FALSE) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) include_directories(third/lua/include) link_directories(third/lua/lib) link_libraries(lua) find_package(Qt5 COMPONENTS Core Quick Widgets REQUIRED) #include(D:\\project\\c++qt\\qsswraper\\CMakeLists.txt) set(SOURCES # 待预编译的cpp代码 dialog.cpp main.cpp ) set(HEADERS # 待预编译的cpp头文件 dialog.h ) set(RESOURCES qml.qrc ) set(QMLS main.qml ) set (UIS "dialog.ui" ${QsswraperUI} ) QT5_WRAP_CPP(MOC ${SOURCES} ) # moc预编译代码 QT5_ADD_RESOURCES(RCC ${RESOURCES}) # rcc生成资源cpp QT5_WRAP_UI(UIC ${UIS}) # uic生成ui_x.h FOREACH(list ${MOCHEADER}) message("MOCHEADER file " ${list}) ENDFOREACH(list) FOREACH(list ${MOC}) message("MOC file " ${list}) ENDFOREACH(list) FOREACH(list ${SOURCES}) message("SOURCES file " ${list}) ENDFOREACH(list) FOREACH(list ${UIC}) message("UIC file " ${list}) ENDFOREACH(list) FOREACH(list ${RCC}) message("RCC file " ${list}) ENDFOREACH(list) add_executable(protoDebuger #最后需要参与链接生成的是 ${SOURCES} #1. 原先的cpp代码, ${MOC} #2. 预编译后的cpp ${RCC} #3. 资源cpp代码 ) target_compile_definitions(protoDebuger PRIVATE $<$,$>:QT_QML_DEBUG>) target_link_libraries(protoDebuger PRIVATE Qt5::Core Qt5::Quick Qt5::Widgets) # 指定引入的QT功能,和qmake .pro 文件中的QT+= XXX类似