Undefined reference when linking against LLVM libraries with CMake

I’ve downloaded and compiled the LLVM 17.0.2 source. I always get an undefined reference when trying to link against it.

Here is a sample C++ code:

#include <llvm/IR/LLVMContext.h>

int main() {
    llvm::LLVMContext x;
}

Here is the error I get upon compilation:

ld.exe: CMakeFiles/proj_name.dir/main.cpp.obj: in function `main':
main.cpp:4: undefined reference to `llvm::LLVMContext::LLVMContext()'
main.cpp:5: undefined reference to `llvm::LLVMContext::~LLVMContext()'

My CMakeLists.txt file looks as follows:

cmake_minimum_required(VERSION 3.26)

project(proj_name)

set(CMAKE_CXX_STANDARD 17)

set(LLVM_DIR "path_to_llvm_source/lib/cmake/llvm/")

find_package(LLVM REQUIRED CONFIG)

include_directories(${LLVM_INCLUDE_DIRS})
separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS})
add_definitions(${LLVM_DEFINITIONS_LIST})

add_executable(proj_name main.cpp)

llvm_map_components_to_libnames(llvm_libs support core irreader)

target_link_libraries(proj_name ${llvm_libs})

I even tried to link against every single library as follows:

file(GLOB libs "path_to_llvm_source/Release/lib/*.lib")
target_link_libraries(proj_name ${libs})

Still, getting the same linking error.