Error in CMake path

2019-05-17 16:53发布

I'm trying to build the Visual Studio project for a kinect demo thing, rgbddemo. According to the instructions on the page, I need to set the PATH variable to include QMAKE from QT. I did that, but I keep getting this error:

CMake Error at CMakeLists.txt:1 (QT4_WRAP_CPP): Unknown CMake command "QT4_WRAP_CPP".

From what I could gather from google, it's a problem with CMake knowing where something from QT is. The page I linked above also mentions that you can set the path for QMAKE within CMake, but I don't know how to do that. Does anyone have any suggestions? Thanks.

标签: cmake
2条回答
放我归山
2楼-- · 2019-05-17 17:19

I think this lines in your CMakeLists.txt file can help you.

find_package(Qt4 Required)
include(${QT_USE_FILE}) #contains path to Qt header

#...

qt4_wrap_cpp(MOC_SOURCES ${MY_HEADERS}) #invoking moc 
add_library(MY_LIB ${SOURCES} ${MOC_SOURCES}) #building lib
target_link_libraries(MY_LIB ${QT_LIBRARIES})

qt4_add_resources(MY_QT_RSC ${RESOURCES}) #if you want to compile from resource files
add_library(MY_LIB_2 ${MY_QT_RSC} {SOURCES})
查看更多
手持菜刀,她持情操
3楼-- · 2019-05-17 17:38

You could try inserting the line

FIND_PACKAGE(Qt4)

into the top-level CMakeLists.txt file after the line

INCLUDE("${nestk_BINARY_DIR}/UseNestk.cmake")

That should cause it to try to find qmake for you. I'm not sure why they don't have that though, but then I'm not that familiar with cmake.

查看更多
登录 后发表回答