[CMake] Question on usage of cmake on Windows with clang

Victor Leschuk vleschuk at gmail.com
Mon Feb 8 07:56:16 EST 2016


Hello, I am trying to use clang with cmake on Windows.

I have compiled LLVM+clang using Visual Studio 2015. And now I am facing 
problems with building cmake projects using this clang. It looks like 
cmake is trying to pass wrong options to linker.

Here simple test project:

$ cat CMakeLists.txt
project(test_proj)
add_executable(test
         test.cpp
)

$ cat test.cpp
#include <cstdio>

int main() {
         printf("Hi there\n");
}

I am trying to build it using the following command:

$ cmake .. -G "Ninja" -DCMAKE_C_COMPILER=clang 
-DCMAKE_CXX_COMPILER=clang -DCMAKE_C_COMPILER_ID=Clang 
-DCMAKE_CXX_COMPILER_ID=Clang

And it fails with the error:

   Run Build Command:"C:/ninja/ninja.exe" "cmTC_a2e93"

   [1/2] Building C object CMakeFiles\cmTC_a2e93.dir\testCCompiler.c.obj

   [2/2] Linking C executable cmTC_a2e93.exe

   FAILED: cmd.exe /C "cd .  && C:\Users\del\work\llvm\bin\clang.exe
   CMakeFiles\cmTC_a2e93.dir\testCCompiler.c.obj -o cmTC_a2e93.exe
   -Wl,--out-implib,libcmTC_a2e93.dll.a
   -Wl,--major-image-version,0,--minor-image-version,0 && cd ."

   LINK : warning LNK4044: unrecognized option '/-out-implib'; ignored

   LINK : warning LNK4044: unrecognized option '/-major-image-version';
   ignored

   LINK : warning LNK4044: unrecognized option '/-minor-image-version';
   ignored

   LINK : fatal error LNK1181: cannot open input file 'libcmTC_a2e93.dll.a'

   clang.exe: error: linker command failed with exit code 1181 (use -v 
to see
   invocation)

   ninja: build stopped: subcommand failed.

Here are the details on environment:

os: Windows 7 (64bit)

$ clang --version
clang version 3.9.0
Target: i686-pc-windows-msvc
Thread model: posix

$ cmake --version
cmake version 3.5.0-rc1

It would be great if someone could point me to what am I doing wrong?

Thanks in advance!

-- 
Best Regards,
Victor



More information about the CMake mailing list