CLion 2017.1在Mac OS上的CMake编译错误10.12

问题描述:

我安装了CLion for mac。但是当我创建一个“Hello,world”项目时,我遇到了一些问题。看起来CMake未能设置系统信息或什么。CLion 2017.1在Mac OS上的CMake编译错误10.12

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 [email protected] so it can 
> be added to cmake Your CMakeCache.txt file was copied to 
> CopyOfCMakeCache.txt. Please send that file to [email protected] 
> 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 [email protected] 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我第一次运行克利翁项目,它运行完美

这是由克利翁默认生成我CMakeList.txt 。但是在XCode上编译cocos2d后,出现了这些问题。我删除了我的Mac上的所有cocos2d文件,但cmake仍然出错。

最后,我在这里解决了我的问题。这似乎很不寻常。

关于CMake列出的错误是由于错误地调用 uname造成的。

我检查了CMake manual,我发现我的mac产生了错误的CMAKE_HOST_SYSTEM_NAME结果。在我的终端上测试uname后,我发现内核可能使用了错误的命令。然后我echo $PATH发现我的$PATH由昨天安装的cocos2d-x改了。新的$PATH包括我编程的uname用于研究,并且它覆盖了内核uname。删除my uname后,清理CMake,重启CLion,一切都很顺利。完成。