A
A
Alexey Solovyov2016-04-13 02:42:56
CMake
Alexey Solovyov, 2016-04-13 02:42:56

How to disable the default /Zm option when generating a project using cmake for Visual Studio?

Good day,
a little background: there is a project that is successfully built by cmake using standard generators and compilers. There was a need to test it with clang. If you use the clang compiler clang-cl.exe (according to the documentation, it repeats the behavior of the standard cl), specifying cmake -T LLVM-vs2014, then in principle everything works, but just "repeat behavior" does not suit you. If you use Microsoft's fork CMake from the https://github.com/Microsoft/CMake/tree/feature/cl... branch along with clang added to the latest versions of VS, then the project is also relatively well built (using - T v140_Clang_3_7), having problems with includes and ignoring some clang options.
Essence of the question: if you try to use the compiled "real" clang / clang ++ (changing the MSBuild templates a bit), then regardless of the version of CMake (installed 3.5.1 or 3.4.2 from a fork from MS), CMake crashes with errors:
-- The C compiler identification is Clang 3.9.0
-- The CXX compiler identification is Clang 3.9.0
Check for working C compiler: D:/Temp/llvm090415/install/bin/clang.exe -- broken
CMake Error at D:/Program Files (x86)/CMake351/share/cmake-3.5/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler "D:/Temp/llvm090415/install/bin/clang.exe" is not able to
compile a simple test program.
....
clang: error: unsupported use of internal gcc -Z option '-Zm'
https://msdn.microsoft.com/en-us/library/bdscwf1c.aspx) , but for some strange reason it is always added to the compilation options, even if I explicitly set -DCMAKE_C_FLAGS/-DCMAKE_CXX_FLAGS (it is added after their contents); I couldn't find it in any of the CMake templates (from share), in any of the MSBuild templates, or in the CMake sources. Technically, I can try to parse (and ignore) this option in the clang sources, but maybe there are easier ways to get rid of it? And where does it come from, in the absence of MSBuild templates?
PS The nmake option for this project doesn't work at all, even with the standard compiler.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question