C++ project compiles from terminal but not from CLion after clang switch

Viewed 61

I compiled clang-14 from source on my machine and now clion won't compile my code. However, everything works as expected when I compile from terminal.

Test project: CMakeLists.txt

cmake_minimum_required(VERSION 3.20)
project(test)

set(CMAKE_CXX_STANDARD 20)

set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}
  -fuse-ld=lld")

add_executable(test main.cpp)

main.cpp

#include <iostream>

int main() {
    std::cout << "Hello, World!" << std::endl;
    return 0;
}

I use default project setup with path/to/clang and path/to/clang++ as C and C++ compilers respectively in clion.

When I compile, I get the following error.

clang-14: error: no input files
make[3]: *** [CMakeFiles/test.dir/build.make:93: test] Error 1
make[2]: *** [CMakeFiles/Makefile2:83: CMakeFiles/test.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:90: CMakeFiles/test.dir/rule] Error 2
make: *** [Makefile:124: test] Error 2

To compile from terminal I do:

mkdir build
cd build
CC=path/to/clang CXX=path/to/clang++ cmake ..
make

What am I missing?

0 Answers
Related