CMake is insane on Windows

This topic is 378 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I am trying to build with Clang on Windows for the first time. I usually use G++ but it creates large static files which irritate me. I also want to try CLang on windows, since I use CLang exclusively on Linux.

There is nothing that seems to work to make it stop sending "MSVC-like" parameters to the compiler. How can I disable MSVC-detection?

It clearly says:

C:\Projects\dm2\clang>cmake .. -G "MinGW Makefiles" -DCMAKE_CXX_COMPILER="c:\\LLVM\\bin\\clang++.exe"
-- The CXX compiler identification is Clang 4.0.1
-- Check for working CXX compiler: c:\LLVM\bin\clang++.exe
-- Check for working CXX compiler: c:\LLVM\bin\clang++.exe -- broken

...

c:\LLVM\bin\clang++.exe /nologo /DWIN32 /D_WINDOWS /W3 /GR /EHsc /D_DEBUG

...
predictable output
...

what's going on here?

EDIT:

I'm using newest CMake, newest LLVM for win64, newest MSYS and MinGW64. I am successfully building statically with G++ as of writing this.

Edited by Kaptein

Share on other sites

I believe the problem is you're specifying the command line parameters after you specified the CMakeLists.txt file instead of before. I know this is common on Windows (for whatever reason) but it's not going to fly here.

This should work: Notice the two dots at the end instead of at the start:

cmake -G "MinGW Makefiles" -DCMAKE_CXX_COMPILER="c:\\LLVM\\bin\\clang++.exe" ..

Share on other sites

Unfortunately, it's the same output as before: it detects CLang 4.0.1 and then proceeds to MSVC

EDIT: I tried cmake with MSYS, and I also get the same output:

 cmake -G "MSYS Makefiles" -DCMAKE_CXX_COMPILER=/c/LLVM/bin/clang++.exe -DCMAKE_MAKE_PROGRAM=mingw32-make ..

...

/C/LLVM/bin/clang++.exe /nologo /DWIN32 /D_WINDOWS /W3 /GR /EHsc /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1

Even if I should find some hack to make this work, it shouldn't be behaving like this.

Edited by Kaptein

Share on other sites

Do you have an old CMakeCache.txt or other build detritus sitting around from a previous VC build? Usually when I get this kind of weirdness, that tends to be the case. Make sure it's completely clean, with no previous build stuff getting in the way.

Share on other sites
Just now, JTippetts said:

Do you have an old CMakeCache.txt or other build detritus sitting around from a previous VC build? Usually when I get this kind of weirdness, that tends to be the case. Make sure it's completely clean, with no previous build stuff getting in the way.

Yea the build folders are cleaned out each time, so unless there are some hidden files it should be empty

Share on other sites

you need to used a toolchain file that specify the configuration to use as I found this was the easiest way to do cross-compilation/non-standard toolchain. Ex This is the content of my basic toolchain file for Android x86 build

set(CMAKE_SYSTEM_NAME Android)
set(CMAKE_SYSTEM_VERSION 16) # API level
set(CMAKE_ANDROID_ARCH_ABI x86)
set(CMAKE_ANDROID_NDK<Path>/Android/android-ndk-r11c)
set(CMAKE_ANDROID_STL_TYPE gnustl_shared)
set(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION clang)

If you need further detail see the CMake docs in regards to using toolchain files. Also I remove the actual path for the variable CMAKE_ANDROID_NDK, but this should not have any impact as this was just for illustration..Please do not just copy and paste without consulting the CMake documentation.

1. 1
Rutin
24
2. 2
3. 3
JoeJ
18
4. 4
5. 5

• 38
• 23
• 13
• 13
• 17
• Forum Statistics

• Total Topics
631706
• Total Posts
3001835
×