我认为自己对 CMake 并不陌生,但我无法让它在我购买的较新的 Windows 计算机上运行。 唯一对我有用的生成器是一个实际的 Visual Studio 项目生成器(例如“Visual Studio 14 2015 Win64”)。我尝试了几个最新版本的 CMake(3.12.2、3.10.3),并且当我尝试另一个生成器(NMake Makefiles JOM、NMake Makefiles、CodeBlocks - NMake Makefiles 等)时总是得到以下内容。我应该补充一点,我正在以管理员身份打开的 VS2015 x64 native 工具命令提示符窗口中运行此命令行。
D:\Projects\build-QWar-newest>cmake -G "NMake Makefiles JOM" ../QWar
错误日志:
Determining if the C compiler works failed with the following output:
Change Dir: D:/Projects/build-QWar-newest/CMakeFiles/CMakeTmp
Run Build Command:"jom" "/NOLOGO" "cmTC_8b88c\fast"
jom: parallel job execution disabled for Makefile
C:\Qt\Tools\QtCreator\bin\jom.exe -f CMakeFiles\cmTC_8b88c.dir\build.make /nologo -L CMakeFiles\cmTC_8b88c.dir\build
Building C object CMakeFiles/cmTC_8b88c.dir/testCCompiler.c.obj
C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\cl.exe @C:\Users\Rich\AppData\Local\Temp\testCCompiler.c.obj.19968.0.jom
testCCompiler.c
Linking C executable cmTC_8b88c.exe
"C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_8b88c.dir --manifests -- C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\link.exe /nologo @CMakeFiles\cmTC_8b88c.dir\objects1.rsp @C:\Users\Rich\AppData\Local\Temp\cmTC_8b88c.exe.19968.375.jom
MT: command "mt /nologo /manifest CMakeFiles\cmTC_8b88c.dir/intermediate.manifest /out:CMakeFiles\cmTC_8b88c.dir/embed.manifest /notify_update" failed (exit code 0x0) with the following output:
The system cannot find the file specifiedjom: D:\Projects\build-QWar-newest\CMakeFiles\CMakeTmp\CMakeFiles\cmTC_8b88c.dir\build.make [cmTC_8b88c.exe] Error 2
jom: D:\Projects\build-QWar-newest\CMakeFiles\CMakeTmp\Makefile [cmTC_8b88c\fast] Error 2
这是一个简单的项目 - 这是来自 D:\Projects\QWar 的 CMakeLists.txt:
cmake_minimum_required(VERSION 3.0)
project(QWar)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
find_package(Qt5Core CONFIG REQUIRED)
add_executable(${PROJECT_NAME}
main.cpp
Card.cpp
Deck.cpp
Player.cpp
Round.cpp
Game.cpp)
target_link_libraries(${PROJECT_NAME} Qt5::Core)
编辑:重新格式化错误日志
我不确定我做错了什么。我已经让它可以与旧版本的 CMake 一起使用,事实上我有另一台带有 Qt5.7/CMake3.6.1 的机器,并且我上面尝试的方法有效。
最佳答案
感谢 kitware 的 Gregor,解决方案是确保“mt.exe”位于系统路径中。它附带与 Visual Studio 分开安装的 Windows SDK。
上面的错误并没有明确指出 mt 作为丢失的文件。使用 -debug-trycompile 运行 cmake 后,我可以自己运行临时构建,并且错误变得更加清晰。如果不使用 -debug-trycompile,当编译器测试失败时,它会默认删除它生成的临时文件。
关于windows - CMake 告诉我什么(Windows 上的错误)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52349891/