CMakeList set CMAKE_PREFIX_PATH

a 夏天 提交于 2020-08-04 05:56:21

问题


If I run

cmake -DCMAKE_PREFIX_PATH=/home/rip/Qt/5.12.1/gcc_64/lib/cmake

everything works well. But if I write

set(CMAKE_PREFIX_PATH "/home/rip/Qt/5.12.1/gcc_64/lib/cmake")

in the CMakeLists.txt and run only cmake, the error message below is shown:

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

   Qt5QuickConfig.cmake
   qt5quick-config.cmake

This is the complete code:

set(CMAKE_CXX_FLAGS " -O3 -fopenmp")
set(CMAKE_PREFIX_PATH "/home/rip/Qt/5.12.1/gcc_64/lib/cmake")

project(${PROJECT_NAME} LANGUAGES CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(SOURCES main.cpp Test5.cpp )
set(HAEDERS Test5.h )
set(RESOURCES qml.qrc )

find_package(Qt5 COMPONENTS Core Quick REQUIRED)
add_executable(${PROJECT_NAME} ${SOURCES} ${HAEDERS} ${RESOURCES}) 
target_compile_definitions(${PROJECT_NAME} PRIVATE $,$>:QT_QML_DEBUG>) 
target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Core Qt5::Quick)

回答1:


The prefix path is a list of paths. Use this:

list(APPEND CMAKE_PREFIX_PATH "/home/rip/Qt/5.12.1/gcc_64")

Also you don't have to point directly into the config file path, you also can point into the directory containing the lib/cmake/...



来源:https://stackoverflow.com/questions/55120611/cmakelist-set-cmake-prefix-path

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!