0

As I've tried getting cmake working with clang and gcc here I've run across what I think is the wierdest thing ever.

I have a small hello world-ish program that compiles perfectly using clang in cmake in ubuntu, the setup was super fast and it's just a fun thing to try.
Now on the windows side I have way more issues, I did the regular order of installing MinGW w64, then clang (also 64 bit) and lastly cmake (VS 15 was insalled earlier due to school projects). I managed to fumble with different cmake things until I almost got it compiling, clearing build directory and using cmake .. -G"MinGW Makefiles" in my build folder to try and get the thing compiling at all. What I instead got was errors telling me the compile failed and it wasn't long before I figured out why;
the try_compile of cmake tries to pass MSVC style flags like /nologo to clang which then thinks the flags are directories.

I couldn't find any way of forcing the flags to look like the regular -flag's.
Are there some hidden cmake variables that can be set or am I just screwed tring to compile in this specific configuration?

  • Which version of CMake do you use? `clang` support was only recently officially added. See e.g. [here](http://stackoverflow.com/questions/38171878/how-do-i-tell-cmake-to-use-clang-on-windows). – Florian Sep 20 '16 at 06:58
  • @Florian I'm using cmake 3.6.2, CMakeLists.txt has `cmake_minimum_required(3.6)` at the top, using NMake or MinGW makefiles makes no difference. – MetroidChild Sep 20 '16 at 07:12
  • clang has a VS-compatible mode, so cmake probably thinks you want to build with VS. I don't know how to fix it, though. – xaxxon Sep 20 '16 at 09:28
  • I found [this](http://public.kitware.com/pipermail/cmake/2012-May/050466.html) Now to try and edit the files, I'll file a bug report over at cmake if I get it running later today... – MetroidChild Sep 20 '16 at 12:27

1 Answers1

2

Add -fmsc-version=0 to the flags and CMake will not assume it's simulating MSVC.

This is checked here.

τεκ
  • 2,994
  • 1
  • 16
  • 14
  • Best answer ever. I've tried so hard to get this to work. Thanks to your answer I 've been finally able to build a very basic CMake toolchain file. Thanks! – Florian Wolters Jan 30 '17 at 22:50