我想用安装目标生成Makefile,安装到/ usr而不是默认的/ usr/local.假设构建目录在源子目录中完成,我执行:
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr ..
CMakeCache.txt包含:( CMAKE_INSTALL_PREFIX:PATH=/usr好吗?)
现在我执行:
make make install
所有文件仍然安装到usr/local.怎么了?
编辑:任何CMakeLists.txt项目文件中都没有CMAKE_INSTALL_PREFIX.在运行cmake之前,我从输出目录中删除了所有内容.CMakeLists.txt中的install指令如下所示:
install(TARGETS mylibrary DESTINATION lib)
我正在尝试使用Windows上的CMake制作一个非常基本的Qt5应用程序.我使用Qt5的文档来使用CMake,我的main.cpp文件只包含一个main函数.
我CMakeLists.txt的确如此:
cmake_minimum_required(VERSION 2.8.9)
project(testproject)
Run Code Online (Sandbox Code Playgroud)
编辑解决方案
set (CMAKE_PREFIX_PATH "C:\\Qt\\Qt5.0.1\\5.0.1\\msvc2010\\")
Run Code Online (Sandbox Code Playgroud)
结束编辑
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
# Find the QtWidgets library
find_package(Qt5Widgets)
# Tell CMake to create the helloworld executable
add_executable(helloworld hello.cpp)
# Use the Widgets module from Qt 5.
qt5_use_modules(helloworld Widgets)
Run Code Online (Sandbox Code Playgroud)
在MSysGit bash中我输入`$ cmake -G"Visual Studio 11"
我得到这个输出:
$ cmake -G"Visual Studio 11"
-- The …Run Code Online (Sandbox Code Playgroud) 从这里:https://stackoverflow.com/a/28327499/462608
我试过这个:
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)
Run Code Online (Sandbox Code Playgroud)
这是输出 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 …Run Code Online (Sandbox Code Playgroud)