【发布时间】:2020-03-18 21:10:47
【问题描述】:
我正在尝试按照these instructions 使用 MinGW-w64 编译器在 MSYS2 上编译安装 BASIS(CMake 构建系统和软件实施标准)。但是,ccmake .. 步骤失败:
-bash: ccmake: 找不到命令
我尝试通过 pacman -Ss ccmake 搜索 MSYS2 包,但没有结果。所以我想我必须改用命令行cmake:
cmake -DCMAKE_INSTALL_PREFIX:PATH=~/local -DBUILD_APPLICATIONS:BOOL=ON -DBUILD_EXAMPLE:BOOL=ON ..
失败了:
CMake Error at src/cmake/modules/ProjectTools.cmake:876 (message):
CMAKE_INSTALL_PREFIX must be an absolute path!
Call Stack (most recent call first):
src/cmake/modules/ProjectTools.cmake:2525 (basis_installtree_asserts)
src/cmake/modules/ProjectTools.cmake:2751 (basis_project_begin)
CMakeLists.txt:69 (basis_project_impl)
作为一种解决方法,我将~/local 更改为/home/<userName>/local,这似乎可以正常工作。但是,我不知道 MakeFile(s) 在哪里,因为在运行 make . 时出现错误:
mingw32-make: *** 没有指定目标,也没有找到 makefile。停下来。
假设我在~/.bashrc 文件中有alias make='mingw32-make。如果您能帮助我了解问题所在以及如何解决,我将不胜感激。我安装了 MSYS2-MinGW-w64 包 mingw64/mingw-w64-x86_64-cmake。我的 Windows 是 1909 版,
而 MSYS_NT-10.0-18363 是我的环境。
P.S.1. 查看 CMake 的输出,我现在看到实际上有一个警告:
CMake Warning (dev) in CMakeLists.txt:
No project() command is present. The top-level CMakeLists.txt file must
contain a literal, direct call to the project() command. Add a line of
code such as
project(ProjectName)
near the top of the file, but after cmake_minimum_required().
CMake is pretending there is a "project(Project)" command on the first
line.
This warning is for project developers. Use -Wno-dev to suppress it.
这对这个项目来说有点讽刺,但我不确定这是否是编译失败的原因。
P.S.2. 我安装了mingw64/mingw-w64-x86_64-cmake 包,它没有ccmake 工具。但是msys/cmake 可以。所以:
pacman -R mingw-w64-x86_64-cmakepacman -S msys/cmake
现在ccmake 可用。
【问题讨论】:
-
如果 CMake 输出的最后一行是“构建文件已写入...”,则 CMake 配置成功完成,并且给定目录包含配置的项目。但是根据 CMake 设置,CMake 可能会为不同的构建系统配置项目。如果构建目录不包含
Makefile,则该项目已配置为其他构建系统。您可以使用-G参数明确指定构建系统(generator)。 -
对于在 MSys 下使用
make构建,请使用MSYS Makefiles生成器。 -
pacman -S cmake应该安装它,which ccmake应该是/usr/bin/ccmake -
@Foad 它是作为 cmake 的一部分为我安装的。
-
Re: 在顶级 CMakeLists 中需要“project()”命令,这是最近 CMake 版本中引入的一个已知“问题”(自创建 BASIS 以来)。另请参阅github.com/cmake-basis/BASIS/issues/629 以供参考。
标签: cmake compilation mingw-w64 msys2