1 cmakelists.txt没有设置变量
CMAKE_INSTALL_PREFIX
2 cmake源码默认生成的文件放置路径
#if defined(_WIN32) && !defined(__CYGWIN__)std::string prgfiles;std::string sysDrive;if (cmsys::SystemTools::GetEnv("ProgramFiles", prgfiles)) {this->InstallPath = prgfiles;} else if (cmsys::SystemTools::GetEnv("SystemDrive", sysDrive)) {this->InstallPath = cmStrCat(sysDrive, "/Program Files");} else {this->InstallPath = "c:/Program Files";
3 cmake 源码下载
Download CMake
4 CMAKE_INSTALL_PREFIX 使用
# 设置安装目录为 "/usr/local"
set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Installation directory")# 定义安装目标
install(TARGETS my_executable DESTINATION bin)
install(FILES my_header.h DESTINATION include)