Avast 为 运行 时出现 CMake 问题

CMake issue when Avast is running

当 avast 防病毒 运行ning 运行ning Windows 10 上 运行ning CMake 时,我遇到了问题。

我写了一个小基础CMakeLists.txt:

cmake_minimum_required(VERSION 3.10)

# set the project name
project(RayTracing)

# add the executable
add_executable(rat_tracing main.cpp)

当我 运行 cmake -G "MSYS Makefiles" CMakeLists.txt 激活 Avast 时,我得到::

-- The C compiler identification is GNU 10.3.0
-- The CXX compiler identification is GNU 10.3.0
-- Detecting C compiler ABI info
CMake Error at C:/Program Files/CMake/share/cmake-3.23/Modules/CMakeDetermineCompilerABI.cmake:49 (try_compile):
  Failed to open

    C:/Users/pc/Documents/C++/MyRayTracing/CMakeFiles/CMakeTmp/CMakeLists.txt

  Permission denied
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.23/Modules/CMakeTestCCompiler.cmake:26 (CMAKE_DETERMINE_COMPILER_ABI)
  CMakeLists.txt:4 (project)


-- Detecting C compiler ABI info - failed
-- Check for working C compiler: C:/Program Files/msys64/mingw64/bin/gcc.exe
CMake Error at C:/Program Files/CMake/share/cmake-3.23/Modules/CMakeTestCCompiler.cmake:56 (try_compile):
  Failed to open

    C:/Users/pc/Documents/C++/MyRayTracing/CMakeFiles/CMakeTmp/CMakeLists.txt

  Permission denied
Call Stack (most recent call first):
  CMakeLists.txt:4 (project)


-- Check for working C compiler: C:/Program Files/msys64/mingw64/bin/gcc.exe - broken
CMake Error at C:/Program Files/CMake/share/cmake-3.23/Modules/CMakeTestCCompiler.cmake:69 (message):
  The C compiler

    "C:/Program Files/msys64/mingw64/bin/gcc.exe"

  is not able to compile a simple test program.

  It fails with the following output:





  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:4 (project)


-- Configuring incomplete, errors occurred!
See also "C:/Users/pc/Documents/C++/MyRayTracing/CMakeFiles/CMakeOutput.log".
See also "C:/Users/pc/Documents/C++/MyRayTracing/CMakeFiles/CMakeError.log".

但是当我禁用 Avast 时,一切正常,我得到:

-- The C compiler identification is GNU 10.3.0
-- The CXX compiler identification is GNU 10.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/msys64/mingw64/bin/gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/msys64/mingw64/bin/g++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/pc/Documents/C++/MyRayTracing

我做了一些研究,但似乎没有人遇到过同样的问题。最相似的情况是 Avast 认为 Cmake 是病毒的情况。

谢谢。

在处理另一个小型 c++ 项目时,我找到了解决此问题的方法。

创建一个小的“你好词!”程序。

main.cpp

#include <iostream>

int main() {
    std::cout << "Hello word ! " << std::endl;

    return 0;
}

还有一个小 CMakeLists.txt。

CMakeLists.txt

cmake_minimum_required(VERSION 3.10)

# set the project name
project(Tutorial)

# add the executable
add_executable(Tutorial main.cpp)

使用cmakecmake-gui配置和构建项目。

此时会出现Avast的警告。它会说 CMakeLists.txt 正在尝试修改受保护的目录,在我的例子中是“C:/Users/pc/Documents/”,并会询问您是否允许它或不是。 授权它,它将适用于任何其他项目。