View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0008530CMakeModulespublic2009-02-13 04:052010-05-12 16:34
Reporterstephan Aiche 
Assigned ToAlex Neundorf 
PrioritynormalSeveritytweakReproducibilityN/A
StatusclosedResolutionno change required 
PlatformOSOS Version
Product VersionCMake-2-6 
Target VersionFixed in Version 
Summary0008530: make CMAKE_CXX_COMPILER_INIT customizable from CMakeLists.txt
DescriptionIt would be quite useful if there would be a possibility to set the sequence in which CMake determines the c++ compilers. eg prefer g++ instead of c++

currently this is hardcoded in "modules/CMakeDetermineCXXCompiler.cmake" line 45
    SET(CMAKE_CXX_COMPILER_LIST ${_CMAKE_TOOLCHAIN_PREFIX}c++ ${_CMAKE_TOOLCHAIN_PREFIX}g++ CC aCC cl bcc xlC)

i think the same holds for the C compiler
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0015624)
Alex Neundorf (developer)
2009-03-10 17:43

If you set the environment variable CXX before running cmake the first time, you can also force cmake to use this compiler and nothing else.

Or you could set CMAKE_CXX_COMPILER when running cmake:
cmake -DCMAKE_CXX_COMPILER=/usr/bin/g++ ...

Does this solve your problem ?

Alex
(0015643)
stephan Aiche (reporter)
2009-03-11 06:24

It is not directly a problem it is more a suggestion for an improvment of CMake. I know that I can specify my compiler by setting CXX or CMAKE_CXX_COMPILER. But this is for those who use the CMakeLists.txt.

What I suggested was a way for those guys who write the CMakeLists.txt to specify their own priority of for the compilers. eg. prefer g++ or intel-compilers ..

Stephan
(0020727)
Alex Neundorf (developer)
2010-05-12 16:34

You can do the following in your toplevel CMakeLists.txt, before the first call to project():

set(CMAKE_GENERATOR_CC icc gcc)
set(CMAKE_GENERATOR_CXX icpc g++)

project(MyProject)

This is not completely obvious, maybe more like an undocumented internal variable, but it works.
It will make cmake first search for the Intel compilers, then the GNU ones.
After that you can test which one has been found:

if ("${CMAKE_C_COMPILER_ID}" MATCHES Intel)
...
endif().

And you have, as mentioned in my first comment, also the option to just set the compiler directly when invoking cmake.

So I think there is no need for extra changes in cmake.

Alex

 Issue History
Date Modified Username Field Change
2009-02-13 04:05 stephan Aiche New Issue
2009-02-13 09:15 Bill Hoffman Status new => assigned
2009-02-13 09:15 Bill Hoffman Assigned To => Alex Neundorf
2009-03-10 17:43 Alex Neundorf Note Added: 0015624
2009-03-10 17:43 Alex Neundorf Category CMake => Modules
2009-03-11 06:24 stephan Aiche Note Added: 0015643
2009-09-12 02:22 Alex Neundorf Severity feature => tweak
2010-05-12 16:34 Alex Neundorf Note Added: 0020727
2010-05-12 16:34 Alex Neundorf Status assigned => closed
2010-05-12 16:34 Alex Neundorf Resolution open => no change required


Copyright © 2000 - 2018 MantisBT Team