2017-12-05 30 views
0

을 찾는 CMake 도움이되지 않습니다 여기CMAKE_PREFIX_PATH는 여기에서 Qt5

cmake_minimum_required(VERSION 2.8.12) 

project(qtquick_hello_cmake) 

set(CMAKE_PREFIX_PATH "/opt/Qt5.9.1/5.9.1/") 

set(CMAKE_INCLUDE_CURRENT_DIR ON) 
set(CMAKE_AUTOMOC ON) 
set(CMAKE_AUTORCC ON) 

find_package(Qt5 COMPONENTS Quick Core REQUIRED) 

qt5_add_resources(RESOURCES qml.qrc) 

add_executable(${PROJECT_NAME} "main.cpp" "qml.qrc") 

qt5_use_modules(${PROJECT_NAME} Quick Core) 

target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Quick) 

cmake .

:~/junk/qtquick_hello_cmake$ cmake . 
CMake Error at CMakeLists.txt:11 (find_package): 
    By not providing "FindQt5.cmake" in CMAKE_MODULE_PATH this project has 
    asked CMake to find a package configuration file provided by "Qt5", but 
    CMake did not find one. 

    Could not find a package configuration file provided by "Qt5" with any of 
    the following names: 

    Qt5Config.cmake 
    qt5-config.cmake 

    Add the installation prefix of "Qt5" to CMAKE_PREFIX_PATH or set "Qt5_DIR" 
    to a directory containing one of the above files. If "Qt5" provides a 
    separate development package or SDK, be sure it has been installed. 


-- Configuring incomplete, errors occurred! 
See also "/home/.../junk/qtquick_hello_cmake/CMakeFiles/CMakeOutput.log". 

이의 출력 :

https://stackoverflow.com/a/28327499/462608 나는이 시도 그게 /opt/Qt5.9.1/ 미상임을 보여주는 것입니다. 존재합니다. 여기

:~/junk/qtquick_hello_cmake$ cd /opt/Qt5.9.1/5.9.1/ 
:/opt/Qt5.9.1/5.9.1$ ls 
android_armv7 android_x86 gcc_64 Src 

나는 -DCMAKE 옵션을 cmake를 실행하지만, 출력은 여전히 ​​동일합니다 : 디렉토리의

:~/junk/qtquick_hello_cmake$ cmake -DCMAKE_PREFIX_PATH=/opt/Qt5.9.1/5.9.1/ -DWITH_QT5=1 . 
CMake Error at CMakeLists.txt:11 (find_package): 
    By not providing "FindQt5.cmake" in CMAKE_MODULE_PATH this project has 
    asked CMake to find a package configuration file provided by "Qt5", but 
    CMake did not find one. 

    Could not find a package configuration file provided by "Qt5" with any of 
    the following names: 

    Qt5Config.cmake 
    qt5-config.cmake 

    Add the installation prefix of "Qt5" to CMAKE_PREFIX_PATH or set "Qt5_DIR" 
    to a directory containing one of the above files. If "Qt5" provides a 
    separate development package or SDK, be sure it has been installed. 


-- Configuring incomplete, errors occurred! 
See also "/home/.../junk/qtquick_hello_cmake/CMakeFiles/CMakeOutput.log". 

내용 :

:~/junk/qtquick_hello_cmake$ ls 
CMakeCache.txt CMakeFiles CMakeLists.txt main.cpp main.qml qml.qrc 

답변

0

내가 설치 다음 누락 된 패키지 :

sudo apt-get install qtbase5-dev 
sudo apt-get install qtdeclarative5-dev 

는 접두사의 종류는 이제 필요하지 않습니다 부착 :

:~/junk/qtquick_hello_cmake$ cat CMakeLists.txt 
    cmake_minimum_required(VERSION 2.8.12) 

    project(qtquick_hello_cmake) 

    set(CMAKE_INCLUDE_CURRENT_DIR ON) 
    set(CMAKE_AUTOMOC ON) 
    set(CMAKE_AUTORCC ON) 

    find_package(Qt5 COMPONENTS Quick Core REQUIRED) 

    qt5_add_resources(RESOURCES qml.qrc) 

    add_executable(${PROJECT_NAME} "main.cpp" "qml.qrc") 

    qt5_use_modules(${PROJECT_NAME} Quick Core) 

    target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Quick) 


:~/junk/qtquick_hello_cmake$ ls 
build CMakeLists.txt main.cpp main.qml qml.qrc 

:~/junk/qtquick_hello_cmake$ cd build/ 
:~/junk/qtquick_hello_cmake/build$ rm -rf * 

:~/junk/qtquick_hello_cmake/build$ cmake ../ 
-- The C compiler identification is GNU 4.8.4 
-- The CXX compiler identification is GNU 4.8.4 
-- Check for working C compiler: /usr/bin/cc 
-- Check for working C compiler: /usr/bin/cc -- works 
-- Detecting C compiler ABI info 
-- Detecting C compiler ABI info - done 
-- Check for working CXX compiler: /usr/bin/c++ 
-- Check for working CXX compiler: /usr/bin/c++ -- works 
-- Detecting CXX compiler ABI info 
-- Detecting CXX compiler ABI info - done 
-- Configuring done 
-- Generating done 
-- Build files have been written to: /home/.../junk/qtquick_hello_cmake/build 

오류는 이제 사라졌다.

덕분에 약
https://answers.ros.org/question/236324/could-not-find-a-package-configuration-file-provided-by-qt5widgets/
https://askubuntu.com/questions/508503/whats-the-development-package-for-qt5-in-14-04

0

CMake 오류 메시지 find_package 실패 CMAKE_PREFIX_PATH 설정 변수

을 CMAKE_PREFIX_PATH하는 "Qt5"의 설치 접두사를 추가

은 오해의 소지가 있습니다. "설치 접두사"에 대해서만 말하지만,이 설치는 여전히 에 또는 qt5-config.cmake 파일을 포함해야합니다.이 파일은 find_package에 의해 검색 가능합니다.

그러나 메시지

"Qt5"는 별도의 개발 패키지 또는 SDK,이 설치되어 확인을 제공합니다.

는 분명하다 : 필요한 설정 파일을 포함하는 개발 패키지를 설치하는

하나가 필요합니다.


모든 위의 스크립트는 CMake으로도이 명령을 사용 CMake 프로젝트로도 제공되고, 때 "찾기"만 CONFIG find_package 모드로 적용 할 수 있습니다.