gpt4 book ai didi

c++ - CLion 2017.1 CMake 在mac OS10.12 上编译报错

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:09:53 24 4
gpt4 key购买 nike

我安装了 CLion for mac。但是当我创建一个“Hello, world”项目时,我遇到了一些问题。似乎 CMake 未能设置系统信息或什么。

这是我的 CMakeList.txt 由 CLion 默认生成:

cmake_minimum_required(VERSION 3.7)
PROJECT(untitled)

set(CMAKE_CXX_STANDARD 11)

set(SOURCE_FILES main.cpp)
add_executable(untitled ${SOURCE_FILES})

然后我得到如下错误:

> /Applications/CMake.app/Contents/bin/cmake -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - Unix Makefiles" /Users/changeset/CLionProjects/untitled
> -- The C compiler identification is AppleClang 8.1.0.8020038
> -- The CXX compiler identification is AppleClang 8.1.0.8020038 CMake Error at
> /Applications/CMake.app/Contents/share/cmake-3.7/Modules/CMakeSystemSpecificInformation.cmake:26
> (include): include called with wrong number of arguments. include()
> only takes one file. Call Stack (most recent call first):
> CMakeLists.txt:2 (PROJECT)
>
>
> System is unknown to cmake, create: Platform/sysname:Darwin
> nodename:Fez.local release:16.5.0 version:Darwin Kernel Version
> 16.5.0: Fri Mar 3 16:52:33 PST 2017; root:xnu-3789.51.2~3/RELEASE_X86_64 machine:x86_64 to use this
> system, please send your config file to cmake@www.cmake.org so it can
> be added to cmake Your CMakeCache.txt file was copied to
> CopyOfCMakeCache.txt. Please send that file to cmake@www.cmake.org.
> CMake Error at
> /Applications/CMake.app/Contents/share/cmake-3.7/Modules/CMakeCInformation.cmake:38
> (include): include called with wrong number of arguments. include()
> only takes one file. Call Stack (most recent call first):
> CMakeLists.txt:2 (PROJECT)
>
>
> CMake Error at
> /Applications/CMake.app/Contents/share/cmake-3.7/Modules/CMakeCInformation.cmake:41
> (include): include called with invalid argument:
> root:xnu-3789.51.2~3_RELEASE_X86_64
>
> machine:x86_64 Call Stack (most recent call first):
> CMakeLists.txt:2 (PROJECT)
>
>
> CMake Error at
> /Applications/CMake.app/Contents/share/cmake-3.7/Modules/CMakeCInformation.cmake:48
> (include): include called with wrong number of arguments. include()
> only takes one file. Call Stack (most recent call first):
> CMakeLists.txt:2 (PROJECT)
>
>
> CMake Error at
> /Applications/CMake.app/Contents/share/cmake-3.7/Modules/CMakeCInformation.cmake:52
> (include): include called with wrong number of arguments. include()
> only takes one file. Call Stack (most recent call first):
> CMakeLists.txt:2 (PROJECT)
>
>
> -- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
> CMake Error at
> /Applications/CMake.app/Contents/share/cmake-3.7/Modules/CMakeSystemSpecificInformation.cmake:26
> (include): include called with wrong number of arguments. include()
> only takes one file. Call Stack (most recent call first):
> /Users/changeset/CLionProjects/untitled/cmake-build-debug/CMakeFiles/CMakeTmp/CMakeLists.txt:2
> (project)
>
>
> System is unknown to cmake, create: Platform/sysname:Darwin
> nodename:Fez.local release:16.5.0 version:Darwin Kernel Version
> 16.5.0: Fri Mar 3 16:52:33 PST 2017; root:xnu-3789.51.2~3/RELEASE_X86_64 machine:x86_64 to use this
> system, please send your config file to cmake@www.cmake.org so it can
> be added to cmake CMake Error at
> /Applications/CMake.app/Contents/share/cmake-3.7/Modules/CMakeCInformation.cmake:38
> (include): include called with wrong number of arguments. include()
> only takes one file. Call Stack (most recent call first):
> /Users/changeset/CLionProjects/untitled/cmake-build-debug/CMakeFiles/CMakeTmp/CMakeLists.txt:2
> (project)
>
>
> CMake Error at
> /Applications/CMake.app/Contents/share/cmake-3.7/Modules/CMakeCInformation.cmake:41
> (include): include called with invalid argument:
> root:xnu-3789.51.2~3_RELEASE_X86_64
>
> machine:x86_64 Call Stack (most recent call first):
> /Users/changeset/CLionProjects/untitled/cmake-build-debug/CMakeFiles/CMakeTmp/CMakeLists.txt:2
> (project)
>
>
> CMake Error at
> /Applications/CMake.app/Contents/share/cmake-3.7/Modules/CMakeCInformation.cmake:48
> (include): include called with wrong number of arguments. include()
> only takes one file. Call Stack (most recent call first):
> /Users/changeset/CLionProjects/untitled/cmake-build-debug/CMakeFiles/CMakeTmp/CMakeLists.txt:2
> (project)
>
>
> CMake Error at
> /Applications/CMake.app/Contents/share/cmake-3.7/Modules/CMakeCInformation.cmake:52
> (include): include called with wrong number of arguments. include()
> only takes one file. Call Stack (most recent call first):
> /Users/changeset/CLionProjects/untitled/cmake-build-debug/CMakeFiles/CMakeTmp/CMakeLists.txt:2
> (project)
>
>
> CMake Error: Internal CMake error, TryCompile configure of cmake
> failed
> -- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
> -- broken CMake Error at /Applications/CMake.app/Contents/share/cmake-3.7/Modules/CMakeTestCCompiler.cmake:51
> (message): The C compiler
> "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc"
> 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:2 (PROJECT)
>
>
> -- Configuring incomplete, errors occurred! See also "/Users/changeset/CLionProjects/untitled/cmake-build-debug/CMakeFiles/CMakeOutput.log".
> See also
> "/Users/changeset/CLionProjects/untitled/cmake-build-debug/CMakeFiles/CMakeError.log".

当我第一次在 mac 上运行 CLion 项目时,它运行完美。但是当我在XCode上编译cocos2d后,这些问题就来了。我把我mac上的cocos2d文件全部删除了,但是cmake还是出错。

最佳答案

终于解决了我这里的问题。这似乎是不寻常的。

The errors listed about CMake were caused by incorrectly invoking uname.

我检查了 CMake manual , 我发现我的 mac 生成了错误的 CMAKE_HOST_SYSTEM_NAME结果。在我的终端上测试 uname 后,我发现可能是内核使用了错误的命令。然后我 echo $PATH 发现我的 $PATH 被昨天安装的 cocos2d-x 改变了。新的 $PATH 包括我为学习而编程的 uname,它覆盖了内核 uname。删除 my uname 后,清理 CMake,重新启动 CLion,一切正常。完毕。

关于c++ - CLion 2017.1 CMake 在mac OS10.12 上编译报错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43489997/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com