如何简化此 cmake 文件?
How do I simplify this cmake file?
我有这个CMakeLists.txt。
从模式来看,似乎有更好、更清洁的方法来做到这一点。
QT5_WRAP_CPP(windowui_moc ../../include/QtDisplay/WindowUI.hpp)
QT5_WRAP_CPP(mainwindow_moc ../../include/QtDisplay/MainWindow.hpp)
QT5_WRAP_CPP(editor_moc ../../include/QtDisplay/SpiderEditor.hpp)
QT5_WRAP_CPP(output_moc ../../include/QtDisplay/OutputPane.hpp)
add_library(Display WindowUI.cpp MainWindow.cpp SpiderEditor.cpp OutputPane.cpp
${windowui_moc} ${mainwindow_moc} ${editor_moc} ${output_moc})
qt5_use_modules(Display Widgets Core)
我不太了解cmake中使用的约定,所以我无法查找'solution'叫什么。
您可以像这样使用 CMake 的 automoc 功能:
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_library(Display MainWindow.cpp SpiderEditor.cpp OutputPane.cpp)
qt5_use_modules(Display Widgets Core)
你在找这样的东西吗:
set (Display_src
${PROJECT_SOURCE_DIR}/WindowUI.cpp
${PROJECT_SOURCE_DIR}/MainWindow.cpp
${PROJECT_SOURCE_DIR}/SpiderEditor.cpp
${PROJECT_SOURCE_DIR}/OutputPane.cpp
)
set (Display_hdr
${PROJECT_SOURCE_DIR}/../../include/QtDisplay/WindowUI.hpp
${PROJECT_SOURCE_DIR}/../../include/QtDisplay/MainWindow.hpp
${PROJECT_SOURCE_DIR}/../../include/QtDisplay/SpiderEditor.hpp
${PROJECT_SOURCE_DIR}/../../include/QtDisplay/OutputPane.hpp
)
qt5_wrap_cpp (Display_hdr_moc ${Display_hdr})
add_library (Display
${Display_src}
${Display_hdr_moc}
)
# For Qt 5.2+
target_link_libraries (Display Qt5::Widgets)
# For Qt 5.1.
# qt5_use_modules(Display Widgets Core)
我有这个CMakeLists.txt。
从模式来看,似乎有更好、更清洁的方法来做到这一点。
QT5_WRAP_CPP(windowui_moc ../../include/QtDisplay/WindowUI.hpp)
QT5_WRAP_CPP(mainwindow_moc ../../include/QtDisplay/MainWindow.hpp)
QT5_WRAP_CPP(editor_moc ../../include/QtDisplay/SpiderEditor.hpp)
QT5_WRAP_CPP(output_moc ../../include/QtDisplay/OutputPane.hpp)
add_library(Display WindowUI.cpp MainWindow.cpp SpiderEditor.cpp OutputPane.cpp
${windowui_moc} ${mainwindow_moc} ${editor_moc} ${output_moc})
qt5_use_modules(Display Widgets Core)
我不太了解cmake中使用的约定,所以我无法查找'solution'叫什么。
您可以像这样使用 CMake 的 automoc 功能:
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_library(Display MainWindow.cpp SpiderEditor.cpp OutputPane.cpp)
qt5_use_modules(Display Widgets Core)
你在找这样的东西吗:
set (Display_src
${PROJECT_SOURCE_DIR}/WindowUI.cpp
${PROJECT_SOURCE_DIR}/MainWindow.cpp
${PROJECT_SOURCE_DIR}/SpiderEditor.cpp
${PROJECT_SOURCE_DIR}/OutputPane.cpp
)
set (Display_hdr
${PROJECT_SOURCE_DIR}/../../include/QtDisplay/WindowUI.hpp
${PROJECT_SOURCE_DIR}/../../include/QtDisplay/MainWindow.hpp
${PROJECT_SOURCE_DIR}/../../include/QtDisplay/SpiderEditor.hpp
${PROJECT_SOURCE_DIR}/../../include/QtDisplay/OutputPane.hpp
)
qt5_wrap_cpp (Display_hdr_moc ${Display_hdr})
add_library (Display
${Display_src}
${Display_hdr_moc}
)
# For Qt 5.2+
target_link_libraries (Display Qt5::Widgets)
# For Qt 5.1.
# qt5_use_modules(Display Widgets Core)