CMake not using appropriate output command line argument for compiler
I'm working with CMake, and my program compiles fine with g++. However, I also wish to compiled it with bcc32 and cl.
I am running into an issue -- I'm telling cmake to use those compilers by doing a command line somewhat like "cmake -DCMAKE_CXX_COMPILER=cl" or whatnot, and it picks up the compiler correctly (ie, in that case, the MSVC variable is set to true).
However, it still seems to be using the gnu c开发者_如何学JAVAommand line arguments, which causes the compiler to fail on the CXX compiler test (ie, it tries to use -o to specify and output file for cl instead of /Fe, and instead of -e for bcc32).
Is there some proper way to specify which compiler to use, or some way to fix this?
You must use the -G
parameter which defines for which compiler the make files should be generated. Just start cmake --help
to see which generators are available. For example, -G "Visual Studio 9 2008"
will create makefiles for 32-bit Visual Studio 2008.
You can use any compiler you want with the makefile generators, but it has to be specified by full path, or available in the PATH environment variable.
One thing that might be confusing you is that once a compiler is specified in a CMake build tree, there is no way to change it. You have to blow away the build tree and start over to use a new compiler. You cannot simply run cmake over again with a different -DCMAKE_CXX_COMPILER argument. Start from scratch...
We run CMake dashboards on some clients using gmake and cl and the "Unix Makefiles" generator. See the script that sets up such a build here:
http://www.cdash.org/CDash/viewNotes.php?buildid=581283
To see the results of running the script, replace "viewNotes" with "buildSummary" in the URL...
精彩评论