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

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to