Please help with setup on Mac
I don't have a clue how to get this working. I know you have to edit the CmakeList.txt file but all my edits produced errors.
Can someone please advise how to get a simple project up and compiling on Mac?
Also it is my understanding that I don't need to download a compiler because Clang is built in to Mac. Is this correct?
请先登录再写评论。
You need to install XCode and its Command Line extension, for clang to be accessable to CLion
I installed xcode, which they say includes the command line extension.
when I try to build a simple file, I get this:
"/Applications/CLion EAP.app/Contents/bin/cmake/bin/cmake" --build /Users/Cary/Library/Caches/clion10/cmake/generated/ea7dfe3f/ea7dfe3f/Debug --target lion0 -- -j 8
CMakeFiles/lion0.dir/build.make:53: *** target pattern contains no `%'. Stop.
make[2]: *** [CMakeFiles/lion0.dir/all] Error 2
make[1]: *** [CMakeFiles/lion0.dir/rule] Error 2
make: *** [lion0] Error 2
how do get this resolved? does xcode include a clang and gcc compiler? how do i link this to Clion? Thanks.
If you have installed Xcode with command line extensions, open 'Preferences' -> 'Build, Execution, Deployment' -> 'Toolchains' in CLion. You should see 'CMake', 'make', 'C Compiler', 'C++ Compiler' and 'GDB' ticked. Then you're all set.
GCC is not part of the Xcode suite (at least since 10.9).
Thanks Carsten. I checked my preferences and I have everything checked already. But I still can't build. Also I'd like to use Clang for compiler.
Please try creating a new project with CLion, does it work or still the same problem?
Also, please check this thread https://devnet.jetbrains.com/message/5534006#5534006, you may have a similar issue.
Hi Anton,
I tried a new project but it still doesn't work. My cmakelists.txt looks like this below. Also how can I configure so I don't have to edit the cmakelists.txt file for each new project? Many thanks.
If you have Xcode installed, then you can you Clang that is bundled with Xcode, so you don't need to override CMAKE_C(XX)_COMPILER variables: everything should work without them.
If you do need to use your own version of Clang, then perhaps the problem is that the paths to the compilers miss the root "/".
upd: Also, it is better to override these variables externally, rather than in CMakeLists.txt itself. In CLion this can be done by putting something like "-D CMAKE_C_COMPILER=/path" into CMake options, or provide CC and CXX environment variables.
Thanks guys, I set the environment variables but I'm still getting an error message. See attached. What am I missing?
Attachment(s):
Screen Shot 2015-02-02 at 4.11.36 PM (2).png
Screen Shot 2015-02-02 at 4.10.52 PM (2).png
1) You don't need to set any environment variables if you simply want to use /usr/bin/clang, becase CMake will find it by itself
2) If you want to override compiler via environment variables, you need to use CC and CXX variables, not CMAKE_C_COMPILER and CMAKE_CXX_COMPILER.
With no environment variables I still get an error message. I changed the environment variables to CC and CXX and I still can't build. I am a pycharm user, love your products so I will purchase CLion but this is harder to set up than eclipse!
If you don't have any errors displayed in the "Toolchains" preference pane, then you can just create a new project in CLion and everything should work out of the box.
I appreciate your help, but I am getting nowhere with this. I tried cmake options, I tried environment variables, and also cmakelists.txt, and none of those options worked. I have the latest version of Xcode with command line tools installed. My toolchains pane is all checked off (see pic), but for some reason I cannot build a hello world project.
I love your products (I have Pycharm) and I got Clang to work on eclipse, so I'm somewhat literate, is it possible there is a problem for mac users?
Attachment(s):
Screen Shot 2015-02-02 at 5.57.45 PM.png
Do you have any 'fancy' characters in the project path (same issue as in https://devnet.jetbrains.com/message/5534006#5534006), like '+'? If you do, this may be a cause.
If not, please attach /'Users/Cary/Library/Caches/clion10/cmake/generated/ea7dfe3f/ea7dfe3f/Debug/CMakeFiles/lion0.dir/build.make' file - it looks like CMake generates a broken Makefile.
Thanks Anton! I had a project folder named C/C++ and the '/' was converted to a colon. I renamed the folder to just 'C++" and now all is well.