How to properly change the compilers in Toolchains Preferences ???

I'm quite confused.

I'm using the Eval version of CLion on OS X 10.10.1 (MAVERICKS).  I have Xcode : Version 6.3.1 (6D1002) installed.  I also have gcc-5.1.0 installed on this machine.

I want to use the gcc/g++ compilers from gcc-5.1.0.  But I cannot see how to change these settings...  I must be missing something.

An image of my Toolchains Preferences is below.  Notice that the C and C++ Compiler options point at the cc and c++ from Xcode.  cc and c++ are both symbolic links to clang in the Xcode folder.

Now, for testing purposes, I have simply changed these symbolic links to point at the gcc-5.1.0 and g++-5.1.0 compilers respectively.  Everything works fine...  But, my Xcode environment is now broken...

How do I accomplish this task "properly" ???  This is my first exposure to CMake...do I make these settings in the CMakeLists.txt file and then the changes will be reflected in the Toolchains Preferences ???  If so, please provide the syntax.  I think it might be the following :

CMAKE_C_COMPILER
the compiler used for C files.  Normally it is detected and set  during the CMake run, but you can override it at configuration time.  Note! It can not be changed after the first cmake or ccmake run. Although  the gui allows to enter an alternative, it will be ignored in the next  'configure' run. Use for example:
CC=gcc-3.3 CXX=g++-3.3 cmake
to set the compiler. (You can also set CMAKE_C_COMPILER_INIT, before  any PROJECT() or ENABLE_LANGUAGE() command.)  Any other way (like  writing make CC=gcc-3.3 CXX=g++-3.3) will not work. When using distcc or similar tools, you need to write:
CC="distcc gcc-3.3" CXX="distcc g++-3.3" cmake
However, this will empty all your CMAKE_..._FLAGS_... above.

and

CMAKE_CXX_COMPILER
the compiler used for C++ files.  Normally it is detected and set  during the CMake run, but you can override it at configuration time.  Note! It can not be changed after the first cmake or ccmake run.  See CMAKE_C_COMPILER above.

But what is this note in the description for CMAKE_C_COMPILER, "Note! It can not be changed after the first cmake or ccmake run." ??  Please point me at an explanation of what, precisely, this means.

And, where is the best documentation for CMake ???

As I write this, I am learning more and I think I see where this is going...  But, I'll shutup for now and let someone respond who has a better understanding of this topic.

Thanks !!!



Attachment(s):
Preferences_and_CMakeLists_txt_-_Test_-____ClionProjects_Test_.jpg
4 comments
Comment actions Permalink

OK, I have answered my own question.  You use the CC and CXX environment variables.  See : https://devnet.jetbrains.com/message/5534174#5534174

0
Comment actions Permalink

Sorry for abusing of this post but I'm having exactly the same problem and I'm not able to solve it with the CC/CXX environment solution.
I tried both the Cmake command line options (CMAKE_C_COMPILER and CMAKE_CXX_COMPILER) and the custom environment setting, but the toolchains panel still report that Clion is using the XCode compilers.

Here are two screenshot, the first of the toolchains and the second of the CMake settings. Needless to say the two compiler paths are correct: I tried also setting only the compiler name to the environment variables (due being in the PATH) but nothing changed.

Could someone please help me ? I'm using the last version of CLion (1.2.2)



Attachment(s):
Screenshot 2015-12-19 11.46.52.png
Screenshot 2015-12-19 11.47.09.png
0
Comment actions Permalink

Hi Salvatore.

Did you try to pass the following parameters in that view:
-D CMAKE_C_COMPILER=<your_path_to_c_compiler>  -D CMAKE_CXX_COMPILER=<your_path_to_cxx_compiler>

to Preferences (Settings) | Build, Execution, Deployment | CMake | CMake options?
Could you please delete system environments (CC/CXX) and send us a screenshot?
0
Comment actions Permalink

Hi Anna,

After lot of tries I just discovered the compiler used by CLion is ok, even if the toolchains doesn't report the correct ones (as you can see from the screenshot posted above)
I was able to discover it by setting "VERBOSE=1" in the build option and looking at the build messages, which report all the command executed for building.
I then moved from the environment variables to the CMake options (CMAKE_C_COMPILER and CMAKE_CXX_COMPILER) and the result was the same: the toolchains is still reporting the wrong information but the compiler is ok.
I don't know the reason of this missmatch but everything is work fine right now (although I spent lot of times on discovering this "bug")
Hope you will be able to solve it in next releases.

0

Please sign in to leave a comment.