cmake添加NO_MOC来应对直接粗暴include moc生成的源代码
parent
d29cee3d5a
commit
3fa6fe6b6a
|
@ -1,7 +1,7 @@
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
message("CMAKE VERSION " ${VERSION})
|
||||||
include_directories(third/lua/include)
|
include_directories(third/include)
|
||||||
link_directories(third/lua/lib)
|
link_directories(third/lib)
|
||||||
link_libraries(lua)
|
link_libraries(lua)
|
||||||
|
|
||||||
project(protoDebuger LANGUAGES CXX)
|
project(protoDebuger LANGUAGES CXX)
|
||||||
|
@ -17,16 +17,15 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
find_package(Qt5 COMPONENTS Core Quick Widgets REQUIRED)
|
find_package(Qt5 COMPONENTS Core Quick Widgets REQUIRED)
|
||||||
|
|
||||||
include(D:\\project\\c++qt\\qsswraper\\CMakeLists.txt)
|
|
||||||
|
|
||||||
set(HEADERS # 待预编译的cpp头文件
|
set(HEADERS # 待预编译的cpp头文件
|
||||||
dialog.h
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set(SOURCES # 待预编译的cpp代码
|
set(SOURCES # 待预编译的cpp代码
|
||||||
dialog.cpp
|
|
||||||
main.cpp
|
main.cpp
|
||||||
)
|
)
|
||||||
|
set(NO_MOC_SOURCES
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
set(RESOURCES
|
set(RESOURCES
|
||||||
qml.qrc
|
qml.qrc
|
||||||
|
@ -37,23 +36,35 @@ set(QMLS
|
||||||
)
|
)
|
||||||
|
|
||||||
set (UIS
|
set (UIS
|
||||||
"dialog.ui"
|
${QsswraperUI}
|
||||||
${QsswraperUI})
|
)
|
||||||
|
|
||||||
|
include(D:\\project\\qt\\qsswraper\\CMakeLists.txt)
|
||||||
|
include(D:\\project\\qt\\qsswraper\\extserial\\src\\qextserialport.cmake)
|
||||||
|
|
||||||
QT5_WRAP_CPP(MOC ${SOURCES} ) # moc预编译代码
|
QT5_WRAP_CPP(MOC ${SOURCES} ) # moc预编译代码
|
||||||
QT5_WRAP_CPP(MOCHEADER ${HEADERS} ) # moc预编译代码
|
QT5_WRAP_CPP(MOCHEADER ${HEADERS} ) # moc预编译代码
|
||||||
QT5_ADD_RESOURCES(RCC ${RESOURCES}) # rcc生成资源cpp
|
QT5_ADD_RESOURCES(RCC ${RESOURCES}) # rcc生成资源cpp
|
||||||
QT5_WRAP_UI(UIC ${UIS}) # uic生成ui_x.h
|
QT5_WRAP_UI(UIC ${UIS}) # uic生成ui_x.h
|
||||||
|
|
||||||
message("MOC " ${MOC} ${MOCHEADER})
|
FOREACH(list ${SOURCES})
|
||||||
message("UIC " ${UIC})
|
message("SOURCES file " ${list})
|
||||||
message("RCC " ${RCC})
|
ENDFOREACH(list)
|
||||||
|
|
||||||
|
FOREACH(list ${MOCHEADER})
|
||||||
|
message("MOCHEADER file" ${list})
|
||||||
|
ENDFOREACH(list)
|
||||||
|
|
||||||
|
FOREACH(list ${NO_MOC_SOURCES})
|
||||||
|
message("NO_MOC_SOURCES file" ${list})
|
||||||
|
ENDFOREACH(list)
|
||||||
|
|
||||||
add_executable(protoDebuger #最后需要参与链接生成的是
|
add_executable(protoDebuger #最后需要参与链接生成的是
|
||||||
${SOURCES} #1. 原先的cpp代码,
|
${SOURCES} #1. 原先的cpp代码,
|
||||||
${MOC} #2. 预编译后的cpp
|
${MOC} #2. 预编译后的cpp
|
||||||
${RCC} #3. 资源cpp代码
|
${RCC} #3. 资源cpp代码
|
||||||
${UIC}
|
${UIC}
|
||||||
|
${NO_MOC_SOURCES}
|
||||||
)
|
)
|
||||||
|
|
||||||
target_compile_definitions(protoDebuger
|
target_compile_definitions(protoDebuger
|
||||||
|
|
|
@ -17,8 +17,6 @@ int main(int argc, char *argv[])
|
||||||
QCoreApplication::exit(-1);
|
QCoreApplication::exit(-1);
|
||||||
}, Qt::QueuedConnection);
|
}, Qt::QueuedConnection);
|
||||||
engine.load(url);
|
engine.load(url);
|
||||||
Dialog a;
|
|
||||||
a.show();
|
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue