0

Why does my C compiler (Clang) fail to compile a simple test program when opening a CMake project in CLion?

I'm trying to setup CLion to run with CMake, Ninja, Clang and Clang++. To test it I tried opening a new project, the Clang source. When opening a new project I selected ~/src/llvm-project/clang/

Clion then opens the project and proceeds to immediately give me the following debug output:

/snap/clion/85/bin/cmake/linux/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=/usr/bin/ninja -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -G "CodeBlocks - Unix Makefiles" /home/kim/src/llvm-project/clang -- The C compiler identification is Clang 6.0.0 -- The CXX compiler identification is Clang 6.0.0 -- Check for working C compiler: /usr/bin/clang -- Check for working C compiler: /usr/bin/clang -- broken CMake Error at /snap/clion/85/bin/cmake/linux/share/cmake-3.15/Modules/CMakeTestCCompiler.cmake:60 (message): The C compiler

"/usr/bin/clang"

is not able to compile a simple test program.

It fails with the following output:

Change Dir: /home/kim/src/llvm-project/clang/cmake-build-debug/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/ninja cmTC_a3bcb/fast && ninja: error: loading 'build.ninja': No such file or directory

CMake will not be able to correctly generate this project. Call Stack (most recent call first): CMakeLists.txt:10 (project)

-- Configuring incomplete, errors occurred! See also "/home/kim/src/llvm-project/clang/cmake-build-debug/CMakeFiles/CMakeOutput.log". See also "/home/kim/src/llvm-project/clang/cmake-build-debug/CMakeFiles/CMakeError.log".

CMakeOutput.log contains:

The system is: Linux - 5.0.0-29-generic - x86_64 Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded. Compiler: /usr/bin/clang Build flags: Id flags:

The output was: 0

Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "a.out"

The C compiler identification is Clang, found in "/home/kim/src/llvm-project/clang/cmake-build-debug/CMakeFiles/3.15.3/CompilerIdC/a.out"

Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded. Compiler: /usr/bin/clang++ Build flags: Id flags:

The output was: 0

Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "a.out"

The CXX compiler identification is Clang, found in "/home/kim/src/llvm-project/clang/cmake-build-debug/CMakeFiles/3.15.3/CompilerIdCXX/a.out"

The CMakeError.log contains:

Determining if the C compiler works failed with the following output: Change Dir: /home/kim/src/llvm-project/clang/cmake-build-debug/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/ninja cmTC_a3bcb/fast && ninja: error: loading 'build.ninja': No such file or directory

1 Answer 1

0

I also asked JetBrains for help and apparently CLion doesn't yet support Ninja CMake generator. I will simply have to use make instead of Ninja for now. Work is ongoing to support Ninja as well.

https://intellij-support.jetbrains.com/hc/en-us/requests/2306298

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .