17

私の CMakeLists.txt は次のようになります。

cmake_minimum_required(VERSION 2.8)
if(CMAKE_BUILD_TYPE STREQUAL Release)
  SET(CMAKE_BUILD_TYPE Release)
  SET (PROJECT_NAME location_recognition)
  message("Release mode")
else()
  SET(CMAKE_BUILD_TYPE Debug)
  SET (PROJECT_NAME location_recognition)
  SET(CMAKE_CXX_FILES "-g -Wall")
  message("Debug mode")

endif()

#find QT libraries
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Core REQUIRED)
find_package(Qt5Gui REQUIRED)

FIND_PACKAGE(OpenCV REQUIRED)
FIND_PACKAGE(Boost REQUIRED)

# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)

# As moc files are generated in the binary dir, tell CMake
# to always look for includes there:
set(CMAKE_INCLUDE_CURRENT_DIR ON)
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} )
# We need add -DQT_WIDGETS_LIB when using QtWidgets in Qt 5.
add_definitions(${Qt5Widgets_DEFINITIONS})

SET(SRC
  src/voting_classifier.cpp
  src/voting_classifier_helper.cpp
  src/results_scene.cpp
  src/image_window_widget.cpp
  src/image_result_matrix.cpp
  src/location_recognition.cpp
  src/main.cpp
  )

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

FIND_PROGRAM(QT_UIC_EXECUTABLE uic
  $ENV{QTDIR}/bin
  )

IF (QT_UIC_EXECUTABLE)
  # SET ( QT_WRAP_UI "YES")
  message("WOW")
ENDIF (QT_UIC_EXECUTABLE)

QT5_WRAP_UI(image_result_matrix.h ui_forms/image_result_matrix.ui -o ui_forms/image_result_matrix.h)
QT5_WRAP_UI(image_window_widget.h ui_forms/image_window_widget.ui -o ui_forms/image_window_widget.h)
QT5_WRAP_UI(location_recognition.h ui_forms/location_recognition.ui -o ui_forms/location_recognition.h)
QT5_WRAP_UI(ui_results_view.h ui_forms/result_view.ui -o ui_forms/ui_results_view.h)

include_directories(${PROJECT_SOURCE_DIR}/include
  ${PROJECT_SOURCE_DIR}/ui_forms
  ${PROJECT_SOURCE_DIR}
  ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Core_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS}
  ${PROJECT_SOURCE_DIR}/../perception_kit/utilities/include
  ${PROJECT_SOURCE_DIR}/../perception_kit/visual_categorization/include
  ${OpenCV_INCLUDE_DIRS})

FIND_LIBRARY(utilities NAMES libperception_kitutilities.so PATHS "/other/workspace/perception/perception_kit/utilities/lib")
FIND_LIBRARY(utilitiesd NAMES libperception_kitutilitiesd.so PATHS "/other/workspace/perception/perception_kit/utilities/lib")

message("Utilites Libs :${utilities}")

FIND_LIBRARY(visual_categorization NAMES libperception_kitvisual_categorization.so PATHS "/other/workspace/perception/perception_kit/visual_categorization/lib")
FIND_LIBRARY(visual_categorizationd NAMES libperception_kitvisual_categorizationd.so PATHS "/other/workspace/perception/perception_kit/visual_categorization/lib")
message("Visual_categorization Libs :${visual_categorization}")

SET(LINK_LIBRARY optimized ${utilities} ${visual_categorization} debug ${utilities} ${visual_categorizationd})
# set_target_properties(${PROJECT_NAME} PROPERTIES SOVERSION ${perception_kit_VERSION} )
add_executable(location_recognition ${SRC})
target_link_libraries(${PROJECT_NAME} ${LINK_LIBRARY}
  ${OpenCV_LIBS} ${Boost_LIBS})

qt5_use_modules(location_recognition Core Gui Widgets)

私がする時

cmake .

それはうまくいきます。しかし、試しmakeてみると、まだ ui_forms/*.h ヘッダーが見つからず、失敗するというメッセージが表示されます。

/other/workspace/perception/location_recognition/src/results_scene.cpp:4:0 からインクルードされたファイル: /other/workspace/perception/location_recognition/include/perception_kit/location_recognition/results_scene.h:6:29: 致命的なエラー: ui_results_view .h: そのようなファイルまたはディレクトリのコンパイルは終了しませんでした。make[2]: * [CMakeFiles/location_recognition.dir/src/results_scene.cpp.o] エラー 1 make[1]: * [CMakeFiles/location_recognition.dir/all] エラー 2 make: * [all] エラー 2

「make VERBOSE=1」を実行すると、

/usr/local/bin/cmake -H/other/workspace/perception/location_recognition -B/other/workspace/perception/location_recognition --check-build-system CMakeFiles/Makefile.cmake 0
/usr/local/bin/cmake -E cmake_progress_start /other/workspace/perception/location_recognition/CMakeFiles /other/workspace/perception/location_recognition/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/other/workspace/perception/location_recognition'
make -f CMakeFiles/location_recognition_automoc.dir/build.make CMakeFiles/location_recognition_automoc.dir/depend
make[2]: Entering directory `/other/workspace/perception/location_recognition'
cd /other/workspace/perception/location_recognition && /usr/local/bin/cmake -E cmake_depends "Unix Makefiles" /other/workspace/perception/location_recognition /other/workspace/perception/location_recognition /other/workspace/perception/location_recognition /other/workspace/perception/location_recognition /other/workspace/perception/location_recognition/CMakeFiles/location_recognition_automoc.dir/DependInfo.cmake --color=
make[2]: Leaving directory `/other/workspace/perception/location_recognition'
make -f CMakeFiles/location_recognition_automoc.dir/build.make CMakeFiles/location_recognition_automoc.dir/build
make[2]: Entering directory `/other/workspace/perception/location_recognition'
/usr/local/bin/cmake -E cmake_progress_report /other/workspace/perception/location_recognition/CMakeFiles 9
[ 11%] Automoc for target location_recognition
/usr/local/bin/cmake -E cmake_automoc /other/workspace/perception/location_recognition/CMakeFiles/location_recognition_automoc.dir/
AUTOMOC: Checking /other/workspace/perception/location_recognition/src/voting_classifier.cpp
AUTOMOC: Checking /other/workspace/perception/location_recognition/src/voting_classifier_helper.cpp
AUTOMOC: Checking /other/workspace/perception/location_recognition/src/results_scene.cpp
AUTOMOC: Checking /other/workspace/perception/location_recognition/src/image_window_widget.cpp
AUTOMOC: Checking /other/workspace/perception/location_recognition/src/image_result_matrix.cpp
AUTOMOC: Checking /other/workspace/perception/location_recognition/src/location_recognition.cpp
AUTOMOC: Checking /other/workspace/perception/location_recognition/src/main.cpp
make[2]: Leaving directory `/other/workspace/perception/location_recognition'
/usr/local/bin/cmake -E cmake_progress_report /other/workspace/perception/location_recognition/CMakeFiles  9
[ 11%] Built target location_recognition_automoc
make -f CMakeFiles/location_recognition.dir/build.make CMakeFiles/location_recognition.dir/depend
make[2]: Entering directory `/other/workspace/perception/location_recognition'
cd /other/workspace/perception/location_recognition && /usr/local/bin/cmake -E cmake_depends "Unix Makefiles" /other/workspace/perception/location_recognition /other/workspace/perception/location_recognition /other/workspace/perception/location_recognition /other/workspace/perception/location_recognition /other/workspace/perception/location_recognition/CMakeFiles/location_recognition.dir/DependInfo.cmake --color=
make[2]: Leaving directory `/other/workspace/perception/location_recognition'
make -f CMakeFiles/location_recognition.dir/build.make CMakeFiles/location_recognition.dir/build
make[2]: Entering directory `/other/workspace/perception/location_recognition'
/usr/local/bin/cmake -E cmake_progress_report /other/workspace/perception/location_recognition/CMakeFiles 3
[ 22%] Building CXX object CMakeFiles/location_recognition.dir/src/results_scene.cpp.o
/usr/bin/c++   -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -DQT_WIDGETS_LIB -O3 -DNDEBUG -fPIE -I/other/workspace/perception/location_recognition -I/opt/ros/fuerte/include/opencv -I/opt/ros/fuerte/include -I/other/workspace/perception/location_recognition/include -I/other/workspace/perception/location_recognition/ui_forms -I/other/Qt5.0.1/5.0.1/gcc_64/include -I/other/Qt5.0.1/5.0.1/gcc_64/include/QtWidgets -I/other/Qt5.0.1/5.0.1/gcc_64/include/QtGui -I/other/Qt5.0.1/5.0.1/gcc_64/include/QtCore -I/other/Qt5.0.1/5.0.1/gcc_64/mkspecs/linux-g++-64 -I/other/workspace/perception/location_recognition/../perception_kit/utilities/include -I/other/workspace/perception/location_recognition/../perception_kit/visual_categorization/include    -o CMakeFiles/location_recognition.dir/src/results_scene.cpp.o -c /other/workspace/perception/location_recognition/src/results_scene.cpp
In file included from /other/workspace/perception/location_recognition/src/results_scene.cpp:4:0:
/other/workspace/perception/location_recognition/include/perception_kit/location_recognition/results_scene.h:6:29: fatal error: ui_results_view.h: No such file or directory
compilation terminated.
make[2]: *** [CMakeFiles/location_recognition.dir/src/results_scene.cpp.o] Error 1
make[2]: Leaving directory `/other/workspace/perception/location_recognition'
make[1]: *** [CMakeFiles/location_recognition.dir/all] Error 2
make[1]: Leaving directory `/other/workspace/perception/location_recognition'
make: *** [all] Error 2

したがって、どういうわけか、ui_form ヘッダーを作成できるか、適切にリンクされていません。QT_WRAP_UI と QT5_WRAP_UI の実験にかなりの時間を費やしましたが、問題を解決できませんでした。正しく含まれる ui_form ヘッダーを取得するには、CMakeLists.txt で何を変更する必要がありますか?

4

1 に答える 1