我可以导致CMake内部错误吗?

问题描述 投票:0回答:1

根据我的问题What can cause a CMake option not work?我试图找出使用clean-all.cmake和手动删除构建目录之间是否有任何区别。在运行clean-all之后,我仍然遇到选项问题。当我删除build子目录时,我收到以下错误消息:

-- Looking for include file pthread.h
-- Looking for include file pthread.h - not found
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: Internal CMake error, TryCompile configure of cmake failed
CMake Error at /usr/local/share/cmake-3.2/Modules/FindPackageHandleStandardArgs.cmake:138 (message):
  Could NOT find Threads (missing: Threads_FOUND)
Call Stack (most recent call first):
  /usr/local/share/cmake-3.2/Modules/FindPackageHandleStandardArgs.cmake:374 (_FPHSA_FAILURE_MESSAGE)
  /usr/local/share/cmake-3.2/Modules/FindThreads.cmake:204 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  cmake/Dependencies.cmake:11 (find_package)
  CMakeLists.txt:53 (include)

并且日志文件仅包含:

Determining if files pthread.h exist failed with the following output:

Source:
/* */
#include <pthread.h>


int main(void){return 0;}

而且,从那以后,系统一直在告诉错误。所以,它看起来有区别:);它是什么?我的CMakeLists.txt可能会导致一些内部错误吗?

PS:在遇到这个永久性错误后,我开始寻找原因,再次构建我的CMakeLists.txt,从已删除的build子目录开始。

一开始,我有

option (CLEAN_ALL "Make a cleanup before building"  OFF)

后来

if(CLEAN_ALL)
include(cmake/clean-all.cmake)
endif(CLEAN_ALL)

和cmake文件是

# clean-all.cmake
# Cleans all subdirectories in the build subdirectory
set(cmake_generated ${CMAKE_BINARY_DIR}/CMakeCache.txt
                    ${CMAKE_BINARY_DIR}/cmake_install.cmake  
                    ${CMAKE_BINARY_DIR}/Makefile
                    ${CMAKE_BINARY_DIR}/CMakeFiles
# Above this, the common directories, below the project-specific ones                    
                    ${CMAKE_BINARY_DIR}/bin
                    ${CMAKE_BINARY_DIR}/lib
                    ${CMAKE_BINARY_DIR}/QtGUI
                    ${CMAKE_BINARY_DIR}/test
)

foreach(file ${cmake_generated})

  if (EXISTS ${file})
     file(REMOVE_RECURSE ${file})
  endif()

endforeach(file)

看起来错误是可重现的:删除构建并打开选项,我收到提到的错误。同时,选项OFF,它构建正常。使用那种干净的东西有什么害处吗?

cmake internal
1个回答
0
投票

CMake将作为文件构建的项目的状态存储在项目的构建目录中。这些文件不受保护,因此对它们进行不正确的修改(如删除)可能会导致项目状态变得不一致。

消息Internal CMake error意味着如果由CMake生成的项目构建文件在外部没有损坏,这可能(可能)是CMake中的错误。

否则,这样的错误只是表明项目构建以某种方式被破坏。

在给定的情况下,在CMake调用期间删除文件CMakeCache.txt导致不一致状态。 The answerclean- all.cmake脚本的起源,它明确表示在调用此脚本后,没有CMake命令可以正常工作。

© www.soinside.com 2019 - 2024. All rights reserved.