CMake does not find Visual C++ compiler

前端 未结 27 2380
小鲜肉
小鲜肉 2020-11-29 18:51

After installing Visual Studio 2015 and running CMake on a previous project, CMake errors stating that it could not find the C compiler.

The C compiler ident         


        
27条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-29 19:30

    In my case the issue was that the parent project, which is including googletest via

    add_subdirectory(gtest_dir)
    

    was defined as

    PROJECT( projname CXX )
    

    Somehow, CMake does not recognize

    PROJECT(sub_project_name CXX C)
    

    since the C compiler is not set in the parent.

    I solved the issue by using

    PROJECT( projname CXX C)
    

    in my main CMakeLists.txt file.

提交回复
热议问题